To configure health checks, create a pod for each type of check you want.
To create health checks:
-
Create a Liveness Container Execution Check:
-
Create a YAML file similar to the following:
apiVersion: v1 kind: Pod metadata: labels: test: liveness name: liveness-exec spec: containers: - args: image: k8s.gcr.io/liveness livenessProbe: exec: (1) command: (2) - cat - /tmp/health initialDelaySeconds: 15 (3) ...
-
Specify a Liveness check and the type of Liveness check.
-
Specify the commands to use in the container.
-
Specify the number of seconds before performing the first probe after the container starts.
-
-
Verify the state of the health check pod:
$ oc describe pod liveness-exec Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 9s default-scheduler Successfully assigned openshift-logging/liveness-exec to ip-10-0-143-40.ec2.internal Normal Pulling 2s kubelet, ip-10-0-143-40.ec2.internal pulling image "k8s.gcr.io/liveness" Normal Pulled 1s kubelet, ip-10-0-143-40.ec2.internal Successfully pulled image "k8s.gcr.io/liveness" Normal Created 1s kubelet, ip-10-0-143-40.ec2.internal Created container Normal Started 1s kubelet, ip-10-0-143-40.ec2.internal Started container
NoteThe
timeoutSeconds
parameter has no effect on the Readiness and Liveness probes for Container Execution Checks. You can implement a timeout inside the probe itself, as {product-title} cannot time out on an exec call into the container. One way to implement a timeout in a probe is by using thetimeout
parameter to run your liveness or readiness probe:spec: containers: livenessProbe: exec: command: - /bin/bash - '-c' - timeout 60 /opt/eap/bin/livenessProbe.sh (1) timeoutSeconds: 1 periodSeconds: 10 successThreshold: 1 failureThreshold: 3
-
Timeout value and path to the probe script.
-
-
Create the check:
$ oc create -f <file-name>.yaml
-
-
Create a Liveness TCP Socket Check:
-
Create a YAML file similar to the following:
apiVersion: v1 kind: Pod metadata: labels: test: liveness name: liveness-tcp spec: containers: - name: contaier1 (1) image: k8s.gcr.io/liveness ports: - containerPort: 8080 (1) livenessProbe: (2) tcpSocket: port: 8080 initialDelaySeconds: 15 (3) timeoutSeconds: 1 (4)
-
Specify the container name and port for the check to connect to.
-
Specify the Liveness heath check and the type of Liveness check.
-
Specify the number of seconds before performing the first probe after the container starts.
-
Specify the number of seconds between probes.
-
-
Create the check:
$ oc create -f <file-name>.yaml
-
-
Create an Readiness HTTP Check:
-
Create a YAML file similar to the following:
apiVersion: v1 kind: Pod metadata: labels: test: readiness name: readiness-http spec: containers: - args: image: k8s.gcr.io/readiness (1) readinessProbe: (2) httpGet: # host: my-host (3) # scheme: HTTPS (4) path: /healthz port: 8080 initialDelaySeconds: 15 (5) timeoutSeconds: 1 (6)
-
Specify the image to use for the liveness probe.
-
Specify the Readiness heath check and the type of Readiness check.
-
Specify a host IP address. When
host
is not defined, thePodIP
is used. -
Specify
HTTP
orHTTPS
. Whenscheme
is not defined, theHTTP
scheme is used. -
Specify the number of seconds before performing the first probe after the container starts.
-
Specify the number of seconds between probes.
-
-
Create the check:
$ oc create -f <file-name>.yaml
-