Latest
Kubernetes 1 min read

Configure Kubernetes Health Checks and Safe Shutdown

Configure Kubernetes Health Checks and Safe Shutdown
Kubernetes · November 28, 2026

Version note: examples use the Kubernetes v1.35 documentation snapshot, not necessarily the newest release. Check current support and component compatibility. These commands were not tested on a live cluster.

What this guide covers

A readiness probe controls whether a Pod receives Service traffic. A liveness probe can restart an unhealthy container. A startup probe gives slow-starting applications time to initialize. A disruption budget limits some voluntary Pod removals.

Before you start

Create availability-lab in a test cluster. The manifest uses Nginx and an illustrative shutdown delay. Real applications must handle their own stop signal and finish requests within the termination time.

Step 1: Create the Deployment and budget

Save this as availability.yaml and apply it:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
  namespace: availability-lab
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      terminationGracePeriodSeconds: 45
      containers:
        - name: api
          image: registry.example.com/team/api:approved
          ports:
            - name: http
              containerPort: 8080
          startupProbe:
            httpGet:
              path: /startup
              port: http
            periodSeconds: 2
            failureThreshold: 30
          readinessProbe:
            httpGet:
              path: /ready
              port: http
            periodSeconds: 5
            failureThreshold: 2
          livenessProbe:
            httpGet:
              path: /live
              port: http
            periodSeconds: 10
            failureThreshold: 3
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              memory: 256Mi
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: api
  namespace: availability-lab
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app: api

Run kubectl apply -f availability.yaml. Readiness and liveness serve different purposes; a temporary downstream failure should not automatically trigger endless container restarts.

Step 2: Check capacity before draining

Inspect the workload:

kubectl -n availability-lab get pdb api
kubectl -n availability-lab get pods -o wide
kubectl -n availability-lab describe deployment api
kubectl drain worker1 --ignore-daemonsets --timeout=120s

The last command drains worker1 and may block. Run it only during a planned test with data protected and somewhere else for Pods to run. One worker cannot provide continuous application service while it is drained.

Step 3: Check application shutdown

Observe readiness, request failures and termination logs during a controlled replacement. The application must handle SIGTERM. A sleep in a hook alone does not complete active work. Restore scheduling with kubectl uncordon worker1 after maintenance.

Check the result

Check both successful responses and shutdown behavior. A PodDisruptionBudget does not prevent node crashes, every rollout interruption or downtime caused by insufficient capacity.

References

PB
Written by

Parul Bedi

Notes and guides by Parul Bedi.

Up next

Install SonarQube on Ubuntu Step by Step

Sonar November 30, 2026 4 min read
Open post

Conversation

0 comments

No comments yet. Start the conversation below.

Leave a comment

Replying to a comment.
Be kind. Markdown is not supported in comments.