Get a Kubernetes Pod IP Address

A pod is a group of containers that are running on the same host and share the same filesystem. Containers in a pod share network and IPC namespace. Pods can be created and managed by Kubernetes and deployed together on the same host or different hosts.

In this post, we will show you how to get the IP address of a Kubernetes pod in a simple and clean format without scrolling over an output.

Deploy a Pod and Get IP

Let’s go ahead and deploy a pod using the following command.

kubectl run nginx --image=nginx 

Now that the pod has been deployed, let’s get its IP address. To format the output into a clean and simple output, I’m using JSONPath Query language.

kubectl get pod nginx --output,POD_IP:status.podIP 

The output is shown below.


Don’t forget to view the last article on the topic Deploy a Pod in Kubernetes with only One Command