<p>I am new to K8s and this is my first time trying to get to grips with it. I am trying to set up a basic Nodejs Express API using this deployment.yml:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - image: registry.gitlab.com/&lt;project&gt;/&lt;app&gt;:&lt;TAG&gt;
        imagePullPolicy: Always
        name: api
        env:
        - name: PORT
          value: "8080"
        ports:
          - containerPort: 8080
            hostPort: 80
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 30
          timeoutSeconds: 1
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 30
          timeoutSeconds: 1
      imagePullSecrets:
        - name: registry.gitlab.com
</code></pre>

<p>Which is being deployed via gitlab-ci. This is working and I have set up a service to expose it:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: api-svc
  labels:
    app: api-svc
spec:
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  selector:
    app: api
  type: LoadBalancer
</code></pre>

<p>But I have been looking into ingress to have a single point of entry for possibly multiple services. I have been reading through Kubernetes guides and I read through this <a href="https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example" rel="nofollow noreferrer">Kubernetes Ingress Example</a> and this is the ingress.yml I created:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  backend:
    serviceName: api-svc
    servicePort: 80
</code></pre>

<p>But this did not work, when I visited the external IP address that was generated from the ingress and I just 502 error pages. </p>

<p>Could anyone point me in the right direction, what am I doing wrong or what am I missing? I see that in the example link above that there is an nginx-rc.yml which I deployed exactly like in the example and that was created but still got nothing from the endpoint. The API was accessible from the Service external IP though..</p>

<p>Many Thanks</p>

<p>I have looked into it again and think I figured it out.</p>

<p>In order for Ingress to work on GCE you need to define your backend service das a <code>NodePort</code> not as ClusterIP or LoadBalancer.</p>

<p>Also you need to make sure the http health check to <code>/</code> works (you'll see the Google L7 Loadbalancer hitting your service quite a lot on that url) and then it's available.</p>
