Kubernetes kubectl commands part-1

Kubernetes kubectl commands part

Kubernetes Cheat Sheet

what is Kubernetes ?

Play with Kubernetes Classroom is a workshop environment similar to the Play with Docker Classroom. We currently have an extensive Kubernetes Workshop based on Jerome Petazzoni’s Container Training Kubernetes Workshop. But instead of doing all this locally or setting up VMs in the cloud, you can now run the workshop entirely in the browser.

Viewing Resource Information

Nodes

$ kubectl get no
$ kubectl get no •o wide
$ kubectl describe no
$ kubectl get no -o yaml
$ kubectl get node --selector=[label_name] kubectl get nodes -o
$ kubectl get nodes -o
$ kubectl top node [node_name

Pods

$ kubectl get po
$ kubectl get po -o wide
$ kubectl describe
$ kubectl get po --show-labels
$ kubectl get po -l app=nginx
$ kubectl get po -o yaml
$ kubectl get pod [pod-name] -o yaml-- export >nameoffile.yaml
$ kubectl get pods --field-selector
status,phase=running

namespaces

$ kubectl get ns
$ kubectl get ns -o yaml
$ kubectl describe ns

Deployments

$ kubectl get deploy
$ kubectl describe deploy
$ kubectl get drploy -o wide
$$ kubectl get drploy -o yaml

Services

$ kubectl get svc
$ kubectl describe svc
$ kubectl get svc -o wide
$ kubectl get svc -o yaml
$ kubectl get svc -- show-labels

DaemonSets

$ kubectl get ds
$ kubectl get ds --all-namespaces
$ kubectl describe ds [daemoset_name] -n[namespace-name]
$ kubectl get ds [ds_name] -n [ns-name] -o yaml

Events

$ kubectl get events
$ kubectl get events -n kube-system
$ kubectl get events -w

Logs

$ kubectl logs [pod-name]
$ kubectl logs --since=1h [pod -name]
$ kubectl logs --tail=20 [pod-name]
$ kubectl logs -f -c[container-name] [pod-name]
$ kubectl logs [pod-name] > pod.log

Service Accounts

$ kubectl get sa
$ kubectl get sa -o yaml
$ kubectl get serviceaccounts default -o yaml > ./sa.yaml
$ kubectl replace serviceaccounts default -f ./sa.yaml

ReplicaSets

$ kubectl get rs
$ kubectl describe rs
$ kubectl get rs -o wide
$ kubectl get rs -o yaml

Roles

$ kubectl get roles --all namespaces
$ kubectl get roles --all namespaces -o yaml

secrets

$ kubectl get secrets
$ kubectl get secrets --all-namespace
$ kubectl get secrets -o yaml

Configmaps

$ kubectl get cm
$ kubectl get cm --all-namespaces
$ kubectl get cm --all-namespaces -o yaml

Ingress

$ kubectl get ing
$ kubectl get ing --all-namespaces

PeristentVolume

$ kubectl get pv
$ kubectl get describe pv

PeristentVolumeClaim

$ kubectl get pvc
$ kubectl describe pvc

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Comments

No comments to show.