Skip to content

Instantly share code, notes, and snippets.

@rileypriddle
Forked from prudhvigodithi/.txt
Last active March 21, 2019 08:56
Show Gist options
  • Save rileypriddle/6938e83c5eda51c7029d2ad7f9dbe62a to your computer and use it in GitHub Desktop.
Save rileypriddle/6938e83c5eda51c7029d2ad7f9dbe62a to your computer and use it in GitHub Desktop.
Kubectl cheat sheet.
gcloud compute project-info add-metadata \
--metadata google-compute-default-region=australia-southeast1,google-compute-default-zone=australia-southeast1a
kubectl run nginx image=nginx --port=80 --record
kubectl set image deployment nginx nginx=nginx:1.2
kubectl rollout history deployment nginx
kubectl rollout status deployment nginx
kubectl rollout undo deployment nginx --to-revision=2
kubectl autoscale deployment nginx --cpu-percent=50 --min=1 --max 2
kubectl run nginx3 --image=nginx --requests=cpu=200m --limits=cpu=300m --requests=memory=1Gi --limits=memory=2Gi
kubectl run hello --schedule="*/1 * * * *" --restart=OnFailure --image=busybox --/bin/sh -c "date; echo Hello from the kubernetes cluster"
kubectl port-forward redis-master-765d459796–258hz 6379:6379
kubectl get pods redis-master-765d459796–258hz -o yaml
kubectl create secret docker-registry --dry-run=true registryhttps --docker-server=https://example.com:5000 --docker-username=username --docker-password=password--docker-email=docker@docker.com -o yaml
kubectl create secret generic db-user-pass --from-file=./username.txt --from-file=./password.txt (echo -n ‘username’ > ./username.txt, echo -n ‘password’ > ./pass)
kubectl get secrets -o yaml
kubectl create secret generic db-pass --from-literal=username=<username> --from-lieral=password=<somebase64password>
kubectl top node NODE_NAME
kubectl top pod --namespace=<namespace>
kubectl top pod POD_NAME --containers
kubectl top pod -l name=myLabel
Kubectl rollout resume deploy/nginx
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep username | awk ‘{print $1}’)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment