Last active
February 5, 2019 03:15
-
-
Save leitu/5c590e5cef2815ff0911c63760fff8f7 to your computer and use it in GitHub Desktop.
k8s tricks
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
# 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" | |
# Patch deployment env | |
kubectl patch deployment xyz-deployment -p '{"spec":{"template":{"spec":{"containers":[{"name":"xyz", "env":[{"name":"HTTP_PROXY", "value":"xyz-proxy.exampe.com"}]}]}}}}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment