<p>I have an app which will start a server at <code>127.0.0.1:8080</code> and using a <code>Dockerfile</code> to create an image for hosting it on GKE. I deployed this app on <code>port 8080</code> on the kubernetes cluster. Then I EXPOSE the service as <code>LoadBalancer</code> for the same port 8080 but it is not allowing it to be accessed from outside. So I created an ingress for external access but still doesn't work.
When I click at the IP provided by ingress, I get this Error:</p>
<pre><code>Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
</code></pre>
<p>I would like to ask is there something I have missed or done wrong in the implementation.</p>
<p>My YAML file:</p>
<pre><code>---
apiVersion: &quot;apps/v1&quot;
kind: &quot;Deployment&quot;
metadata:
  name: &quot;app&quot;
  namespace: &quot;default&quot;
  labels:
    app: &quot;app&quot;
spec:
  replicas: 3
  selector:
    matchLabels:
      app: &quot;app&quot;
  template:
    metadata:
      labels:
        app: &quot;app&quot;
    spec:
      containers:
      - name: &quot;app-sha256-1&quot;
        image: &quot;gcr.io/project-1234/github.com/user/app@sha256:b17b8159668d44fec3d&quot;
---
apiVersion: &quot;autoscaling/v2beta1&quot;
kind: &quot;HorizontalPodAutoscaler&quot;
metadata:
  name: &quot;app-hpa-y3ay&quot;
  namespace: &quot;default&quot;
  labels:
    app: &quot;app&quot;
spec:
  scaleTargetRef:
    kind: &quot;Deployment&quot;
    name: &quot;app&quot;
    apiVersion: &quot;apps/v1&quot;
  minReplicas: 1
  maxReplicas: 5
  metrics:
  - type: &quot;Resource&quot;
    resource:
      name: &quot;cpu&quot;
      targetAverageUtilization: 80

---
apiVersion: &quot;v1&quot;
kind: &quot;Service&quot;
metadata:
  name: &quot;app-service&quot;
  namespace: &quot;default&quot;
  labels:
    app: &quot;app&quot;
spec:
  ports:
  - protocol: &quot;TCP&quot;
    port: 8080
  selector:
    app: &quot;app&quot;
  type: &quot;LoadBalancer&quot;
  loadBalancerIP: &quot;&quot;

---
apiVersion: &quot;extensions/v1beta1&quot;
kind: &quot;Ingress&quot;
metadata:
  name: &quot;ingress&quot;
  namespace: &quot;default&quot;
spec:
  backend:
    serviceName: &quot;app-service&quot;
    servicePort: 8080

</code></pre>
<p>Thanks! Look forward to the suggestions.</p>

Mohammad Saad
<p><code>start a server at 127.0.0.1:8080 </code> this would allow your app to accept connection within the pod only. Bind to <code>0.0.0.0</code> instead.</p>
<p>Also your Deployment:</p>
<pre><code>...
containers:
  - name: &quot;app-sha256-1&quot;
    image: &quot;gcr.io/project-1234/github.com/user/app@sha256:b17b8159668d44fec3d&quot;
    ports:
    - containerPort: &lt;the port# that your container serves&gt;
</code></pre>
<p>And your Service:</p>
<pre><code>...
ports:
- protocol: &quot;TCP&quot;
  port: 8080
  targetPort: &lt;the port that your container serves&gt;
</code></pre>
