Main Menu

Search

Showing posts with label kubernetes pods. Show all posts
Showing posts with label kubernetes pods. Show all posts

KUBERNETES: Kubectl Command To List All Pods And Nodes On Which They are Running

Below Kubectl command can be used to list all pods and nodes on which they are running.

kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name --all-namespaces

Below is sample output.

NODE       NAME
worker2    grafana-78ccdc896d-rsntv
worker2    istio-egressgateway-688d8db5f6-4k57n
worker3    istio-egressgateway-688d8db5f6-lmk42
worker2    istio-ingressgateway-97bd4fb86-2l4xx
worker1    istio-ingressgateway-97bd4fb86-ljjfr
worker3    istiod-6945f949c8-m9tsx
worker1    istiod-6945f949c8-x9mnm
worker3    prometheus-server-85577f7c59-nxlv9


Key words:

commands run running placed pod node how to docs identify identifying

KUBERNETES: Kubectl Command To Do Rollout Restart of Flannel Pods

Kubectl Command To Do Rollout Restart of Flannel Pods

kubectl rollout restart ds kube-flannel-ds -n kube-system


Keywords:


flannel pod pods podnetwork network networks networking


KUBERNETES: How to Start / Run Temporary Pod For Testing In Kubernetes

You can start a pod temporarily for testing by using kubectl command as follows:

kubectl run <name> --image=<image> --restart=Never

With above command a temporay pod with specified name and image will be deployed. The pod will not start once you delete the pod since restart is specified as "Never"

For e.g. to start nginx pod using nginx image in Oracle container registry, your command will look as follows:

kubectl run nginx --image=container-registry.oracle.com/olcne/nginx:1.17.7 --restart=Never


Keywords:

temporarily starting running pod pods test testing without deployment deployments yaml file files pull pulliing

KUBERNETES: KUBECTL Command To List Pods And Their Associated Container Listening Ports

Below command can be used.

kubectl get pods -A -o custom-columns="POD:.metadata.name,PORTS:.spec.containers[*].ports[*].containerPort"

Below is sample output of above command.

POD                                           PORTS
nginx-6f4cfc8479-22zlh                        80
nginx-6f4cfc8479-2trg9                        80
nginx-6f4cfc8479-7sfpj                        80
nginx-6f4cfc8479-mkfng                        80
nginx-6f4cfc8479-nffq6                        80
nginx-6f4cfc8479-vcmx8                        80
coredns-5859f68d4-7p95k                       53,53,9153
coredns-5859f68d4-f7hnb                       53,53,9153

KUBERNETES: KUBECTL Command To List The Pods and Their CPU & Memory Resource Limits

Below command can be used. Below command will list all the pods in all the namespaces.

kubectl get pods -A -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[].resources.limits.cpu}{"\t"}{.spec.containers[].resources.limits.memory}{"\n"}{end}'

For listing the pods and their limits in specific namespace below command can be used.

kubectl get pods -n <namespace> -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[].resources.limits.cpu}{"\t"}{.spec.containers[].resources.limits.memory}{"\n"}{end}'

Below is sample output of above command. In below output memory is listed as 50Mi which is 50MB and CPU is 100m which is means 1/10th of CPU which is 0.1 CPU.

kube-flannel-ds-4w6lq 100m 50Mi
kube-flannel-ds-69xn6 100m 50Mi
kube-flannel-ds-d7drw 100m 50Mi
kube-flannel-ds-f87dw 100m 50Mi
kube-flannel-ds-rwcjl 100m 50Mi
kube-flannel-ds-xlnh7 100m 50Mi