Created
June 22, 2023 19:49
-
-
Save jmhublar/1de38ead042486d88be50881f9b0f392 to your computer and use it in GitHub Desktop.
Audit liveness and readiness probe endpoints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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