2

I've exposed a service on GKE using the following load balancer config. I can port-forward (kubectl port-forward svc/app-external 3000:80) locally, and the service forwards to the deployed Rails application running on a container at port 3000. However, going to the IP address listed under LoadBalancer Ingress gives connection refused.

It's my understanding that load balancers should automatically be configured by Google cloud to receive connections, but maybe I'm missing something. Any help would be appreciated. Below is my load balancer config.

apiVersion: v1
kind: Service
metadata:
  labels:
    app: app
  name: app-external
spec:
  externalTrafficPolicy: Cluster
  ports:
  - port: 80
    protocol: TCP
    targetPort: http-server
  selector:
    app: app
  sessionAffinity: None
  loadBalancerIP: x.x.x.x
  type: LoadBalancer

Update

Ouput from kubectl get service

NAME           | TYPE       | CLUSTER-IP  | EXTERNAL-IP  | PORT(S)
---------------|------------|-------------|--------------|------------
app-external   |LoadBalancer|xx.xx.xxx.xxx|xx.xxx.xxx.xxx|80:32014/TCP
---------------|------------|-------------|--------------|------------
kubernetes     | ClusterIP  | xx.xx.xxx.x |    <none>    |   443/TCP

I'm using the external IP to access it.

  • What IP address exactly you are going through? can you show the output of `kubectl get svc`? You can mask the IPs if you'd like – Rico Oct 01 '18 at 23:21
  • `NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE app-external . LoadBalancer . xx.xx.xxx.xxx . xx.xxx.xxx.xxx . 80:32014/TCP 6m kubernetes . ClusterIP . xx.xx.xxx.x . . 443/TCP . 12h` I'm going to EXTERNAL-IP for app-external. – Benjamin Newland Oct 02 '18 at 15:02
  • I'm sorry that the formatting is screwy. I wasn't sure how to format tables in comments. – Benjamin Newland Oct 02 '18 at 15:09
  • You can just update the question. :-) – Rico Oct 02 '18 at 15:09
  • Added to the question. – Benjamin Newland Oct 02 '18 at 15:32
  • Where is the variable `http-server` defined? Is it `3000`? – mantithetical Oct 02 '18 at 16:44
  • Follow tutorial https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app, or the Guestbook tutorial in the same website. There are tutorials on mapping ports. – ahmet alp balkan Oct 02 '18 at 20:46
  • The issue is likely with the way you’ve configured targetPort: http-server. Can you share how you created the variable? Can you also confirm it is mapping to each pods correct port? I also suggest taking a look at these[0][1] to help configure the named ports. [0] https://kubernetes.io/docs/concepts/services-networking/service/#discovering-services [1] https://stackoverflow.com/questions/48886837/how-to-make-use-of-kubernetes-port-names – Patrick W Oct 03 '18 at 20:43
  • I'm having the same problem. What's ironical is that I have two similar deployments and two services. One works just fine, the other is not accessible. The config is good. – Paweł Szczur Jan 15 '20 at 13:31

0 Answers0