Kubernetes MCQs – Networking and Service Discovery

21.) Which resource defines how traffic enters the cluster from the outside?

A) Ingress
B) Service
C) NetworkPolicy
D) Endpoint

Answer: Option A

Explanation: Ingress manages external HTTP(S) access to services inside the cluster.

22.) What is the default port range used by NodePort services?

A) 1024–2048
B) 30000–32767
C) 20000–22000
D) 25000–27000

Answer: Option B

Explanation: NodePort services use ports in this range by default.

23.) Which of the following best defines a Service in Kubernetes?

A) A replication of pods
B) A resource to expose pods as a network service
C) A DNS server
D) A security policy

Answer: Option B

Explanation: A service exposes an application running as one or more pods.

24.) Which network component allows internal DNS resolution for service names?

A) kube-dns
B) etcd
C) nginx
D) kubelet

Answer: Option A

Explanation: kube-dns or CoreDNS handles service name resolution inside the cluster.

25.) What command shows detailed information about an ingress resource?

A) kubectl get ingress
B) kubectl inspect ingress
C) kubectl describe ingress <name>
D) kubectl logs ingress

Answer: Option C

Explanation: This command gives all configuration and rule details for an ingress resource.

26.) Which component in Kubernetes creates endpoints for a service?

A) kubelet
B) kube-dns
C) etcd
D) endpoint-controller

Answer: Option D

Explanation: The endpoint-controller watches services and creates corresponding endpoints.

27.) Which command lists all ingress controllers in the cluster?

A) kubectl get ingress-controllers
B) kubectl get ingress
C) kubectl get deployments -n ingress-nginx
D) kubectl get svc ingress

Answer: Option C

Explanation: In most setups, ingress controllers are deployed in the ingress-nginx namespace as deployments.

28.) What does the targetPort field in a Service definition refer to?

A) External port exposed to users
B) Port on which the pod is listening
C) Randomly assigned port
D) The port for API access

Answer: Option B

Explanation: targetPort is the container’s internal port the traffic is routed to.

29.) What command would you use to create a service from a YAML file?

A) kubectl run -f service.yaml
B) kubectl expose -f service.yaml
C) kubectl deploy -f service.yaml
D) kubectl create -f service.yaml

Answer: Option D

Explanation: This command creates any Kubernetes object defined in a manifest file.

30.) Which network feature is used to restrict egress traffic from a pod?

A) Ingress resource
B) NodePort rule
C) Kube-proxy
D) Egress rule in NetworkPolicy

Answer: Option D

Explanation: NetworkPolicy supports both ingress and egress traffic restrictions.

Kubernetes MCQs, Configuration Management

Leave a Reply

Your email address will not be published. Required fields are marked *