This incident type in Kubernetes signals disparities between the intended and actual numbers of replica pods, This playbook help in finding a potential misalignment with deployment specifications. It prompts a thorough investigation and corrective measures to realign deployments with defined specifications, ensuring consistency and reliability in cluster operations.
kubectl get deployments -A -o json | jq '.items[] | select(.status.availableReplicas != .spec.replicas) | {namespace: .metadata.namespace, name: .metadata.name, currentReplicas: .status.availableReplicas, desiredReplicas: .spec.replicas}'
kubectl get deployments -A -o json | jq '.items[] | select(.status.availableReplicas != .spec.replicas) | {namespace: .metadata.namespace, name: .metadata.name, currentReplicas: .status.availableReplicas, desiredReplicas: .spec.replicas}' | grep -w namespace
failed_deployments=$(kubectl get deployments -A -o json | jq -r '.items[] | select(.status.availableReplicas != .spec.replicas) | .metadata.namespace + "/" + .metadata.name') && for deployment in $failed_deployments; do namespace=$(echo "$deployment" | cut -d '/' -f1); deployment_name=$(echo "$deployment" | cut -d '/' -f2) echo "Events for deployment $deployment_name in namespace $namespace:"; kubectl get events --namespace="$namespace"; echo "------------------------"; done