Skip to content

Instantly share code, notes, and snippets.

@zhangchiqing
Created January 31, 2019 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangchiqing/1d7a8af5ceca2eeaf2aea8f867a71e5d to your computer and use it in GitHub Desktop.
Save zhangchiqing/1d7a8af5ceca2eeaf2aea8f867a71e5d to your computer and use it in GitHub Desktop.
Kubectl cheatsheet

Source: https://carlos.mendible.com/2018/03/18/my-kubectl-cheat-sheet/

Deploy

kubectl apply -f [yaml definition file]

Get deployment definition

kubectl get deployment [deployment name] -o yaml

Update the image of a deployment

kubectl set image deployment/[deployment name] [container name]=[image tag]

Set autoscale for a deployment

kubectl autoscale deployment [deployment name] --min=2 --max=5 --cpu-percent=80

Delete a deployment

kubectl delete -f [yaml definition file]

Get secret definition

kubectl get secret [secret name] -o yaml

Force delete a pod

kubectl delete pod [pod name] --grace-period=0 --force

Read a pod’s log

kubectl logs [pod name] -n [namespace name]

Install kubernetes dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment