Skip to Content
Hands-On Microservices with Kubernetes
book

Hands-On Microservices with Kubernetes

by Gigi Sayfan
July 2019
Intermediate to advanced
502 pages
14h
English
Packt Publishing
Content preview from Hands-On Microservices with Kubernetes

Helping the user service locate StatefulSet pods

The headless user-db service has no cluster IP, as follows:

$ kubectl get svc user-dbNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEuser-db ClusterIP None <none> 5432/TCP 4d

However, it does have endpoints, which are the IP addresses in the cluster of all the pods that back the service:

$ kubectl get endpoints user-dbNAME ENDPOINTS AGEuser-db 172.17.0.25:5432 4d

This is a good option; endpoints are not exposed through environment variables, such as a service with a cluster IP (<service name>_SERVICE_HOST and <service name>_SERVICE_PORT). So, for a service to find the endpoints of a headless service, they'll have to query the Kubernetes API directly. While that's possible, it adds unnecessary coupling ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kubernetes Microservices

Kubernetes Microservices

Richard Chesterwood
Cloud Native DevOps with Kubernetes

Cloud Native DevOps with Kubernetes

John Arundel, Justin Domingus
Microservices: Up and Running

Microservices: Up and Running

Ronnie Mitra, Irakli Nadareishvili

Publisher Resources

ISBN: 9781789805468Supplemental Content