No endpoint when deploy service to Kubernetes

I deployed a service to Google Cloud (Kubernetes) however I tried to visit the endpoint to see if my service is up, it failed to response when I tried to visit it via browser.

Check from Kubernetes console, all looked good. Cluster is up. Replication controller is up. Service is up!

However I found that when I tried to describe service

scaab101:~ uadmin$ kubectl describe service

Name: cities

Namespace: default

Labels: name=cities

Annotations: <none>

Selector: app=cities

Type: LoadBalancer

IP: 10.11.254.4

LoadBalancer Ingress: 104.154.83.89

Port: http 5000/TCP

NodePort: http 31098/TCP

Endpoints: <none>

Session Affinity: None

Events: <none>

Name: kubernetes

Namespace: default

Labels: component=apiserver

provider=kubernetes

Annotations: <none>

Selector: <none>

Type: ClusterIP

IP: 10.11.240.1

Port: https 443/TCP

Endpoints: 35.184.191.191:443

Session Affinity: ClientIP

Events: <none>

scaab101:~ uadmin$ kubectl describe service

 

I reviewed my ServiceSpec.selector and found that it is due to a typo in the selector.name which causes the services unable to match to a pod (the selector.name is not the same with pod’s label!)

I fixed this and redeployed. It worked!

scaab101:~ uadmin$ kubectl describe service

Name: cities

Namespace: default

Labels: name=cities

Annotations: <none>

Selector: name=cities

Type: LoadBalancer

IP: 10.11.245.45

LoadBalancer Ingress: 104.197.164.44

Port: http 5000/TCP

NodePort: http 31712/TCP

Endpoints: 10.8.2.40:5000,10.8.2.41:5000,10.8.2.42:5000

Session Affinity: None