Skip to content

Instantly share code, notes, and snippets.

@StevenACoffman
Created January 8, 2020 20:21
Show Gist options
  • Save StevenACoffman/72fe9db7b011ca5b1192a01ed4011219 to your computer and use it in GitHub Desktop.
Save StevenACoffman/72fe9db7b011ca5b1192a01ed4011219 to your computer and use it in GitHub Desktop.
healthcheck.md

Many applications running for long periods of time eventually transition to broken states, and cannot recover except by being restarted. Kubernetes provides liveness probes to detect and remedy such situations.

apiVersion: batch/v1
kind: Job
metadata:
  labels:
    test: liveness
  name: liveness-exec
spec:
  ttlSecondsAfterFinished: 100
  backoffLimit: 4
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: liveness
        image: k8s.gcr.io/busybox
        volumeMounts:
          - name: tempdir
            mountPath: "/tmp"
        args:
        - /bin/sh
        - -c
        - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
        terminationMessagePolicy: FallbackToLogsOnError
        livenessProbe:
          exec:
            command:
            - cat
            - /tmp/healthy
          initialDelaySeconds: 5
          periodSeconds: 5
      volumes:
      - name: tempdir
        emptyDir: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment