Cheatography
https://cheatography.com
Kubernetes Commands and Tips and Tricks
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Pod Commands
kubectl get nodes |
Get list of all nodes |
kubectl get pods --all-namespaces |
Get list of all pods in all namespaces |
kubectl apply -f calico.yaml |
Apply a Calico Container Networking Configuration |
kubectl init --apiserver-advertise-addres<pvt_ip_addr> --pod-network-cidr=192.168.0.0/16 |
Initialise current node as Manager with Calico Container N/w soln |
kubectl get pods --all-namespaces -o wide |
List pods and their nodes (ip addrs) |
Service Commands
Create Service |
kubectl create service nodeport nginx --tcp=80:80 |
List services |
kubectl get svc |
Nodeport is the type of service endpoint being created. It allows an external client to access the service (One out of 3 types).
Administration Commands
kubectl get all |
Get all resources in a namespace |
kubectl get all -A |
Get all resources in ALL Namespaces |
kubectl config view |
Show Kubectl context. |
Deployment Commands
kubectl get deployments |
Get deployments |
Kubectl Commands
kubectl config |
Context and Configuration. view, get-contexts, current-context, use-context, set-cluster, set-credentials, set-context, use-context, unset |
kubectl apply |
Create and Update Resources. -f ./my1.yaml -f ./my2.yaml |
kubectl create |
Create a single instance. deployment nginx --image=nginx cronjob job |
kubectl explain |
Get documentation, Schema Definition Pod Pod.spec.containers |
kubectl get |
Viewing & Finding Resources services pods --all-namespaces pods -o wide deployment my-dep pod my-pod-o yaml |
kubectl describe |
Obtain real-time info abt resources nodes my-node pods my-pod |
kubectl set |
kubectl rollout |
kubectl replace |
kubectl expose |
kubectl label |
kubectl annotate |
kubectl patch |
kubectl edit |
kubectl scale |
kubectl delete |
kubectl logs |
kubectl run |
kubectl attach |
kubectl port-forward |
kubectl exec |
kubectl debug |
kubectl top |
kubectl cp |
kubectl cordon |
kubectl drain |
kubectl uncordon |
kubectl cluster-info |
kubectl taint |
Google Cloud
Create a K8s Cluster |
gcloud container clusters create [CLUSTER-NAME] |
Authenticate Cluster to interact with it i.e Update kubeconfig |
gcloud container clusters get-credentials [CLUSTER-NAME] |
Create a deployment on created cluster |
kubectl create deployment [DEPL_NAME] --image=gcr.io/[PATH]/[IMG_NAME]:[TAG] |
Expose created deployment to external network i.e Create Service |
kubectl expose deployment [DEPL_NAME] --type=LoadBalancer --port [PORT] |
Inspect created Service |
kubectl get service |
Delete Cluster |
gcloud container clusters delete [CLUSTER-NAME] |
|