<p>I have a scenario like:</p>
<ol>
<li>Have a single deployment containing two containers and have different ports like:</li>
</ol>
<pre><code> template: {
  spec: {
   containers: [
     {
      name: container1,
      image: image1,
      command: [...],
      args: [...],
      imagePullPolicy: IfNotPresent,
      ports: [
        {
          name: port1,
          containerPort: 80,
        },
      ],
      .............
    },
    {
      name: container2,
      image: image1,
      command: [...],
      args: [...],
      imagePullPolicy: IfNotPresent,
      ports: [
        {
          name: port2,
          containerPort: 81,
        },
      ],
      ------------
    }

       ]
     }
  }
</code></pre>
<ol start="2">
<li>A service having multiple ports pointing to those containers like:</li>
</ol>
<pre><code>spec: {
      type: ClusterIP,
      ports: [
      {
      port: 7000,
      targetPort: 80,
      protocol: 'TCP',
      name: port1,
    },
    {
      port: 7001,
      targetPort: 81,
      protocol: 'TCP',
      name: port2,
    } 
   ]
}
</code></pre>
<p>The problem I am facing is I can connect to the container having port 80 using service name and port 7000 but I can't connect to the container having port 81 using service name and port 7001. Did I miss anything here?
Also, note that both containers have identical images having different <strong>command</strong> and <strong>args</strong> for the internal logic.</p>

Yashasvi Raj Pant
<p>You can use two services or one service with two exposed ports
you can try 2 services :
with the deployment like this :</p>
<pre><code>spec:
      containers:
        - name: container1
          image:image1
          ports:
            - containerPort: 8080
        - name: container2
          image: image1 
          ports:
            - containerPort: 8081
</code></pre>
<p>and the services :</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: container1
  annotations:
    version: v1.0
spec:
  selector:
    component: &lt;deployment&gt;
  ports:
     - name: container1
       port: 8080
       targetPort: 8080
  type: ClusterIP           
---
kind: Service
apiVersion: v1
metadata:
  name: container2
  annotations:
    version: v1.0
spec:
  selector:
    component: &lt;deployment&gt;
  ports:
     - name: container2
       port: 8080
       targetPort: 8081
  type: ClusterIP
</code></pre>
