Skip to content

Latest commit

 

History

History
161 lines (144 loc) · 4.09 KB

application-health-configuring.adoc

File metadata and controls

161 lines (144 loc) · 4.09 KB

Configuring health checks

To configure health checks, create a pod for each type of check you want.

Procedure

To create health checks:

  1. Create a Liveness Container Execution Check:

    1. 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)
      ...
      1. Specify a Liveness check and the type of Liveness check.

      2. Specify the commands to use in the container.

      3. Specify the number of seconds before performing the first probe after the container starts.

    2. 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
      Note

      The 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 the timeout 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
      1. Timeout value and path to the probe script.

    3. Create the check:

      $ oc create -f <file-name>.yaml
  2. Create a Liveness TCP Socket Check:

    1. 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)
      1. Specify the container name and port for the check to connect to.

      2. Specify the Liveness heath check and the type of Liveness check.

      3. Specify the number of seconds before performing the first probe after the container starts.

      4. Specify the number of seconds between probes.

    2. Create the check:

      $ oc create -f <file-name>.yaml
  3. Create an Readiness HTTP Check:

    1. 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)
      1. Specify the image to use for the liveness probe.

      2. Specify the Readiness heath check and the type of Readiness check.

      3. Specify a host IP address. When host is not defined, the PodIP is used.

      4. Specify HTTP or HTTPS. When scheme is not defined, the HTTP scheme is used.

      5. Specify the number of seconds before performing the first probe after the container starts.

      6. Specify the number of seconds between probes.

    2. Create the check:

      $ oc create -f <file-name>.yaml