ZERO TO HERO Kubernetes 50 Questions and Answers
_Introduction to Kubernetes Concepts and Key Multiple-Choice
_
1: What is Kubernetes, and why is it needed in modern infrastructure?
Kubernetes is an open-source tool used to manage containerized application. It automates tasks like deploying, scaling, and restarting containers. In modern infrastructure where application runs in containers like Docker, Kubernetes is needed to handle large number of containers efficiently. It ensures high availability, better resource usage and smooth updates making it ideal for cloud environments.
2: What are containers, and how do they differ from virtual machines?
Containers are lightweight portable units that package an application along with everything it needs to run like code libraries and dependencies. They run on a shared OS kernel making them faster and more efficient than virtual machines. Virtual machines on the other hand include an entire operating system and virtual hardware which makes them heavier and slower to start. In short, containers share the host OS and are lightweight. Virtual machines run separate OS instances and are heavier. Containers are preferred in modern DevOps for the faster deployment, testing and development.
3: What are the benefits of using Kubernetes in a production environment?
In production, Kubernetes is very useful because first it keeps application highly available by restarting failed containers. Second, it auto-scales based on the traffic. Third, it handles zero downtime updates using rolling deployment. Fourth, it self-heals by replacing unhealthy containers. And fifth, it manage resources efficiently reducing the cloud cost.
4: What is the difference between Docker and Kubernetes?
Docker is a tool used to create and run containers which package application with their dependencies. Kubernetes on the other hand is used to orchestrate and manage many containers across multiple machines. In simple terms, Docker creates and runs container and Kubernetes manages and scale those containers in production. They often work together. Docker builds the container and Kubernetes deploys and manages them.
5: What are the main components of the Kubernetes architecture?
Kubernetes has two main parts. Control plane and worker nodes. Control plane manages the cluster and it includes API server scheduler controller manager etc. Worker node run the actual application. It includes Kubelet, Kube proxy and a container runtime. Together they keep application running healthy and scalable.
6: Explain the concept of a pod in Kubernetes.
A pod is the smallest unit in Kubernetes. It’s like a wrapper around one or more containers that need to work together closely. All containers inside a pod share the same network name spaces that is IP and ports. It can also communicate easily through local host and can also share storage volumes.
Que 7: What is a Kubernetes cluster, and how does it work?
A Kubernetes cluster is a group of machines that work together to run containerized applications. It has two main parts. Control plane and worker node. Control plane is the brain. It makes decisions like scheduling apps, monitoring health and handling updates. Worker node on the other hand run the actual application inside ports. The control plane tells the worker nodes what to do and the nodes report back with the status. Together they keep the application running scaled and healthy.
8: What is a deployment in Kubernetes, and how does it help in managing applications?
A deployment in Kubernetes is a controller that helps you manage your application’s life cycle. It allows you to define the desired state of your application like how many pods to run. It also allows us to perform rolling updates without any downtime as Q1 is updates part one by one. It also allows to roll back to the previous version if something goes wrong. In short, a deployment makes it easy to update, scale, and maintain our application reliably.
9: What is the role of the Kubernetes scheduler?
The Kubernetes Scheduler is responsible for assigning newly created parts to the best fit worker nodes. It checks resources requirement like CPU and memory. It also checks the node availability and it also checks taints tolerance and affinity rules. Based on these it picks the most suitable node and schedules the part there. This ensures efficient use of cluster resource and app performance.
10: What is a Kubernetes service, and how does it ensure connectivity to pods?
A Kubernetes service is a stable way to connect to pods even if the pods IP keeps changing. It acts as an abstraction layer that provides a fixed IP and DNS name, automatically routes traffic to the right pods using labels and it also ensures load balancing across healthy pods. This way applications can reliably talk to each other without worrying about pod restarts or IP changes
11: What are labels and selectors in Kubernetes, and how do they help in managing resources?
Labels in Kubernetes are key value pairs attached to objects like pods and deployments. They help organize, group, and filter resources. Selectors are used to query or match these labels. For example, a service uses a selector to route traffic only to ports with a specific label. Together, labels and selectors make it easy to manage and target specific set of resources in a large cluster.
12: What are ConfigMaps and Secrets in Kubernetes, and how are they used to manage configurations?
Config maps and secrets are used in Kubernetes to manage configuration data separately from a application code. Config maps store non-sensitive data like application settings, URLs or environment variables. Secrets store sensitive data like password, token or key in a base 64 encoded form for security. Both can be injected into pods as environment variables or mounted as files. It helps keep applications flexible, secure, and easy to update without rebuilding images.
13: What is a replica set in Kubernetes, and how does it ensure the desired number of pod replicas?
A replica set in Kubernetes ensures that a specific number of pod replicas are always running. If a pod crashes or gets deleted, the replica set will automatically create a new one to maintain the desired count. This ensures high availability and reliability of the application. While you can use a replica set directly, it’s usually managed by a deployment which adds version control and rolling update on top.
14: Explain the concept of namespaces in Kubernetes.
Namespaces in Kubernetes are like virtual clusters within a physical cluster. They help isolate resources like pods, services and configs. So teams or project projects can work independently. For example, you can run dev test and production environment in the same cluster using separate name spaces. This keeps things organized, secure, and easy to manage. They are especially useful in large teams or multi-tenant setups.
15: What are taints and tolerations in Kubernetes, and how do they work?
Taints in Kubernetes are used to mark nodes so that only certain parts can run on them. A tainted node says don’t schedule any parts here unless they tolerate this taint. Tolerations are added to pods to let them bypass the taint and run on those nodes. This is useful for keeping dedicated nodes for special workloads like GPU tasks or high security apps.
16: How does Kubernetes handle persistent storage for containers?
Kubernetes uses persistent volumes and persistent volume claims to manage storage for stateful applications. A persistent volume is a piece of storage in a cluster provisioned by an admin or dynamically. A persistent volume claim is a request by a pod for storage specifying size and access mode. Pods use PVCs to get stable long-term storage. Even if the pod is deleted or rescheduled, the data remains safe. This setup makes it easy to manage storage independently of the pod’s life cycle.
17: How does Kubernetes handle rolling updates and rollbacks?
Kubernetes handle rolling updates through the deployment object, updating pods gradually to avoid downtime. It replaces old pod with the new ones one at a time while keeping the app still running. If something goes wrong, you can quickly roll back to a previous table version using a single command. This ensures zero downtime, control roll out and save recovery during application updates.
18: What is the role of an Ingress in Kubernetes?
Ingress in Kubernetes is used to expose services outside the cluster using HTTP or HTTPS. It acts like a smart router that number one routes incoming traffic to write service based on URL paths or host name. Number two, supports SSL termination. Number three, offer load balancing for better traffic management. With ingress, you can manage access to multiple services through a single external IP, making it diff ideal for web apps and APIs.
19: What is the significance of auto-scaling in Kubernetes, and how does it work?
Autoscaling in Kubernetes helps application handle changing loads by automatically adjusting the number of pods. The most common is horizontal pod auto-scaler which scales pod up and down based on CPU memory usage or custom metrics. This ensures number one better performance during high traffic. Number two, cost saving during load usage. And number three, no manual scaling needed. Kubernetes constantly monitors metrics and adjust pod count to match the demand in real time.
20: What is the difference between stateful and stateless applications in Kubernetes, and how are StatefulSets and Deployments used to manage them?
In Kubernetes, stateless application don’t store data between sessions. Every pod is identical and replaceable. These are managed using deployments which handle scaling and rolling updates easily. Stateful application need to retain data and have stable identities like databases. These are managed using stateful sets which ensures number one persistent storage with stable volume, number two consistent quad names and order and number three predictable network identities. So use deployments for stateless application like web servers and stateful set for stateful application like MySQL, Kafka or Radius.
- What is the primary purpose of Kubernetes? A) Package applications as containers B) Manage and orchestrate containerized applications C) Monitor server hardware D) Build virtual machines
Answer: B – Manage and orchestrate containerized applications
- Containers differ from virtual machines in that they: A) Include a full OS B) Share the host OS kernel C) Are always slower to start D) Require more resources than VMs
Answer: B – Share the host OS kernel
- One of the main benefits of using Kubernetes in production is: A) Manual scaling of applications B) Self-healing of failed containers C) Lack of load balancing D) No support for rolling updates
Answer: B – Self-healing of failed containers
- Docker is primarily used for: A) Managing multiple nodes in a cluster B) Orchestrating applications C) Creating and running containers D) Scaling applications automatically
Answer: C – Creating and running containers
- In Kubernetes architecture, the Control Plane includes: A) kubelet and kube-proxy B) API Server, Scheduler, Controller Manager, etcd C) Persistent Volumes and Persistent Volume Claims D) ConfigMaps and Secrets
Answer: B – API Server, Scheduler, Controller Manager, etcd
- Worker Nodes in Kubernetes run: A) API Server B) etcd C) kubelet, kube-proxy, and container runtime D) Scheduler and Controller Manager
Answer: C – kubelet, kube-proxy, and container runtime
- A pod in Kubernetes is: A) A virtual machine B) A group of containers sharing network and storage C) A physical server D) A replica set
Answer: B – A group of containers sharing network and storage
- The Kubernetes cluster works by: A) Running a single container B) Scheduling pods on nodes and monitoring cluster state C) Running only on a single machine D) Managing hardware directly
Answer: B – Scheduling pods on nodes and monitoring cluster state
- A deployment in Kubernetes is used to: A) Configure nodes B) Manage a set of identical pods and perform rolling updates C) Store persistent data D) Configure network policies
Answer: B – Manage a set of identical pods and perform rolling updates
- The role of the Kubernetes scheduler is to: A) Manage secrets B) Handle container storage C) Assign pods to nodes based on resource availability D) Monitor etcd health
Answer: C – Assign pods to nodes based on resource availability
- A Kubernetes service ensures connectivity to pods by: A) Assigning static IPs to each pod B) Providing a stable IP and DNS name with load balancing C) Manually configuring routes D) Disabling networking between pods
Answer: B – Providing a stable IP and DNS name with load balancing
- Labels in Kubernetes are: A) Internal node components B) Key-value pairs attached to objects for grouping C) Namespaces D) Containers that store config data
Answer: B – Key-value pairs attached to objects for grouping
- ConfigMaps are used to: A) Store sensitive data in encoded form B) Store non-sensitive configuration data as key-value pairs C) Define pod replicas D) Set node taints
Answer: B – Store non-sensitive configuration data as key-value pairs
- Secrets in Kubernetes: A) Store persistent volume claims B) Store sensitive information like passwords encoded C) Define pod selectors D) Manage node affinity
Answer: B – Store sensitive information like passwords encoded
- A replica set ensures: A) Only one pod runs B) A specified number of pod replicas are running C) That only stateful applications run D) Persistent volumes are attached
Answer: B – A specified number of pod replicas are running
- Namespaces in Kubernetes are used to: A) Define container storage B) Isolate resources and manage multiple environments C) Create pods D) Monitor node health
Answer: B – Isolate resources and manage multiple environments
- Taints are used to: A) Ensure pods are always scheduled B) Repel pods from nodes unless they have tolerations C) Store config files D) Enable pod autoscaling
Answer: B – Repel pods from nodes unless they have tolerations
- Persistent Volumes (PV) are: A) Temporary storage for pods B) Physical storage resources managed by Kubernetes C) Auto-generated by ConfigMaps D) Specific to the Control Plane
Answer: B – Physical storage resources managed by Kubernetes
- Persistent Volume Claims (PVC): A) Define cluster-wide node limits B) Request persistent storage by pods C) Store deployment configurations D) Automatically remove volumes when pods are deleted
Answer: B – Request persistent storage by pods
- Rolling updates in Kubernetes: A) Stop all pods and start new ones B) Incrementally update pods without downtime C) Update only the etcd D) Are not supported by deployments
Answer: B – Incrementally update pods without downtime
- An Ingress in Kubernetes is used to: A) Expose internal pods to external traffic B) Store configuration data C) Manage internal DNS D) Define persistent volumes
Answer: A – Expose internal pods to external traffic
- Horizontal Pod Autoscaler (HPA) works by: A) Adding nodes to the cluster B) Scaling pod replicas based on CPU/memory usage C) Automatically rolling back deployments D) Managing namespaces
Answer: B – Scaling pod replicas based on CPU/memory usage
- StatefulSets differ from Deployments in that they: A) Do not use persistent storage B) Ensure stable network identities and ordered deployment C) Always run stateless applications D) Cannot scale automatically
Answer: B – Ensure stable network identities and ordered deployment
- Stateless applications: A) Require persistent storage B) Store session data between requests C) Do not store data between sessions and are easily scalable D) Always use StatefulSets
Answer: C – Do not store data between sessions and are easily scalable
- Which component monitors the state of the cluster and ensures the desired state is maintained? A) kubelet B) Controller Manager C) API Server D) Persistent Volume
Answer: B – Controller Manager
- The component responsible for storing cluster state data in Kubernetes is: A) Scheduler B) etcd C) kube-proxy D) Ingress Controller
Answer: B – etcd
- Tolerations in Kubernetes: A) Repel pods from nodes B) Allow pods to be scheduled on nodes with matching taints C) Manage persistent storage D) Control container runtime versions
Answer: B – Allow pods to be scheduled on nodes with matching taints
- How does a Kubernetes Service load balance traffic? A) It does not support load balancing B) Through an external load balancer only C) It assigns a stable IP/DNS and balances traffic across pods D) By manually configuring iptables
Answer: C – It assigns a stable IP/DNS and balances traffic across pods
- What type of data is stored in ConfigMaps? A) Encoded secrets like passwords B) Key-value pairs of non-sensitive configuration data C) Replica set definitions D) Node-level configuration
Answer: B – Key-value pairs of non-sensitive configuration data
- How is sensitive configuration data handled in Kubernetes? A) Stored in ConfigMaps B) Embedded in pod specifications C) Stored in Secrets as encoded key-value pairs D) Stored in namespaces
Answer: C – Stored in Secrets as encoded key-value pairs
- Which Kubernetes object provides a declarative way to manage scaling and updating of applications? A) Replica Set B) StatefulSet C) Deployment D) ConfigMap
Answer: C – Deployment
- A pod usually contains: A) Only one container B) Multiple containers sharing network and storage C) Only one persistent volume D) Multiple control plane components
Answer: B – Multiple containers sharing network and storage
- What is the smallest deployable unit in Kubernetes? A) Node B) Namespace C) Pod D) Deployment
Answer: C – Pod
- Which of the following best describes a Kubernetes Namespace? A) A set of worker nodes B) A virtual cluster within a Kubernetes cluster C) A container runtime D) An Ingress rule
Answer: B – A virtual cluster within a Kubernetes cluster
- What happens if a pod fails in Kubernetes? A) The user must manually recreate it B) The kubelet deletes the pod permanently C) The system automatically restarts or reschedules it D) The pod data is permanently lost
Answer: C – The system automatically restarts or reschedules it
- Which component of the control plane schedules pods to nodes? A) API Server B) Scheduler C) Controller Manager D) etcd
Answer: B – Scheduler
- What does etcd store in Kubernetes? A) Pod logs B) Cluster configuration and state C) Network policies D) Persistent storage data
Answer: B – Cluster configuration and state
- What does a StatefulSet guarantee that a Deployment does not? A) Immutable configuration B) Persistent identity and storage for each pod C) Manual scaling D) Statelessness
Answer: B – Persistent identity and storage for each pod
- How do taints and tolerations work together? A) Taints force scheduling of pods to specific nodes B) Taints repel pods unless tolerations allow them C) Tolerations are only used for secrets management D) Taints define resource limits
Answer: B – Taints repel pods unless tolerations allow them
- An Ingress Controller is responsible for: A) Managing internal pod-to-pod communication B) Allowing external HTTP(S) traffic into the cluster C) Storing ConfigMaps D) Managing persistent storage claims
Answer: B – Allowing external HTTP(S) traffic into the cluster
- What mechanism does Kubernetes use to provide persistent storage to pods? A) Direct node disk mounting B) Persistent Volumes (PV) and Persistent Volume Claims (PVC) C) StatefulSets only D) ConfigMaps
Answer: B – Persistent Volumes (PV) and Persistent Volume Claims (PVC)
- What is a common use of labels in Kubernetes? A) Storing container logs B) Tagging resources to facilitate selection and grouping C) Encrypting Secrets D) Defining the control plane configuration
Answer: B – Tagging resources to facilitate selection and grouping
- Kubernetes Self-healing means: A) Manually scaling pods as needed B) Automatically restarting failed containers C) Reinstalling the OS on nodes D) Manually updating configurations
Answer: B – Automatically restarting failed containers
- What is the role of the kube-proxy on a worker node? A) Scheduling pods to nodes B) Managing network rules to allow communication to and from pods C) Storing persistent volumes D) Monitoring etcd health
Answer: B – Managing network rules to allow communication to and from pods
- What does a Deployment controller do when a pod update fails? A) Deletes the whole namespace B) Rolls back to the previous working version C) Forces the update anyway D) Deletes etcd data
Answer: B – Rolls back to the previous working version
- What type of scaling adjusts the number of nodes in the cluster? A) Horizontal Pod Autoscaler (HPA) B) Vertical Pod Autoscaler (VPA) C) Cluster Autoscaler D) Deployment scaling
Answer: C – Cluster Autoscaler
- Which resource type is used for sensitive configuration data in Kubernetes? A) ConfigMap B) Namespace C) Secret D) Service
Answer: C – Secret
- Which Kubernetes object ensures the desired number of pods are running? A) Service B) ConfigMap C) Replica Set D) Ingress
Answer: C – Replica Set
- Which type of application would require StatefulSets rather than Deployments? A) Web servers B) Stateless APIs C) Databases D) CronJobs
Answer: C – Databases
- Why is Kubernetes preferred over manually managing containers? A) It only works with VMs B) It automates deployment, scaling, and management of containers C) It does not support autoscaling D) It requires no configuration
Answer: B – It automates deployment, scaling, and management of containers
Top comments (0)