Kubectl Cheat Sheet
by Sam15 via cheatography.com/127983/cs/24960/
Viewing and Finding Creating Objects Interacting with Running Pods Formatting Output
Resources
Create kubectl apply -f Dump pod logs kubectl logs Print a table using a -o=cus‐
List all kubectl get resource(s) ./my-manifes‐ (stdout) my-pod comma separated list tom-co‐
namespaces namespaces t.yaml Dump pod logs, kubectl logs of custom columns lumns=‐
in the cluster Create kubectl apply -f with label -l name=m‐ <spec>
List all kubectl get resource(s) in ./dir name=myLabel yLabel Print a table using the -o=cus‐
services in services all manifest (stdout) custom columns tom-co‐
the files in dir Dump pod logs kubectl logs template in the <filen‐ lumns-‐
namespace Create kubectl apply -f (stdout) for a my-pod -- ame> file file=<fil‐
List all pods kubectl get resource(s) https://git.io/‐ previous instan‐ previous ename>
in all pods --all-nam‐ from URL vPieo tiation of a Print only the -
namespaces espaces Start a single kubectl create container resource name and o=name
List all pods kubectl get instance of deployment Dump pod kubectl logs nothing else
in the pods -o wide nginx nginx --imag‐ container logs my-pod -c Print the fields -o=jso‐
namespace, e=nginx (stdout, multi-‐ my-con‐ defined in a jsonpath npath=‐
with more Get the kubectl explain container case) tainer expression <templ‐
details docume‐ pods Stream pod logs kubectl logs ate>
List a kubectl get ntation for (stdout) -f my-pod Print the fields -o=jso‐
particular deployment my- pod manifests Stream pod kubectl logs defined by the npath-‐
deployment dep container logs -f my-pod -c jsonpath expression file=<fil‐
List all pods kubectl get Modifying and Deleting (stdout, multi-‐ my-con‐ in the <filename> file ename>
in the pods Resources container case) tainer Output a YAML -o=yaml
namespace Add a kubectl label pods Run command in kubectl exec formatted API object
Get a pod's kubectl get pod label my-pod new-label‐ existing pod (1 my-pod -- ls Output in the plain- -o=wide
YAML my-pod -o yaml =awesome container case) / text format with any
List Services kubectl get Add an kubectl annotate Show metrics for kubectl top additional inform‐
Sorted by services --sort- annotation pods my-pod icon- a given pod and pod ation, and for pods,
Name by=.metadat‐ url=http://goo.gl/X‐ its containers POD_NAME the node name is
a.name XBTWq --containers included
Get all kubectl get
running pods pods --field-s‐
in the elector=stat‐
namespace us.phase=‐
Running
By Sam15 Published 26th October, 2020. Sponsored by CrosswordCheats.com
cheatography.com/sam15/ Last updated 26th October, 2020. Learn to solve cryptic crosswords!
Page 1 of 1. http://crosswordcheats.com