Skip to content

Init containers

Example for

  • DNS Check
  • TCP Check
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: myapp-container
    image: busybox
    command: ['sh', '-c', 'echo The app is running! && sleep 3600']
  initContainers:
  - name: check-tcp
    image: rhel7/rhel-tools
    command: ['sh', '-c', 'while true ; do echo "Try to connect " ; nc -z myserver 8080 && break; sleep 5; done; echo "Eventserver is running..."']
  - name: check-nslookup
    image: busybox
    command: ['sh', '-c', 'while true; do nslookup mydb || break ; sleep 2 ; echo "waiting for mydb"; done;']

Last update: April 12, 2020