Skip to content

Instantly share code, notes, and snippets.

@jmhublar
Created June 22, 2023 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmhublar/1de38ead042486d88be50881f9b0f392 to your computer and use it in GitHub Desktop.
Save jmhublar/1de38ead042486d88be50881f9b0f392 to your computer and use it in GitHub Desktop.
Audit liveness and readiness probe endpoints
#!/bin/bash
all_probe_paths=()
for ns in $(kubectl get namespaces -o jsonpath='{.items[*].metadata.name}'); do
readiness_probes=$(kubectl -n $ns get deployments -o jsonpath='{range .items[*]}{.spec.template.spec.containers[0].readinessProbe.httpGet.path}{","}{end}')
liveness_probes=$(kubectl -n $ns get deployments -o jsonpath='{range .items[*]}{.spec.template.spec.containers[0].livenessProbe.httpGet.path}{","}{end}')
if [ ! -z "$readiness_probes" ]; then
all_probe_paths+=${readiness_probes}
fi
if [ ! -z "$liveness_probes" ]; then
all_probe_paths+=${liveness_probes}
fi
done
IFS=',' read -ra unique_probe_paths <<< "$(echo "${all_probe_paths[@]}" | tr ',' '\n' | sort -u | paste -sd, -)"
printf '%s\n' "${unique_probe_paths[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment