How do I get a pod's name from its IP address? What's the magic incantation of kubectl
+ sed
/awk
/grep
/etc regardless of where kubectl
is invoked?
Run kubectl get deployments to check if the Deployment was created. When you inspect the Deployments in your cluster, the following fields are displayed: NAME lists the names of the Deployments in the namespace. READY displays how many replicas of the application are available to your users.
Currently when a pod is created, its hostname is the Pod's metadata.name value. With v1. 2, users can specify a Pod annotation, pod.beta.kubernetes.io/hostname , to specify what the Pod's hostname should be. The Pod annotation, if specified, takes precedence over the Pod's name, to be the hostname of the pod.
Typically, the node name is given with "--hostname-override" option when starting the kubelet. So, the following command would give the node name if --hostname-override is set.
kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE alpine-3835730047-ggn2v 1/1 Running 0 5d 10.22.19.69 ip-10-35-80-221.ec2.internal
kubectl get --all-namespaces --output json pods | jq '.items[] | select(.status.podIP=="10.22.19.69")' | jq .metadata.name "alpine-3835730047-ggn2v"
kubectl get --all-namespaces --output json pods | jq '.items[] | select(.status.podIP=="10.22.19.69")' | jq .spec.containers[].name "alpine"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With