<p>I am new to Kubernetes, and I am trying to host an application using Kubernetes in our internal compute service system.</p>
<p>Since our internal compute service doesn't support <code>rewrite-target</code> annotation I have to use the reverse proxy to handle the rewrite.</p>
<p>So, the flow I have is:
VIP -&gt; Service -&gt; Pod [Sidecar which has nginx rewrite] -&gt; Pod [Application container]</p>
<p>Here is manifest:</p>
<pre class="lang-yaml prettyprint-override"><code># Source: reportportal/templates/gateway-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: reportportal-gateway-ingress
  labels:     
    heritage: &quot;Helm&quot;
    release: &quot;reportportal&quot;
    chart: reportportal-5.2.1
    app: &quot;reportportal&quot;
spec:
  rules:

  - http:
      paths:
      - path: /
        backend:
          serviceName: reportportal-ui
          servicePort: headless
          

---
# Source: reportportal/templates/ui-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: reportportal-ui
  labels:     
    heritage: &quot;Helm&quot;
    release: &quot;reportportal&quot;
    chart: reportportal-5.2.1
    app: &quot;reportportal&quot;
  annotations:
    service: ui
    infoEndpoint: /info
spec:
  ports:
  - name: headless
    port: 5000
    protocol: TCP
    targetPort: 5000
  selector:
    component: reportportal-ui
  type: ClusterIP
  
  
---
# Source: reportportal/templates/ui-config-map.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: ui-nginx-conf
  labels:
     sdr.appname: reportportal
data:
  nginx.conf: |-
    user  nginx;
    worker_processes  1;

    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;

    events {
        worker_connections  1024;
    }

    http {
        keepalive_timeout  65;

        upstream ui {
            server 127.0.0.1:8080;
        }

        server {
            listen 5000;

            location / {
                #rewrite  /(ui)/?(.*)  /$2;
                proxy_pass         http://ui;
                proxy_redirect     off;
            }
        }
    }

---
# Source: reportportal/templates/ui-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: reportportal-ui
  labels:     
    heritage: &quot;Helm&quot;
    release: &quot;reportportal&quot;
    chart: reportportal-5.2.1
    app: &quot;reportportal&quot;
spec:
  replicas: 1
  selector:
    matchLabels:
      component: reportportal-ui
  template:
    metadata:
      labels:
        component: reportportal-ui
      annotations:
    spec:
      containers:
      - name: uinginx
        image: nginx:alpine
        ports:
        - containerPort: 5000
          protocol: TCP
        volumeMounts:
        - name: nginx-proxy-config
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
      - name: ui
        image: &quot;reportportal/service-ui:5.2.2&quot;
        env:
          - name: RP_SERVER_PORT
            value: &quot;8080&quot;
        resources:
          requests:
            cpu: 100m
            memory: 64Mi
          limits:
            cpu: 200m
            memory: 128Mi
        readinessProbe:
          httpGet:
            path: &quot;/health&quot;
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 3
      volumes:
        - name: nginx-proxy-config
          configMap:
            name: ui-nginx-conf
        
      securityContext:
        {}
      serviceAccountName:
      ...
</code></pre>
<p>I am using Minikube (in my local machine), when I try to hit the URL, I am getting &quot;404 not found&quot; page.</p>
<p>The issue here is, Service is unable to connect the Pod[Sidecar]!</p>
<p>Can someone please help to fix this issue?</p>
<p>Thanks in advance!</p>

Ramesh
<p>Tried this 🏂 with:</p>
<pre class="lang-sh prettyprint-override"><code># MacOS
minikube start --driver=docker
kubectl apply -f file-with-all-the-manifests.yaml
</code></pre>
<p>and it works great for me 🤷‍♂️.</p>
<p>From a debug pod on the same namespace 🏃:</p>
<pre class="lang-html prettyprint-override"><code>/ # curl reportportal-ui:5000
&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;Report Portal&lt;/title&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;link rel=&quot;shortcut icon&quot; href=&quot;favicon.ico&quot;&gt;&lt;link href=&quot;styles.535fa1.css&quot; rel=&quot;stylesheet&quot;&gt;&lt;link href=&quot;main.535fa1.css&quot; rel=&quot;stylesheet&quot;&gt;&lt;/head&gt;
    &lt;body&gt;
      &lt;div id=&quot;app&quot; style=&quot;width: 100%; height: 100%&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;popover-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;modal-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;tooltip-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;notification-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;screen-lock-root&quot;&gt;&lt;/div&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;polyfills.app.535fa1.js&quot;&gt;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;styles.app.535fa1.js&quot;&gt;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;main.app.535fa1.js&quot;&gt;&lt;/script&gt;&lt;/body&gt;
  &lt;/html&gt;
/ #
</code></pre>
<p>Also works from the Nginx sidecar container 🏃:</p>
<pre class="lang-js prettyprint-override"><code>/ # curl 127.0.0.1:8080
&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;Report Portal&lt;/title&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;link rel=&quot;shortcut icon&quot; href=&quot;favicon.ico&quot;&gt;&lt;link href=&quot;styles.535fa1.css&quot; rel=&quot;stylesheet&quot;&gt;&lt;link href=&quot;main.535fa1.css&quot; rel=&quot;stylesheet&quot;&gt;&lt;/head&gt;
    &lt;body&gt;
      &lt;div id=&quot;app&quot; style=&quot;width: 100%; height: 100%&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;popover-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;modal-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;tooltip-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;notification-root&quot;&gt;&lt;/div&gt;
      &lt;div id=&quot;screen-lock-root&quot;&gt;&lt;/div&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;polyfills.app.535fa1.js&quot;&gt;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;styles.app.535fa1.js&quot;&gt;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;main.app.535fa1.js&quot;&gt;&lt;/script&gt;&lt;/body&gt;
  &lt;/html&gt;
/ #
</code></pre>
<p>It's probably networking on whichever environment you are running. Your internal compute system or minikube. See if none of the pods are crashing:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl get pods --all-namespaces
</code></pre>
<p>✌️</p>
