Skip to content

Instantly share code, notes, and snippets.

@worldofprasanna
Created February 18, 2019 14:55
Show Gist options
  • Select an option

  • Save worldofprasanna/38807f53c2d8bbcb3c04ee81a7bbb968 to your computer and use it in GitHub Desktop.

Select an option

Save worldofprasanna/38807f53c2d8bbcb3c04ee81a7bbb968 to your computer and use it in GitHub Desktop.
Lifecycle of k8s pod
kind: Deployment
apiVersion: apps/v1beta1
metadata:
name: lifecycle
spec:
replicas: 1
template:
metadata:
labels:
app: lifecycle
spec:
volumes:
- name: shared-log-record
hostPath:
path: /tmp/logs
type: Directory
initContainers:
- name: init-container
image: busybox
command: ['sh', '-c', 'echo $(date): Init Container >> /logs/record && sleep 5']
volumeMounts:
- name: shared-log-record
mountPath: /logs
containers:
- name: main-container
image: busybox
volumeMounts:
- name: shared-log-record
mountPath: /logs
command: ['sh', '-c', 'echo $(date): Running main container >> /logs/record && echo "The app is started" && /bin/sleep 30']
readinessProbe:
exec:
command: ['sh', '-c', 'echo $(date): Invoking Readiness Probe >> /logs/record']
initialDelaySeconds: 5
livenessProbe:
exec:
command: ['sh', '-c', 'echo $(date): Invoking Liveliness Probe >> /logs/record']
initialDelaySeconds: 5
timeoutSeconds: 30
lifecycle:
postStart:
exec:
command: ['sh', '-c', 'echo $(date): Invoking Post Start >> /logs/record']
preStop:
exec:
command: ['sh', '-c', 'echo $(date): Invoking Pre Stop >> /logs/record']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment