Skip to main content

More Info:

Advisory: long-running containers should define livenessProbe and readinessProbe so Kubernetes can restart hung pods and keep traffic off pods that are not ready.

Risk Level

Informational

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. On any machine with kubectl access, list non-compliant pods and note their namespaces, names, and owning controllers (Deployment/StatefulSet/Job/etc.):
  2. For pods managed by a controller (recommended), edit the controller manifest and add probes. Example for a Deployment my-app in namespace prod:
    In the spec.template.spec.containers[] entry for each long-running container, add both probes, adapting paths/ports and thresholds to the app:
    Save and exit; the Deployment will roll out new pods automatically.
  3. For pods defined directly by a Pod manifest (no controller), edit the manifest and re-apply it. First, export the manifest:
    Edit /tmp/my-pod.yaml, add appropriate livenessProbe and readinessProbe under the container, then delete and recreate the pod from the file:
  4. If your GKE workloads are managed by GitOps or another IaC system, locate the corresponding manifest in the repository and add the same livenessProbe and readinessProbe fields under each long-running container, then commit and let your pipeline apply the changes instead of using kubectl edit.
  5. After the updated workloads have rolled out and pods are running, verify compliance from any machine with kubectl access:
    The output should be is_compliant=true.
On any machine with kubectl access:
  1. Identify a non-compliant pod and export its owning workload
Use the audit output’s owner= field (e.g., Deployment/default/web-app/...). Then export the current manifest for that owner resource:
(For other controllers, substitute deployment with statefulset, daemonset, etc.)
  1. Edit the manifest to add probes
Open the file and, for each long-running container, add both livenessProbe and readinessProbe under spec.template.spec.containers[]. Example HTTP-based probes:
Adjust paths, ports, and timings to match the application’s health endpoints and startup characteristics.
  1. Apply the updated manifest
This will roll out new pods with the probes defined.
  1. For bare Pods (no controller)
If the audit output shows owner= is empty (a standalone Pod), fetch, modify, and re-create it (Pods cannot be updated in-place for some fields; recreate is safer):
Edit standalone-app-pod.yaml to add livenessProbe and readinessProbe under spec.containers[] as above, then delete and recreate:
  1. Verification
Run the same style of audit to confirm the probes are now present: