--- apiVersion: v1 kind: ConfigMap metadata: name: test namespace: swh data: pre-stop.sh: | #!/bin/bash set -ex if [ ! -e /var/run/stopped ]; then kill 1 else echo "Doing noting" fi touch /var/run/stopped --- apiVersion: apps/v1 kind: Deployment metadata: namespace: swh name: test-local-storage spec: revisionHistoryLimit: 2 selector: matchLabels: app: swh-test template: metadata: labels: app: swh-test spec: #affinity: # nodeAffinity: # requiredDuringSchedulingIgnoredDuringExecution: # nodeSelectorTerms: # - matchExpressions: # - key: "kubernetes.io/hostname" # operator: In # values: # - "rancher-node-production-worker01" terminationGracePeriodSeconds: 3600 containers: - name: test-local-storage image: debian:bullseye command: - /bin/sleep args: - "3600" imagePullPolicy: Always volumeMounts: - name: local mountPath: /tmp lifecycle: preStop: exec: command: ["/pre-stop.sh"] volumeMounts: - name: test mountPath: /pre-stop.sh subPath: "pre-stop.sh" volumes: - name: local emptyDir: {} - name: test configMap: name: test defaultMode: 0777 items: - key: "pre-stop.sh" path: "pre-stop.sh" - name: metadata-fetcher-credentials secret: secretName: metadata-fetcher-credentials optional: true