Quiz Module 4 - Services and Networking
Instructions
This quiz contains 30 multiple-choice questions to validate your understanding of Module 4.
Tip: Answer each question before revealing the answer.
Question 1
What is the main role of a Service in Kubernetes?
Show explanation
Correct answer: Expose a set of Pods as a network service with a stable IP
Explanation: A Service provides a stable IP and DNS name to access a group of Pods, even if the Pod IPs change.
Question 2
Which Service type is used by default and is only accessible from within the cluster?
Show explanation
Correct answer: ClusterIP
Explanation: ClusterIP is the default type. It exposes the Service on an internal cluster IP, accessible only from within the cluster.
Question 3
Which Service type exposes the application on a static port on each node?
Show explanation
Correct answer: NodePort
Explanation: NodePort exposes the Service on a static port (30000-32767) on each node, allowing access to the Service from outside the cluster via [NodeIP]:[NodePort].
Question 4
Which Service type automatically creates an external load balancer in cloud environments?
Show explanation
Correct answer: LoadBalancer
Explanation: LoadBalancer extends NodePort and automatically creates an external load balancer in cloud environments (AWS ELB, Azure Load Balancer, GCP Load Balancer).
Question 5
What is the DNS format of a Service in Kubernetes?
Show explanation
Correct answer: [service-name].[namespace].svc.cluster.local
Explanation: Services have a fully qualified DNS name that includes the Service name, the namespace, and the cluster domain, enabling DNS resolution across the entire cluster.
Question 6
Which Kubernetes component handles DNS resolution for Services?
Show explanation
Correct answer: CoreDNS
Explanation: CoreDNS is the DNS service that resolves Service names and enables service discovery via DNS within the cluster.
Question 7
What is an Endpoint in Kubernetes?
Show explanation
Correct answer: A resource that lists the IP addresses of Pods matching a Service's selectors
Explanation: Endpoints are automatically created for each Service and contain the IP addresses of the backend Pods that match the Service's selectors.
Question 8
What is an EndpointSlice?
Show explanation
Correct answer: An improved version of Endpoint that manages large numbers of backends more efficiently
Explanation: EndpointSlice is a modern alternative to Endpoint that splits endpoints into multiple slices, improving performance for Services with many backends.
Question 9
What is the default load balancing mode for a ClusterIP Service?
Show explanation
Correct answer: Round-robin via iptables or IPVS (depending on kube-proxy configuration)
Explanation: kube-proxy uses iptables (default) or IPVS to distribute traffic among backend Pods in a round-robin fashion.
Question 10
What is a headless Service?
Show explanation
Correct answer: A Service with clusterIP: None that directly returns Pod IPs
Explanation: A headless Service (clusterIP: None) allows you to directly obtain Pod IP addresses via DNS, useful for StatefulSets and service discovery.
Question 11
What is a Network Policy?
Show explanation
Correct answer: A resource that defines network communication rules between Pods
Explanation: Network Policies allow you to control network traffic between Pods, acting as a firewall at the cluster level.
Question 12
Which CNI plugin is required to use Network Policies?
Show explanation
Correct answer: A CNI plugin that supports Network Policies (Calico, Cilium, Weave, etc.)
Explanation: Not all CNI plugins support Network Policies. You must use a compatible plugin such as Calico, Cilium, or Weave.
Question 13
What is the default port of a Service if not specified?
Show explanation
Correct answer: The port must be explicitly specified
Explanation: Kubernetes does not define a default port for Services. The port must be specified in the Service definition.
Question 14
What is an ExternalName Service?
Show explanation
Correct answer: A Service that maps a Service to an external DNS name
Explanation: ExternalName maps a Kubernetes Service to an external DNS name, allowing access to external services as if they were internal to the cluster.
Question 15
What is the port range for NodePort?
Show explanation
Correct answer: 30000-32767
Explanation: NodePort ports are assigned in the 30000-32767 range by default, although this range can be configured.
Question 16
What is sessionAffinity in a Service?
Show explanation
Correct answer: A configuration that ensures requests from a client always go to the same backend Pod
Explanation: sessionAffinity: ClientIP ensures that all requests from the same client IP are directed to the same backend Pod, useful for sessions.
Question 17
What is the role of kube-proxy in Kubernetes networking?
Show explanation
Correct answer: Maintain network rules (iptables/IPVS) for Services and perform load balancing
Explanation: kube-proxy watches Services and Endpoints, and updates iptables or IPVS rules to direct traffic to the appropriate backend Pods.
Question 18
What is a Service without a selector?
Show explanation
Correct answer: A Service that points to manually defined external endpoints
Explanation: A Service without a selector allows you to create a Service that points to external endpoints by manually creating an Endpoints object.
Question 19
What is the advantage of using IPVS instead of iptables for kube-proxy?
Show explanation
Correct answer: IPVS offers better performance and more load balancing options for many Services
Explanation: IPVS uses hash tables instead of long iptables chains, offering better performance and more load balancing algorithms (rr, lc, dh, sh, sed, nq).
Question 20
What is cluster.local in Kubernetes DNS?
Show explanation
Correct answer: The default DNS domain of the cluster
Explanation: cluster.local is the default DNS domain used by CoreDNS to resolve Service names in the cluster (can be configured differently).
Question 21
What is the difference between a ClusterIP Service and a NodePort Service?
Show explanation
Correct answer: ClusterIP is only accessible within the cluster, NodePort also exposes a port on each node
Explanation: A ClusterIP Service is only accessible from within the cluster, while a NodePort extends ClusterIP by also exposing a static port on each node.
Question 22
What is a Service Account in the context of networking?
Show explanation
Correct answer: An identity for Pods, used for authentication with the API Server
Explanation: A Service Account provides an identity for Pods, enabling authentication and authorization when accessing the API Server, but is not directly related to Service networking.
Question 23
What is the role of an Ingress in Kubernetes?
Show explanation
Correct answer: Expose HTTP/HTTPS Services from outside the cluster with path-based or hostname-based routing
Explanation: Ingress allows you to expose multiple Services through a single entry point with routing based on URL path or hostname, with TLS/SSL support.
Question 24
What is a CNI plugin?
Show explanation
Correct answer: A network plugin that configures Pod networking in Kubernetes
Explanation: CNI (Container Network Interface) is a standard interface that allows network plugins (Calico, Flannel, Weave, etc.) to configure Pod networking.
Question 25
What is the command to view the Endpoints of a Service?
Show explanation
Correct answer: kubectl get endpoints
Explanation: This command displays Endpoints that list the IP addresses of backend Pods for each Service.
Question 26
What is a Service mesh?
Show explanation
Correct answer: A dedicated infrastructure that manages communication between microservices with observability, security, and traffic control
Explanation: A Service mesh (like Istio, Linkerd) adds a networking layer that manages communication between services with advanced features like mTLS, circuit breaking, and observability.
Question 27
What is the difference between a Service and an Ingress?
Show explanation
Correct answer: A Service exposes a set of Pods, an Ingress exposes HTTP/HTTPS Services with advanced routing
Explanation: A Service exposes Pods with a stable IP and load balancing. An Ingress is a layer on top that enables HTTP/HTTPS routing based on path or hostname to multiple Services.
Question 28
What is an ExternalIP in a Service?
Show explanation
Correct answer: An external IP address that can be used to access the Service from outside the cluster
Explanation: externalIPs allows you to specify external IP addresses that will be routed to the Service, enabling external access without a LoadBalancer.
Question 29
What is the command to test DNS resolution of a Service?
Show explanation
Correct answer: nslookup [service-name].[namespace].svc.cluster.local from within a Pod
Explanation: You can test DNS resolution by running nslookup or dig from within a Pod to verify that CoreDNS correctly resolves the Service name.
Question 30
What is a Service without a specified targetPort?
Show explanation
Correct answer: The targetPort uses the same value as the port
Explanation: If targetPort is not specified in a Service, it uses the same value as the port, meaning traffic to the Service port is directed to the same port on the backend Pods.
Quiz Results
Congratulations on completing the Module 4 quiz!
Score:
- 25-30 correct answers: Excellent!
- 20-24 correct answers: Very good!
- 15-19 correct answers: Good!
- Less than 15: Recommended to review the module.
Quiz created: December 2024