title: How to connect kubernetes deployment having multiple containers to multiple service ports of a single service?
body: <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>