🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to get port of a pod in Kubernetes?

To get the port of a pod in Kubernetes, you can use the kubectl command along with the get and describe options.

Here are the steps:

1. List all the pods in the cluster to find the specific pod you’re interested in:

kubectl get pods
Code language: JavaScript (javascript)

2. Identify the name of the pod from the list of pods.

3. Retrieve detailed information about the pod, including the container ports:

kubectl describe pod <pod-name>Code language: HTML, XML (xml)

4. Look for the “Containers” section in the output. Under each container, you will find the “Ports” field, which lists the container ports.

Alternatively, you can use the kubectl get command with the -o or --output flag to format the output and display only the port information for the pod:

kubectl get pod <pod-name> -o jsonpath='{.spec.containers[*].ports[*].containerPort}'Code language: JavaScript (javascript)

This command uses jsonpath to extract the container port(s) from the pod’s specification.

Replace <pod-name> with the name of the pod you want to get the port for.

By following these steps, you can retrieve the port(s) associated with a specific pod in Kubernetes.

Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x