CKA Networking 1 — Questions and Answers
Question 1: What is the primary function of a Service in Kubernetes?
- To store cluster configuration data.
- To provide persistent storage for Pods.
- To expose a set of Pods as a network service. (Correct answer)
- To monitor the health of cluster nodes.
Correct answer: To expose a set of Pods as a network service.
A Kubernetes Service is an abstract way to expose an application running on a set of Pods as a network service. It provides a stable IP address and DNS name, acting as a single point of access for clients, even as the underlying Pods scale up, down, or are replaced. Services enable loose coupling between dependent applications and facilitate load balancing across Pods.
Question 2: Which Service type allows external access to a Kubernetes application through a specific port on each node in the cluster?
- ClusterIP
- NodePort (Correct answer)
- LoadBalancer
- ExternalName
Correct answer: NodePort
The NodePort Service type exposes the Service on a static port on each node's IP address. This means that any traffic sent to that specific port on any node in the cluster will be routed to the Service and its backing Pods. It's a common way to make a service accessible from outside the cluster, especially in development or smaller environments where an external load balancer isn't readily available.
Question 3: What is a CNI plugin in Kubernetes?
- A tool for managing Pod replicas.
- A network configuration file for Pods.
- A container network interface implementation. (Correct answer)
- A DNS resolver for the cluster.
Correct answer: A container network interface implementation.
CNI (Container Network Interface) is a specification for configuring network interfaces for Linux containers. In Kubernetes, a CNI plugin is an implementation of this specification that provides the actual network connectivity between Pods, assigns IP addresses, and manages network routing within the cluster. Examples include Calico, Flannel, and Weave Net.
Question 4: Which of the following is the default Kubernetes DNS Service?
- kube-dns
- CoreDNS (Correct answer)
- ExternalDNS
- SkyDNS
Correct answer: CoreDNS
CoreDNS is the default DNS server in Kubernetes clusters since version 1.11. It provides DNS resolution for services and Pods within the cluster, allowing them to discover each other by name rather than IP address. This is a critical component for inter-service communication and application functionality.
Question 5: How do you restrict communication between Pods in a Kubernetes cluster?
- By using RBAC policies.
- By using Network Policies. (Correct answer)
- By setting resource limits on Pods.
- By adding taints to nodes.
Correct answer: By using Network Policies.
Network Policies are Kubernetes resources that allow you to define rules for how Pods are allowed to communicate with each other and with external network endpoints. They act as a firewall for Pods, enabling you to restrict ingress (incoming) and egress (outgoing) traffic based on labels, namespaces, and IP ranges. This is essential for implementing micro-segmentation and enhancing security within the cluster.
What is the primary function of a Service in Kubernetes?