41
Kubernetes Cheatsheet
Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available. Kubernetes provides you with a framework to run distributed systems resiliently. It takes care of scaling and failover for your application, provides deployment patterns, canary deployments, and more. In this blog post, I will mention Kubernetes commands which we need for most of the use-cases.
I will list down
kubectl
commands in the sections below as a quick reference to work with Kubernetes.kubectl get namespaces
kubectl get pods
kubectl get pods -o wide
kubectl get pods --field-selector=spec.nodeName=[server-name]
kubectl get replicationcontroller,services
kubectl get daemonset
kubectl create namespace [namespace-name]
kubectl create βf [filename]
To apply or update a resource use the
kubectl apply
command.kubectl apply -f [service-config].yaml
kubectl apply -f [controller-config].yaml
kubectl apply -f [yaml-file/directory-name]
kubectl edit svc/[service-name]
Above command opens the file in your default editor. To choose another editor, specify it in front of the command:
KUBE_EDITOR=β[editor-name]β kubectl edit svc/[service-name]
kubectl describe nodes [node-name]
kubectl describe pods [pod-name]
pod.json
kubectl describe βf pod.json
kubectl describe pods [replication-controller-name]
kubectl describe pods
kubectl delete -f pod.yaml
kubectl delete pods,services -l [label-key]=[label-value]
kubectl delete pods --all
kubectl exec [pod-name] -- [command]
kubectl exec [pod-name] -c [container-name] -- [command]
kubectl exec -ti [pod-name] -- /bin/bash
kubectl logs [pod-name]
kubectl logs -f [pod-name]
kubectl logs --tail=200 [pod-name]
kubectl config
command lets you view and modify kubeconfig files.kubectl config current-context
kubectl config set-cluster [cluster-name] --server=[server-name]
kubectl config unset [property-name]
Hope you find these resources useful. If you like what you read and want to see more about system design, microservices, and other technology-related stuff... You can follow me on
41