Kubernetes Networking
medium
Questão de Kubernetes Networking #019e3a4f
Enunciado da Questão
Kubernetes Networking
#kubernetes
#service
#pod
#networking
Médio
In Kubernetes, which abstraction defines a logical set of Pods and a policy by which to access them?
A
Service Account
B
NetworkPolicy
C
Service
Correta
D
Custom Resource Definition
Explicação Oficial / Explicações da Comunidade
In Kubernetes, a Service is an abstraction that defines a logical set of Pods and a policy by which to access them. Services enable stable networking endpoints for Pods, which are ephemeral and can be created or destroyed dynamically. A Service selects Pods based on labels and provides load-balanced access to them, typically via a ClusterIP (internal virtual IP) or other types like NodePort or LoadBalancer.
How it Works
- A Service uses a label selector to identify the Pods it targets. When Pods match the selector, they become endpoints of the Service.
- The Service creates a stable IP address (ClusterIP) and DNS name within the cluster, allowing other components to reach the Pods without needing to track individual Pod IPs.
- Traffic to the Service is load-balanced across the selected Pods using kube-proxy, which implements rules (e.g., iptables or IPVS) on each node.
Why the Correct Answer is Right
- Service directly fulfills the definition: it logically groups Pods and provides a consistent access policy (e.g., ClusterIP, NodePort, LoadBalancer). It is the core abstraction for exposing applications running in Pods.
Why the Incorrect Answers are Wrong
- Service Account: This is an identity for Pods to authenticate with the Kubernetes API server, not a networking abstraction for accessing Pods.
- NetworkPolicy: This defines rules for ingress and egress traffic between Pods and network endpoints, but it does not define a logical set of Pods or provide a stable access endpoint. It is a security feature, not a service discovery mechanism.
- Custom Resource Definition (CRD): This allows users to extend the Kubernetes API with custom resources, but it is not a built-in abstraction for grouping Pods or defining access policies. CRDs are used to create new resource types, not to manage Pod networking.