Kubernetes Cheatsheet
Gregg
The get parameter is a powerful way of discovering your kubenetes resources. You can use it to query:
- namespace
- pod
- node
- deployment
- service
- replicasets
$ kubectl get nodes$ kubectl get ns # ns is an abreviation for namespace$ kubectl get pods -n kube-system
The create command can do just that for:
- service
- cronjob
- deployment
- job
- namespace (or ns)
$ kubectl create ns hello-world$ kubectl create cronjob my-cronjob --image=alpine --schedule="*/15 * * * *" -- echo "hi there"
You can also use cj as an abreviation for cronjob
$ kubectl create cj my-cronjob --image=alpine --schedule="*/15 * * * *" -- echo "hi there"
The edit parameter allows you to update resources:
$ kubectr edit my-cronjob
The delete parameter allows you to remove resources:
$ kubectl delete cronjob my-cronjob
The apply parameter allows you to apply configurations from files
$ kubectl apply -f jenkins.yaml
The describe parameter provides details of your resources which could be:
- nodes
- pods
- services
- deployments
- replicasets
- cronjobs
$ kubectl describe cronjob my-cronjob
The logs parameter displays the contents of the resource’s log:
$ kubectl logs my-resource -n charts
The exec parameter allows you to exec into a container:
$ kubectl exec -it my-resource -n charts -- /bin/bash
The cp parameter lets you copy files and directories to and from containers:
$ kubectl cp file1.txt my-resource:file1.txt