title: Kubernetes to find Pod IP from another Pod
body: <p>I have the following pods <code>hello-abc</code> and <code>hello-def</code>.</p>
  
  <p>And I want to send data from <code>hello-abc</code> to <code>hello-def</code>.</p>
  
  <p>How would pod <code>hello-abc</code> know the IP address of <code>hello-def</code>?</p>
  
  <p>And I want to do this programmatically.</p>
  
  <p>What's the easiest way for <code>hello-abc</code> to find where <code>hello-def</code>?</p>
  
  <pre><code>---
  apiVersion: extensions/v1beta1
  kind: Deployment
  
  metadata:
  name: hello-abc-deployment
  
  spec:
  replicas: 1
  
  template:
      metadata:
      labels:
          app: hello-abc
      spec:
      containers:
      - name: hello-abc
          image: hello-abc:v0.0.1
          imagePullPolicy: Always
          args: ["/hello-abc"]
          ports:
          - containerPort: 5000
  
  ---
  apiVersion: extensions/v1beta1
  kind: Deployment
  
  metadata:
  name: hello-def-deployment
  
  spec:
  replicas: 1
  
  template:
      metadata:
      labels:
          app: hello-def
      spec:
      containers:
      - name: hello-def
          image: hello-def:v0.0.1
          imagePullPolicy: Always
          args: ["/hello-def"]
          ports:
          - containerPort: 5001
  
  ---
  apiVersion: v1
  kind: Service
  
  metadata:
  name: hello-abc-service
  
  spec:
  ports:
  - port: 80
      targetPort: 5000
      protocol: TCP
  
  selector:
      app: hello-abc
  type: NodePort
  
  ---
  apiVersion: v1
  kind: Service
  
  metadata:
  name: hello-def-service
  
  spec:
  ports:
  - port: 80
      targetPort: 5001
      protocol: TCP
  
  selector:
      app: hello-def
  type: NodePort
  </code></pre>