This article represents concepts, revision / quick notes, and practice or sample test/interview questions and answers on Service Discovery topic of Kubernetes. These notes, Q&A could provide to be helpful for those appearing for Kubernetes administrator certification exams (CKA).
Revision Notes – Service Discovery
- Kubernetes supports the following two modes of service discovery:
- Environment variable
- Service environment details can be set based on the following format. Service name needs to be in uppercase.
- When using environment variables for service discovery, it is a mandate that the services must be created prior to the pods which want to access those services.
- DNS server creates a set of records for each service discovered via watching Kubernetes APIs.
- Services of type ExternalName can only be accessed through DNS server.
- For headless service (exposed with a single service IP) not requiring load balancer, the cluster IP (spec.clusterIP)should be specified as None.
- A service can be reached based on the ServiceType assigned to it. The details can be found on this page, Service types
- ClusterIP: The service can be reached from within the cluster
- NodePort: The service can be reached from outside the cluster at the address NodeIP:NodePort. The port is a static port. The request is then routed to appropriate clusterIP service. Note that the clusterIP service gets created automatically. The port number supported must fall in the range, 30000-32767
- LoadBalancer: The service can be reached from the load balancer. The NodePort and ClusterIP services to which request from load balancer will be routed are created automatically.
- ExternalName: The service can be mapped to the content of ExternalName.
- Kubernetes support the notion of the internal load balancer for route traffic from services inside the same VPC. For different cloud providers AWS, Azure or GCP, different configuration annotation need to be applied. Details could be found on this page, internal load balancer
- Kubernetes supports network load balancer starting version 1.9.
Practice Test – Service Discovery
Services can be discovered using which of the following techniques?
Which of the following are valid serviceTypes?
When using environment variable technique for service discovery, pods must be created prior to services for accessing the respective services
Services of type ExternalName can be accessed using ________
It is possible to access a service without load balancing
For all services including headless service (exposed with a single service IP), clusterIP (spec.clusterIP) must be allocated
A headless service must be defined with a selector
Which of the following ServiceType makes service reachable from within the cluster
Which of the following ServiceType makes service reachable from outside the cluster on a specific port of a Node
Which of the following ServiceType makes service reachable from the load balancer
Kubernetes supports network load balancer from which version
The port number of service type, NodePort, must fall in the range such as __________
Kubernetes can be exposed on external IPs for routing the request to one or more nodes
Other Practice Tests / Interview Questions and Answers
- Introduction to Kubernetes
- Pods, Taints and Tolerations
- Container hooks / Pods
- Pod Lifecycle
He has also authored the book, Building Web Apps with Spring 5 and Angular.
Latest posts by Ajitesh Kumar (see all)
- Neural Network Architecture for Text-to-Speech Synthesis - July 29, 2019
- Reverse Image Search using Deep Learning (CNN) - July 27, 2019
- Why Data Scientists Must Learn Statistics? - July 27, 2019