Created
January 12, 2023 21:59
-
-
Save emeraldsanto/71a933b7f96e12f3d137cf48bfb452f2 to your computer and use it in GitHub Desktop.
This script loops over your `kubectl` contexts and logs the ones where the given service is deployed.
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 | |
service_to_find=$1 | |
context_list_as_string=$(kubectl config get-contexts -o name) | |
context_list=($context_list_as_string) | |
for ctx in ${context_list[@]}; do | |
if kubectl get deploy --context=$ctx | grep -q "$service_to_find"; then | |
echo "Found $service_to_find deployment in $ctx" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment