Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Kubectl CheatSheet

Trevor Rosen edited this page Dec 4, 2018 · 5 revisions

Kubectl

The following are examples of the kubectl commands used throughout the workshop lessons. Remember that in the case where a resource/manifest is named directly, you should substitute the real one from your machine when you run the command.

Most kubectl commands take this basic form:

kubectl VERB [RESOURCE] [FLAGS] [ARGUMENTS]

For further help with basic usage, just run kubectl with no arguments to see a listing of various available commands.

Managing Resources

Creating/updating a resource with apply

kubectl apply -f _deployments/redis/pod.yml

List a resource

kubectl get pods

Show detail for a resource

kubectl describe pod dumbstore-web-xyz

Delete a resource

kubectl delete pod dumbstore-web-xyz

Delete resources by label

kubectl delete pod,service -l app=dumbstore

Viewing Pod Logs

View recent log lines

kubectl logs POD_NAME

Tail a log

kubectl logs -f POD_NAME

Deployments

Show rollout status for a deployment

kubectl rollout status deployment dumbstore-web

Show rollout history for a deployment

kubectl rollout history deployment dumbstore-web

Set a container image on a Deployment's Pod (triggering a new rollout)

kubectl set image deployment dumbstore-web dumbstore-web=dumbstore:1.1.0 --record

Scale up a Deployment to a different number of Pods

kubectl scale deployment dumbstore-web --replicas=5

Clone this wiki locally