<p>I am trying to set up my app on GKE and use an internal load balancer for public access. I am able to deploy the cluster / load balancer service without any issues, but when I try to access the external ip address of the load balancer, I get Connection Refused and I am not sure what is wrong / how to debug this.</p>

<p>These are the steps I did:</p>

<p>I applied my deployment <code>yaml</code> file via <code>kubectl apply -f file.yaml</code> then after, I applied my load balancer service <code>yaml</code> file with <code>kubectl apply -f service.yaml</code>. After both were deployed, I did <code>kubectl get service</code> to fetch the External IP Address from the Load Balancer.</p>

<p>Here is my <code>deployment.yaml</code> file:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app-api
          image: gcr.io/...
          ports:
            - containerPort: 8000
          resources:
            requests:
              memory: "250M"
              cpu: "250m"
            limits:
              memory: "1G"
              cpu: "500m"
        - name: my-app
          image: gcr.io/...
          ports:
            - containerPort: 3000
          resources:
            requests:
              memory: "250M"
              cpu: "250m"
            limits:
              memory: "1G"
              cpu: "500m"
</code></pre>

<p>and here is my <code>service.yaml</code> file:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-app-ilb
  annotations:
    cloud.google.com/load-balancer-type: "Internal"
  labels:
    app: my-app-ilb
spec:
  type: LoadBalancer
  selector:
    app: my-app
  ports:
  - port: 3000
    targetPort: 3000
    protocol: TCP

</code></pre>

<p>My deployment file has two containers; a backend api and a frontend. What I want to happen is that I should be able to go on <code>[external ip address]:3000</code> and see my web app.</p>

<p>I hope this is enough information; please let me know if there is anything else I may be missing / can add.</p>

<p>Thank you all!</p>

<p>You need to allow traffic to flow into your cluster by creating firewall rule.</p>

<pre><code>gcloud compute firewall-rules create my-rule --allow=tcp:3000
</code></pre>

<hr>

<p>Remove this annotation : </p>

<pre><code>  annotations:
    cloud.google.com/load-balancer-type: "Internal"
</code></pre>

<p>You need external Load Balancer.</p>
