<p>I have a kubernetes cluster with 1 pod and 3 containers inside it. One container is a flask app and it redirects the appropriate request to one of the two other containers based on the request.</p>

<p>The problem is my flask app is only able to access one container. Below is my deployment file:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: flask-service
  labels:
    run: flask-service
spec:
  selector:
    app: flask
  ports:
  - protocol: "TCP"
    port: 5000
    targetPort: 5000
  type: LoadBalancer
---  
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask
spec:
  selector:
    matchLabels:
      app: flask  
  replicas: 1
  template:
    metadata:
      labels:
        app: flask
    spec:
      containers:
      - name: flask
        image: gcr.io/translatefx/flask
        ports:
        - containerPort: 5000
      - name: tagatag-container
        image: gcr.io/XXX/tagatag
        ports:
        - containerPort: 8501
      - name: defined-terms-container
        image: gcr.io/XXX/defined_terms
        ports:
        - containerPort: 8501
</code></pre>

<p>If my deployment includes both containers (as shown below), only one will work.</p>

<pre><code>      - name: tagatag-container
        image: gcr.io/XXX/tagatag
        ports:
        - containerPort: 8501
      - name: defined-terms-container
        image: gcr.io/XXX/defined_terms
        ports:
        - containerPort: 8501
</code></pre>

<p>What could I possibly be doing wrong?</p>

echan00
<p>If you want to run multi-containers in only one Pod. </p>

<p>You should run several containers in a Pod to listen on different ports</p>

<pre><code>        image: gcr.io/XXX/tagatag
        ports:
        - containerPort: 8501
      - name: defined-terms-container
        image: gcr.io/XXX/defined_terms
        ports:
        - containerPort: 8502
</code></pre>
