Skip to content

Instantly share code, notes, and snippets.

@emeraldsanto
Created January 12, 2023 21:59
Show Gist options
  • Save emeraldsanto/71a933b7f96e12f3d137cf48bfb452f2 to your computer and use it in GitHub Desktop.
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.
#!/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