Pre-deploy checklist
pre-deploy-check.sh
#!/usr/bin/env bash
# pre-deploy-check.sh — run before prod deploy
set -euo pipefail
NS="${1:-apps}"
DEPLOY="${2:-myapp}"
echo "==> Context: $(kubectl config current-context)"
kubectl cluster-info | head -3
echo "==> Nodes ready"
kubectl get nodes | grep -v NotReady || true
echo "==> Current rollout"
kubectl rollout status "deploy/${DEPLOY}" -n "${NS}" --timeout=30s || true
echo "==> Pending pods in namespace"
kubectl get pods -n "${NS}" | grep -vE 'Running|Completed' || echo "All pods OK"
echo "==> Last deployment revision"
kubectl rollout history "deploy/${DEPLOY}" -n "${NS}" | tail -5
echo "==> Dry-run apply (if manifest dir exists)"
if [[ -d k8s ]]; then
kubectl apply -f k8s/ --dry-run=server -n "${NS}" 2>/dev/null || kubectl apply -f k8s/ --dry-run=client
fi
echo "Pre-deploy checks complete. Proceed with deploy if green."