Skip to content

Liveness probe

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: liveness-probe
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      name: liveness-probe
      labels:
        app: liveness-probe
    spec:
      # only supports always
      # restartPolicy: Always
      initContainers:
      - name: initcontainer
        image:  quay.io/openshift-examples/gitlab-runner:latest
        command: [ "/bin/sh", "-c", "sleep 1; echo init done" ]
      containers:
      - name: container-runner
        image:  quay.io/openshift-examples/gitlab-runner:latest
        command: 
        - /bin/sh
        - -c
        - |
          counter=0; while true ; do echo "$counter : $(date)";sleep 1 ; counter=$((counter+1)) ; done;
      - name: container-crashes
        image:  quay.io/openshift-examples/gitlab-runner:latest
        command:
        - /bin/sh
        - -c
        - |
          counter=0; while true ; do echo "$counter : $(date)";sleep 1 ; counter=$((counter+1)) ; done;
        startupProbe:
          exec:
            command:
            - /usr/bin/bash
            - -x
            - -c
            - |
              false       
        livenessProbe:
          exec:
            command:
            - /usr/bin/bash
            - -x
            - -c
            - |
              false
          initialDelaySeconds: 10
          periodSeconds: 5
  triggers:
  - type: ConfigChange

Last update: April 12, 2020