Skip to content

Instantly share code, notes, and snippets.

@leitu
Created February 4, 2019 03:08
Show Gist options
  • Save leitu/b8429ebc2fde771e87377afc0f377341 to your computer and use it in GitHub Desktop.
Save leitu/b8429ebc2fde771e87377afc0f377341 to your computer and use it in GitHub Desktop.
k8s tricks
# List pods which has CONSUL_HOST
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].env[?(@.name=="CONSUL_HOST")].value}{"\n"}{end}' | awk ' NF==2 {print $0} '
# List deployment which has CONSUL_HOST
kubectl get deployment -o jsonpath="{range .items[*]}{.metadata.name}{'\t'}{.spec.template.spec.containers[*].env[*].name}{'\n'}{end}" | grep "CONSUL_HOST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment