Kubernetes API External Point Fail on Connection

8/21/2018

I have currently create this kubernetes file: for deploy two API's in a Cluster on GCloud. I had tried make two kinds of "type" on kind Service. First of all I had set the service type as a NodePort and couldn't connect to it, after that I had try use LoadBalancer, although, even with the external IP and the Endpoints I'm not able to access any API.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xxxxxxxxxxxxx
  labels:
    app: xxxxxxxx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: xxxxxxxxx
  template:
    metadata:
      labels:
        app: xxxxxxxx
    spec:
      containers:
      - name: xxxxx
        image: xxxxxxxxx
        ports:
        - containerPort: 3000
---

kind: Service
apiVersion: v1
metadata:
  name: xxxxxxxxx
spec:
  selector:
    app: xxxxxxxx
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 3000
  type: LoadBalancer

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: yyyyyy
  labels:
    app: yyyyyy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: yyyyyy
  template:
    metadata:
      labels:
        app: yyyyyy
    spec:
      containers:
      - name: yyyyyy
        image: yyyyyy
        ports:
        - containerPort: 3000
---

kind: Service
apiVersion: v1
metadata:
  name: yyyyyy
spec:
  selector:
    app: yyyyyy
  ports:
  - protocol: TCP
    port: 80
    targetPort: 3000
  type: LoadBalancer

Could anyone help me on this issue?

Regards.

-- Bruno Perim
google-kubernetes-engine
kubernetes

1 Answer

8/23/2018

There are a lot of examples of deploying Service (type:LoadBalancer) and have it redirect traffic to Deployment on GKE documentation.

Please follow these tutorials:

Also in your question you don't list any "errors" or "events". Please take a look at kubectl describe output of the Service. If you aren't getting the load balancer working, there might be an error like you ran out of IP addresses in your GCP project.

-- AhmetB - Google
Source: StackOverflow