-
-
Save mindw/23626ca423cc3a261a573efd3e177c57 to your computer and use it in GitHub Desktop.
kubectl Cookbook
This file contains hidden or 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 only with enabled service links. | |
| kgpoall -o jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{.spec.enableServiceLinks}' | grep true | |
| # list images used in containers (but not in initContainers!). | |
| kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.namespace}{"/"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.name}{"="}{.image}{", "}{end}{end}' |sort | |
| # list containers without memory limits | |
| kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.resources.limits.memory}{", "}{end}{end}' |sort | grep 0, | |
| # running a pod which immidiately exists - the restart policy is crticial | |
| kubectl run -ti jaeger-test --rm --restart=Never \ | |
| --env="SPAN_STORAGE_TYPE=elasticsearch" --image jaegertracing/jaeger-query:1.31.0 -- --help | |
| # running with a different command - notice the a leading slash in the argument will be MSYSed! | |
| kubectl run -ti kruise-test --rm --restart=Never --image openkruise/kruise-manager:v1.0.1 --command -- \ | |
| ./kruise-daemon --help | |
| # using kubernetes api proxy to access https endpoints (in this case it fails as there is no way to pass a client certificate) | |
| MSYS2_ARG_CONV_EXCL=--raw k get --raw='/api/v1/nodes/https:ip-10-0-10-114.eu-west-1.compute.internal:2379/proxy/metrics' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment