kubernetes - Does the Google Container Engine support DNS based service discovery? -


from kubernetes docs see there dns based service discovery mechanism. google container engine support this. if so, what's format of dns name discover service running inside container engine. couldn't find relevant information in container engine docs.

the dns name services follow: {service-name}.{namespace}.svc.cluster.local.

assuming configured kubectl work cluster should able service , namespace details following steps below.

get namespace

$ kubectl namespaces name          labels    status default       <none>    active kube-system   <none>    active 

you should ignore kube-system entry, because cluster itself. other entries namespaces. default there 1 namespace called default.

get services

$ kubectl services name                  labels                                                    selector                   ip(s)            port(s) broker-partition0     name=broker-partition0,type=broker                        name=broker-partition0     10.203.248.95    5050/tcp broker-partition1     name=broker-partition1,type=broker                        name=broker-partition1     10.203.249.91    5050/tcp kubernetes            component=apiserver,provider=kubernetes                   <none>                     10.203.240.1     443/tcp service-frontend      name=service-frontend,service=frontend                    name=service-frontend      10.203.246.16    80/tcp                                                                                                            104.155.61.198    service-membership0   name=service-membership0,partition=0,service=membership   name=service-membership0   10.203.246.242   80/tcp service-membership1   name=service-membership1,partition=1,service=membership   name=service-membership1   10.203.248.211   80/tcp 

this command lists services available in cluster. example, if want ip address of service-frontend can use following dns: service-frontend.default.svc.cluster.local.

verify dns busybox pod

you can create busybox pod , use pod execute nslookup command query dns server.

$ kubectl create -f - << eof apiversion: v1 kind: pod metadata:   name: busybox   namespace: default spec:   containers:   - image: busybox     command:       - sleep       - "3600"     imagepullpolicy: ifnotpresent     name: busybox   restartpolicy: eof 

now can nslookup pod in cluster.

$ kubectl exec busybox -- nslookup broker-partition0.default.svc.cluster.local server:    10.203.240.10  address 1: 10.203.240.10  name:      service-frontend.default.svc.cluster.local address 1: 10.203.246.16 

here see addres 1 entry ip of service-frontend service, same ip address listed kubectl services.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -