Pages

Monday, May 21, 2018

Kubernetes - kubectl Check Sheet

Kubernetes Cheat Sheet


kubectl label nodes work-node1 label=node1 : Label a Node "work-node1" with "node1"

kubectl exec testing-service -c test-ser -it -- bash : Connect to the container test-ser in the pod testing-service

kubectl exec testing-service -c test-ser free : Run a command in the container "test-ser" in pod "testing-service"


kubectl create secret docker-registry docker-secret --docker-server https://index.docker.io/v1/ --docker-email jagadesh.manchala@gmail.com --docker-username=<User Name> --docker-password <password> : Create a docker secret for pulling images from docker

kubectl get componentstatus : Get the kubernetes component status

Get all images pulled and being used: kubectl get pods --all-namespaces -o jsonpath="{..image}" |\
> tr -s '[[:space:]]' '\n' |\
> sort |\
> uniq -c

     1 docker.io/rajpr01/myapp
     1 docker.io/rajpr01/myapp:latest
     3 docker.io/weaveworks/weave-kube:2.3.0
     3 docker.io/weaveworks/weave-npc:2.3.0
     2 k8s.gcr.io/etcd-amd64:3.1.12
     2 k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.8
     2 k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.8
     2 k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.8
     2 k8s.gcr.io/kube-apiserver-amd64:v1.10.2
     2 k8s.gcr.io/kube-controller-manager-amd64:v1.10.2
     6 k8s.gcr.io/kube-proxy-amd64:v1.10.2
     2 k8s.gcr.io/kube-scheduler-amd64:v1.10.2
     3 weaveworks/weave-kube:2.3.0
     3 weaveworks/weave-npc:2.3.0

List Containers by Pod : kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |sort



No comments :

Post a Comment