Gcloud Kubernetes connection refused to exposed service

7/18/2018

I am unable to connect to an exposed IP for a docker container deployed on Google Could Kubernetes. I have been roughly following this tutorial but using my own application.

The deployment seems to work fine, everything is green and running when visiting the cloud dashboard but when trying to visit the deployed application on the exposed IP, I get a browser error:

This site can’t be reached 35.231.27.158 refused to connect

If I ping the IP I do get a response back.

kubectl get pods produces the following:

NAME                        READY     STATUS    RESTARTS   AGE
mtg-dash-7874f6c54d-nktjn   1/1       Running   0          21m

and kubectl get service shows the following:

NAME         TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
kubernetes   ClusterIP      10.7.240.1     <none>          443/TCP        23m
mtg-dash     LoadBalancer   10.7.242.240   35.231.27.158   80:30306/TCP   20m

and kubectl describe svc show the following:

Name:                     mtg-dash
Namespace:                default
Labels:                   run=mtg-dash
Annotations:              <none>
Selector:                 run=mtg-dash
Type:                     LoadBalancer
IP:                       10.7.242.240
LoadBalancer Ingress:     35.231.27.158
Port:                     <unset>  80/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  30306/TCP
Endpoints:                10.4.0.6:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason                Age   From                Message
  ----    ------                ----  ----                -------
  Normal  EnsuringLoadBalancer  37m   service-controller  Ensuring load balancer
  Normal  EnsuredLoadBalancer   37m   service-controller  Ensured load balancer

My Dockerfile contains the following:

FROM nginx:alpine

COPY nginx.conf /etc/nginx/nginx.conf

WORKDIR /usr/share/nginx/html

COPY dist/mtg-dash .

I have a feeling I have missed something obvious.

What more do I need to do to configure this to be accessible on the internet?

Here is a screenshot of running service:

enter image description here

-- wper
docker
google-cloud-platform
kubernetes

1 Answer

7/18/2018

As per the comments the target port should be 80 since that is what the application is set to listen on. Glad I could help. Picked it up from the documentation a month or so ago.

https://kubernetes.io/docs/concepts/services-networking/service/

-- quantomworks
Source: StackOverflow