Kubernetes Cheatsheet
#
CREATINGcreate resource(s)
create from multiple file
create resource(s) in all manifest files in dir
start a single instance of nginx
create a Job which prints "Hello World"
create a CronJob that prints "Hello World" every minute
#
VIEWINGList all services in the namespace
List all pods in all namespaces
List all pods in the current namespace, with more details
Describe commands with verbose output
List Services Sorted by Name
List pods Sorted by Restart Count
List PersistentVolumes sorted by capacity
Get the version label of all pods with label app=cassandra
Compares the current state of the cluster against the state that the cluster would be in if the manifest was applied
#
INTERACTING WITH RUNNING PODSstream pod logs (stdout)
stream pod container logs (stdout, multi-container case) ku
stream all pods logs with label name=myLabel (stdout)
dump pod logs, with label name=myLabel (stdout)
dump pod logs (stdout) for a previous instantiation of a container
Attach to Running Container
Listen on port 5000 on the local machine and forward to port 6000 on my-pod
Run command in existing pod (1 container case)
Interactive shell access to a running pod (1 container case)
Run command in existing pod (multi-container case)
Interactive shell access to a running pod (1 container case)
Run command in existing pod (multi-container case)
Show metrics for a given pod and its containers
#
UPDATINGRolling update "www" containers of "frontend" deployment, updating the image
Check the history of deployments including the revision
Rollback to the previous deployment
Rollback to a specific revision
Replace a pod based on the JSON passed into std
Add a Label
Add an annotation
Auto scale a deployment "foo"
#
COPY FILES AND DIRECTORIES TO AND FROM CONTAINERSCopy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the current namespace
Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container
Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace my
Copy /tmp/foo from a remote pod to /tmp/bar locally
#
SCALING RESOURCESScale a replicaset named 'foo' to 3
Scale a resource specified in "foo.yaml" to 3
If the deployment named mysql's current size is 2, scale mysql to 3
Scale multiple replication controllers
#
PATCHING RESOURCESPartially update a node
Update a container's image; spec.containers[*] .name is required because it's a merge key
Update a container's image using a json patch with positional arrays
Disable a deployment livenessProbe using a json patch with positional arrays
Add a new element to a positional array
#
DELETING RESOURCESDelete a pod using the type and name specified in pod.json
Delete a pod with no grace period
Delete pods and services with same names "baz" and "foo"
Delete pods and services with label name=myLabel
Delete all pods and services in namespace my-ns,
Delete all pods matching the awk pattern1 or pattern2