Pods IP address from inside a container in the pod

0 votes

I'm trying to run Aerospike cluster in kubernetes and the config files need its own IP address. How do I get pods IP address from inside a container in the pod.

Aug 29, 2018 in Kubernetes by lina
• 8,220 points
2,136 views

1 answer to this question.

0 votes

Make sure that your pod yaml file has an environment variable that sets the ip address. You can do this by adding the config blog defined bellow:

 env:
    - name: MY_POD_NAME
      valueFrom:
        fieldRef:
          fieldPath: metadata.name
    - name: MY_POD_NAMESPACE
      valueFrom:
        fieldRef:
          fieldPath: metadata.namespace
    - name: MY_POD_IP
      valueFrom:
        fieldRef:
          fieldPath: status.podIP

Recreate the pod/rc and then try

echo $MY_POD_IP
answered Aug 29, 2018 by Kalgi
• 52,360 points

Related Questions In Kubernetes

0 votes
1 answer

how can i access two containers that are inside a pod from the browser with IP address?

Just do port forward. kubectl port-forward [nginx-pod-name] 80:80 kubectl ...READ MORE

answered Jul 18, 2019 in Kubernetes by Sirajul
• 59,230 points
1,635 views
0 votes
1 answer

Getting the pod's ip address for the container inside of it

You can make sure that the replication ...READ MORE

answered Aug 24, 2018 in Kubernetes by DareDev
• 6,890 points
2,397 views
0 votes
1 answer
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
14,630 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,121 views
0 votes
2 answers

Access Kubernetes api from within a pod container

wget version: KUBE_TOKEN=$(</var/run/secrets/kubernetes.io/serviceaccount/token) wget -vO- ...READ MORE

answered Aug 29, 2018 in Kubernetes by Nilesh
• 7,050 points
2,413 views
0 votes
1 answer

Not able to access kubernetes api from a pod in azure

Follow these steps Add --bind-address=0.0.0.0 option to the line https://github.com/kubernetes/kubernetes/blob/v1.2.0/docs/getting-started-guides/coreos/azure/cloud_config_templates/kubernetes-cluster-main-nodes-template.yml#L218  Created ...READ MORE

answered Aug 30, 2018 in Kubernetes by Kalgi
• 52,360 points
818 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP