Difference between revisions of "Kubernetes Container Lifecycle Events"
Jump to navigation
Jump to search
(Created page with "* https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/ * {{Lifecycle}}") |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
+ | == Official example == | ||
+ | <pre> | ||
+ | apiVersion: v1 | ||
+ | kind: Pod | ||
+ | metadata: | ||
+ | |||
+ | name: lifecycle-demo | ||
+ | |||
+ | spec: | ||
+ | |||
+ | containers: | ||
+ | |||
+ | - name: lifecycle-demo-container | ||
+ | |||
+ | image: nginx | ||
+ | |||
+ | lifecycle: | ||
+ | |||
+ | postStart: | ||
+ | |||
+ | exec: | ||
+ | |||
+ | command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"] | ||
+ | |||
+ | preStop: | ||
+ | |||
+ | exec: | ||
+ | |||
+ | command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"] | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | == Related == | ||
+ | * [[Kubernetes Pod Lifecycle]] | ||
+ | |||
+ | == See also == | ||
* {{Lifecycle}} | * {{Lifecycle}} | ||
+ | * {{Pod}} | ||
+ | |||
+ | [[Category:K8s]] |
Latest revision as of 08:24, 28 October 2022
Official example[edit]
apiVersion: v1 kind: Pod metadata: name: lifecycle-demo spec: containers: - name: lifecycle-demo-container image: nginx lifecycle: postStart: exec: command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"] preStop: exec: command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]
Related[edit]
See also[edit]
Advertising: