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 primary role of a Service in Kubernetes?
See 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 Pods' IPs change.
Question 2
Which type of Service is used by default and is only accessible from within the cluster?
See explanation
Correct answer: ClusterIP
Explanation: ClusterIP is the default type. It exposes the Service on an internal cluster IP, accessible only from within.
Question 3
Which type of Service exposes the application on a static port of each node?
See explanation
Correct answer: NodePort
Explanation: NodePort exposes the Service on a static port (30000-32767) of each node, allowing access to the Service from outside the cluster via [NodeIP]:[NodePort].
Question 4
Which type of Service automatically creates an external load balancer in cloud environments?
See 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?
See explanation
Correct answer: [service-name].[namespace].svc.cluster.local
Explanation: Services have a full DNS name that includes the Service name, namespace, and cluster domain, allowing DNS resolution throughout the cluster.
Question 6
Which Kubernetes component manages the DNS resolution of Services?
See explanation
Correct answer: CoreDNS
Explanation: CoreDNS is the DNS service that resolves Service names and enables service discovery via DNS in the cluster.
Question 7
What is an Endpoint in Kubernetes?
See explanation
Correct answer: A resource that lists the IP addresses of Pods that match a Service's selectors
Explanation: Endpoints are automatically created for each Service and contain the IP addresses of backend Pods that match the Service's selectors.
Question 8
What is an EndpointSlice?
See explanation
Correct answer: An improved version of Endpoint that allows managing large numbers of backends more efficiently
Explanation: EndpointSlice is a modern alternative to Endpoint that divides endpoints into multiple slices, improving performance for Services with many backends.
Question 9
What is the default load balancing mode for a ClusterIP Service?
See explanation
Correct answer: Round-robin via iptables or IPVS (depending on kube-proxy configuration)
Explanation: kube-proxy uses iptables (by default) or IPVS to distribute traffic among backend Pods in a round-robin manner.
Question 10
What is a headless Service?
See explanation
Correct answer: A Service with clusterIP: None that directly returns the IPs of the Pods
Explanation: A headless Service (clusterIP: None) allows directly obtaining the IP addresses of Pods via DNS, useful for StatefulSets and service discovery.
Question 11
What is a Network Policy?
See explanation
Correct answer: A resource that defines network communication rules between Pods
Explanation: Network Policies allow controlling network traffic between Pods, acting as a firewall at the cluster level.
Question 12
Which CNI plugin is required to use Network Policies?
See explanation
Correct answer: A CNI plugin that supports Network Policies (Calico, Cilium, Weave, etc.)
Explanation: Not all CNI plugins support Network Policies. You need to use a compatible plugin like Calico, Cilium, or Weave.
Question 13
What is the default port of a Service if not specified?
See 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 a Service of type ExternalName?
See 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?
See explanation
Correct answer: 30000-32767
Explanation: NodePort ports are assigned in the range 30000-32767 by default, although this range can be configured.
Question 16
What is sessionAffinity in a Service?
See explanation
Correct answer: A configuration that ensures a client's requests 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?
See explanation
Correct answer: Maintain network rules (iptables/IPVS) for Services and perform load balancing
Explanation: kube-proxy monitors Services and Endpoints, and updates iptables or IPVS rules to route traffic to the appropriate backend Pods.
Question 18
What is a Service without a selector?
See explanation
Correct answer: A Service that points to manually defined external endpoints
Explanation: A Service without a selector allows creating a Service that points to endpoints external to the cluster by manually creating an Endpoints object.
Question 19
What is the advantage of using IPVS instead of iptables for kube-proxy?
See 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?
See 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 within the cluster (can be configured differently).
Question 21
What is the difference between a ClusterIP Service and a NodePort Service?
See explanation
Correct answer: ClusterIP is only accessible within the cluster, NodePort also exposes a port on each node
Explanation: A ClusterIP Service is accessible only 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?
See explanation
Correct answer: An identity for Pods, used for authentication with the API Server
Explanation: A Service Account provides an identity for Pods, allowing 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?
See explanation
Correct answer: Expose HTTP/HTTPS Services from outside the cluster with path or hostname-based routing
Explanation: Ingress allows exposing multiple Services via a single entry point with URL path or hostname-based routing, with TLS/SSL support.
Question 24
What is a CNI plugin?
See 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?
See explanation
Correct answer: kubectl get endpoints
Explanation: This command displays the Endpoints that list the IP addresses of backend Pods for each Service.
Question 26
What is a Service mesh?
See explanation
Correct answer: A dedicated infrastructure that manages microservice communication with observability, security, and traffic control
Explanation: A Service mesh (like Istio, Linkerd) adds a networking layer that manages service communication with advanced features like mTLS, circuit breaking, and observability.
Question 27
What is the difference between a Service and an Ingress?
See 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 above that allows HTTP/HTTPS routing based on path or hostname to multiple Services.
Question 28
What is an ExternalIP in a Service?
See explanation
Correct answer: An external IP address that can be used to access the Service from outside the cluster
Explanation: externalIPs allows specifying 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?
See explanation
Correct answer: nslookup [service-name].[namespace].svc.cluster.local from a Pod
Explanation: You can test DNS resolution by running nslookup or dig from a Pod to verify that CoreDNS correctly resolves the Service name.
Question 30
What is a Service without a specified targetPort?
See 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 Result
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 on: December 2024