This document contains various kubectl commands for interacting with and managing Kubernetes clusters, nodes, pods, services, replication controllers, and other Kubernetes objects. It includes commands for listing, describing, executing, scaling, mapping ports, draining nodes, creating namespaces, and more. The commands are presented with brief descriptions of their functionality.
This document contains various kubectl commands for interacting with and managing Kubernetes clusters, nodes, pods, services, replication controllers, and other Kubernetes objects. It includes commands for listing, describing, executing, scaling, mapping ports, draining nodes, creating namespaces, and more. The commands are presented with brief descriptions of their functionality.
clusterrolebindings selecting container <$container> # List the current pods clusterroles kubectl exec <service> <command> [-c <$container>] kubectl get pods cm = configmaps # Get logs from service <name> optionally # selecting # Describe pod <name> controllerrevisions container <$container> kubectl describe pod <name> crd = customresourcedefinition kubectl logs -f <name> [-c <$container>] # List the replication controllers cronjobs # Watch the Kubelet logs kubectl get rc cs = componentstatuses watch -n 2 cat /var/log/kublet.log # List the replication controllers in <namespace> csr = certificatesigningrequests # Show metrics for nodes kubectl get rc --namespace="<namespace>" deploy = deployments kubectl top node ds = daemonsets # Describe replication controller <name> # Show metrics for pods kubectl describe rc <name> ep = endpoints kubectl top pod ev = events # List the services kubectl get svc hpa = horizontalpodautoscalers # Describe service <name> ing = ingresses kubectl describe svc <name> jobs # Delete pod <name> limits = limitranges kubectl delete pod <name> # Launch a pod called <name> netpol = networkpolicies # Watch nodes continuously # using image <image-name> no = nodes kubectl get nodes –w kubectl run <name> --image=<image-name> ns = namespaces # Create a service described # in <manifest.yaml> pdb = poddisruptionbudgets kubectl create -f <manifest.yaml> po = pods # Scale replication controller podpreset # <name> to <count> instances podtemplates kubectl scale --replicas=<count> rc <name> psp = podsecuritypolicies # Get version information # Map port <external> to # port <internal> on replication pv = persistentvolumes kubectl version # controller <name> pvc = persistentvolumeclaims # Get cluster information kubectl expose rc <name> --port=<external> --target- quota = resourcequotas kubectl cluster-info port=<internal> rc = replicationcontrollers # Get the configuration # Stop all pods on <n> rolebindings kubectl config view kubectl drain <n> --delete-local-data --force --ignore- roles # Output information about a node daemonsets rs = replicasets kubectl describe node <node> # Create namespace <name> sa = serviceaccounts kubectl create namespace <namespace> sc = storageclasses # Allow Kubernetes master nodes to run pods secrets kubectl taint nodes --all node-role.kubernetes.io/master- sts = statefulsets