<p>I'm doing a deployment on the GKE service and I find that when I try to access the page the message </p>

<p>ERR_CONNECTION_REFUSED</p>

<p>I have defined a load balancing service for deployment and the configuration is as follows.</p>

<p>This is the .yaml for the deployment</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: bonsai-onboarding
spec:
  selector:
    matchLabels:
      app: bonsai-onboarding
  replicas: 2
  template:
    metadata:
      labels:
        app: bonsai-onboarding
    spec:
     containers:
     - name: bonsai-onboarding
       image: "eu.gcr.io/diaphanum/onboarding-iocash-master_web:v1"
       ports:
       - containerPort: 3000
</code></pre>

<p>This is the service .yaml file.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: lb-onboarding
spec:
  type: LoadBalancer
  selector:
    app: bonsai-onboarding
  ports:
  - protocol: TCP
    port: 3000
    targetPort: 3000
</code></pre>

<p>This working fine, and all is green in GKE  :)</p>

<pre><code>kubectl get pods,svc
NAME                                     READY   STATUS    RESTARTS   AGE
pod/bonsai-onboarding-8586b9b699-flhbn   1/1     Running   0          3h23m
pod/bonsai-onboarding-8586b9b699-p9sn9   1/1     Running   0          3h23m

NAME                    TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)          AGE
service/kubernetes      ClusterIP      XX.xx.yy.YY      &lt;none&gt;         443/TCP          29d
service/lb-onboarding   LoadBalancer   XX.xx.yy.YY   XX.xx.yy.YY   3000:32618/TCP   3h
</code></pre>

<p>Then when i tried to connect the error is ERR_CONNECTION_REFUSED</p>

<p>I think is about the network because y did the next test from my local machine</p>

<pre><code>Ping  [load balancer IP]  ---&gt;  Correct
Telnet [Load Balancer IP] 3000  ---&gt;  Correct
</code></pre>

<p>From cloud shell i forward the port 3000 to 8080 and in other cloudShell make a Curl <a href="http://localhost:8080" rel="nofollow noreferrer">http://localhost:8080</a>, and work fine.</p>

<p>Any idea about the problem?</p>

<p>Thanks in advance</p>

Alberto Valencia Carrasco
<p>I've changed a little bit your deployment to check it on my cluster because your image was unreachable:</p>

<ul>
<li><p>deployment:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: bonsai-onboarding
spec:
  selector:
    matchLabels:
      app: bonsai-onboarding
  replicas: 2
  template:
    metadata:
      labels:
        app: bonsai-onboarding
    spec:
     containers:
     - name: bonsai-onboarding
       image: nginx:latest
       ports:
       - containerPort: 80
</code></pre></li>
<li><p>service:</p>

<pre><code>apiVersion: v1
    kind: Service
    metadata:
      name: lb-onboarding
    spec:
      type: LoadBalancer
      selector:
        app: bonsai-onboarding
      ports:
      - protocol: TCP
        port: 3000
        targetPort: 80
</code></pre></li>
</ul>

<p>and it works out of the box:</p>

<pre><code>kubectl get pods,svc
NAME                                     READY   STATUS    RESTARTS   AGE
pod/bonsai-onboarding-7bdf584499-j2nv7   1/1     Running   0          6m58s
pod/bonsai-onboarding-7bdf584499-vc7kh   1/1     Running   0          6m58s

NAME                    TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)        AGE
service/kubernetes      ClusterIP      10.XXX.XXX.1     &lt;none&gt;          443/TCP        8m35s
service/lb-onboarding   LoadBalancer   10.XXX.XXX.230   35.XXX.XXX.235   3000:31637/TCP   67s
</code></pre>

<p>and I'm able reach <code>35.XXX.XXX.235:3000</code> from any IP:</p>

<pre><code>Welcome to nginx!
...
Thank you for using nginx.
</code></pre>

<p>You can check if your app is reachable using this command:</p>

<pre><code>nmap -Pn $(kubectl get svc lb-onboarding -o jsonpath='{.status.loadBalancer.ingress[*].ip}')
</code></pre>

<p>Maybe the cause of your problem with "ERR_CONNECTION_REFUSED" in configuration of your image? I found no problem with your deployment and load balancer configuration.</p>
