Day 37 Task: Kubernetes Important interview Questions.
Questions
1 . What is Kubernetes and why it is important?
- Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It is important because it simplifies the management of complex containerized environments, enables efficient resource utilization, and provides high availability and scalability for applications.
2 . What is difference between docker swarm and kubernetes?
Docker Swarm is Docker's native clustering and orchestration tool, whereas Kubernetes is a more comprehensive and widely adopted container orchestration platform.
Kubernetes provides more advanced features such as automatic scaling, rolling updates, and declarative configuration, while Docker Swarm is simpler and easier to set up.
3 . How does Kubernetes handle network communication between containers?
- Kubernetes uses a flat networking model where each pod gets its own IP address. It uses a container network interface (CNI) plugin to manage networking between containers and pods. Network policies can be applied to control traffic between pods.
4 . How does Kubernetes handle scaling of applications?
- Kubernetes can automatically scale applications horizontally by adding or removing replicas based on CPU or custom metrics. It supports both manual scaling and autoscaling based on defined thresholds.
5 . What is a Kubernetes Deployment and how does it differ from a ReplicaSet?
A Deployment manages a set of identical pods, ensuring that a specified number of replicas are running at any given time. It provides features for rolling updates and rollback.
A ReplicaSet is a lower-level Kubernetes object that ensures a specified number of pod replicas are running. Deployments are higher-level abstractions built on top of ReplicaSets.
6 . Can you explain the concept of rolling updates in Kubernetes?
- Rolling updates in Kubernetes allow for updating a deployment to a new version without downtime. It gradually replaces old pods with new ones, ensuring that the application remains available during the update process.
7 . How does Kubernetes handle network security and access control?
- Kubernetes provides network policies to control traffic between pods based on labels and namespaces. It supports role-based access control (RBAC) for managing user permissions and authentication mechanisms like service accounts and tokens.
8 . Can you give an example of how Kubernetes can be used to deploy a highly available application?
- Deploying a stateless web application with multiple replicas across different nodes, using horizontal pod autoscaling and load balancing with an ingress controller.
9 . What is namespace is kubernetes? Which namespace any pod takes if we don't specify any namespace?
- A namespace in Kubernetes provides a way to logically isolate resources within a cluster. If no namespace is specified, the pod is created in the default namespace.
10 . How ingress helps in kubernetes?
- Ingress in Kubernetes is an API object that manages external access to services within a cluster. It provides routing rules, SSL termination, and load balancing for HTTP and HTTPS traffic to different services based on hostnames or paths.
11 . Explain different types of services in kubernetes?
Kubernetes supports several types of services:
ClusterIP: Exposes the service on an internal IP within the cluster. It is accessible only from within the cluster.
NodePort: Exposes the service on a static port on each node's IP. It is accessible from outside the cluster.
LoadBalancer: Creates an external load balancer in the cloud provider's network to route external traffic to the service.
ExternalName: Maps the service to the contents of the externalName field. It allows accessing services outside the cluster.
Headless: Forwards DNS requests to the pods directly without load balancing. Useful for stateful applications.
12 . Can you explain the concept of self-healing in Kubernetes and give examples of how it works?
Self-healing in Kubernetes refers to the ability of the system to automatically detect and recover from failures without human intervention.
Examples of self-healing mechanisms in Kubernetes include:
Restarting pods that have crashed or become unhealthy.
Rescheduling pods to healthy nodes if a node fails.
Replacing failed or unresponsive containers.
Performing rolling updates to deploy new versions of applications.
13 . How does Kubernetes handle storage management for containers?
Kubernetes provides persistent storage solutions through PersistentVolumes (PVs) and PersistentVolumeClaims (PVCs).
PVs represent storage volumes provisioned by administrators, while PVCs are requests for storage by applications.
Kubernetes supports various storage options such as hostPath, NFS, AWS EBS, GCE PD, Azure Disk, and more.
StorageClasses allow dynamic provisioning of storage based on predefined policies.
14 . How does the NodePort service work?
NodePort is a Kubernetes service type that exposes the service on a static port on each node's IP address.
When a NodePort service is created, Kubernetes allocates a port from a predefined range (30000-32767) on each node.
External traffic sent to any node's IP address on the allocated port is forwarded to the service.
15 . What is a multinode cluster and single-node cluster in Kubernetes?
A multinode cluster in Kubernetes consists of multiple nodes (VMs or physical servers) connected together to form a cluster. Each node runs Kubernetes components like kubelet, kube-proxy, and container runtime.
A single-node cluster is a Kubernetes cluster running entirely on a single machine, typically used for development, testing, or small-scale deployments.
16 . Difference between create and apply in kubernetes?
kubectl create
is used to create new Kubernetes resources from configuration files or command-line arguments. If a resource already exists with the same name,create
will fail.kubectl apply
is used to create or update Kubernetes resources based on the configuration provided. If a resource already exists,apply
will update it to match the provided configuration.