Day 37 Task: Kubernetes Important interview Questions.

Day 37 Task: Kubernetes Important interview Questions.

1.What is Kubernetes and why it is important?

Kubernetes is an open-source container orchestration platform developed by Google. It is designed to automate the deployment, scaling, and management of containerized applications. Containers are lightweight, isolated environments that package an application and its dependencies, allowing for easy and consistent deployment across different computing environments.

Kubernetes is important for several reasons:

  1. Scalability

    High availability

    Portability

    Operational efficiency

    Ecosystem and community

2.What is difference between docker swarm and kubernetes?

Kubernetes is generally considered more suitable for large-scale and complex containerized environments, offering extensive features, flexibility, and a robust ecosystem. Docker Swarm, on the other hand, is simpler, more tightly integrated with Docker, and often favored for smaller deployments or situations where ease of use is a priority. The choice between Docker Swarm and Kubernetes depends on the specific requirements, complexity, and scale of the container orchestration needs.

3.How does Kubernetes handle network communication between containers?

Kubernetes handles network communication between containers by assigning unique IP addresses to Pods, enabling direct communication between Pods within the cluster, providing stable network access to Services, and supporting various network plugins and load balancing mechanisms. These features ensure efficient and reliable networking for containerized applications running in a Kubernetes cluster.

4.How does Kubernetes handle scaling of applications?

Kubernetes provides built-in mechanisms for scaling applications, allowing you to scale your application horizontally by increasing or decreasing the number of running instances (replicas) of your containers. There are two primary approaches to scaling in Kubernetes: manual scaling and automatic scaling.

Manual Scaling: kubectl scale deployment my-deployment --replicas=3

Automatic scaling: Horizontal Pod Autoscaling (HPA)

5.What is a Kubernetes Deployment and how does it differ from a ReplicaSet?

The main difference between a Deployment and a ReplicaSet is that a Deployment can perform rolling updates, while a ReplicaSet cannot.

6. Can you explain the concept of rolling updates in Kubernetes?

By using rolling updates, you can seamlessly update your application without interrupting its availability. It ensures a smooth transition from the old version to the new version by progressively replacing Pods while maintaining the desired replica count. This strategy is an important feature of Kubernetes for achieving continuous delivery, minimizing downtime, and maintaining a resilient application infrastructure.

7.How does Kubernetes handle network security and access control?

Kubernetes provides several built-in network security features, such as network policies, which allow administrators to control access to the pod network.

Kubernetes also supports several authentication and authorization methods, such as certificates and tokens, to control access to the Kubernetes API.

8.Can you give an example of how Kubernetes can be used to deploy a highly available application?

Kubernetes ensures that multiple replicas of your microservices are running, provides automatic recovery from failures, load balances traffic, and enables scaling based on demand. This setup allows your application to handle increased traffic, remain available during failures, and maintain a high level of reliability and availability.

9.What is namespace is kubernetes? Which namespace any pod takes if we don't specify any namespace?

Using namespaces allows for better resource management, isolation, and control within a Kubernetes cluster, especially when running multiple applications or different environments within the same cluster. Default ns is used when we don't specify any ns

10.How ingress helps in kubernetes?

By using Ingress, you can simplify external access to your services, implement routing and load balancing, enforce security measures, and achieve more flexibility and control over incoming traffic in your Kubernetes cluster.

11.Explain different types of services in kubernetes?

Three types of services in Kubernetes: ClusterIP, NodePort, and LoadBalancer.

ClusterIP is used to expose a service on a cluster-internal IP address, NodePort is used to expose a service on each node's IP address and a specific port, and LoadBalancer is used to expose a service externally using a cloud provider's load balancer.

12.Can you explain the concept of self-healing in Kubernetes and give examples of how it works?

Self-healing in Kubernetes is the ability of the platform to automatically detect and recover from failures.

For example, if a pod fails, Kubernetes can automatically restart the pod or spin up a new replica to replace the failed pod.

Kubernetes can also perform health checks on pods and services, and automatically remove or replace them if they are not functioning correctly.

13.How does Kubernetes handle storage management for containers?

Persistent volumes and persistent volume claims.

Persistent volumes are used to create a pool of storage that can be shared by multiple pods, while persistent volume claims are used to request storage from a persistent volume.

Kubernetes also supports several storage plugins, such as NFS and GlusterFS, to allow for a wide range of storage options.

14.How does the NodePort service work?

NodePort service is a type of service that exposes an application running inside a cluster on a static port on each node's IP address. It allows external access to the service by mapping a port from a predefined range to the target service's port.

15.What is a multinode cluster and single-node cluster in Kubernetes?

single-node clusters are useful for local development or learning purposes, they lack the scalability, fault tolerance, and high availability features provided by multinode clusters. In a multinode cluster, you can distribute workloads across multiple nodes, handle node failures, and scale resources horizontally to meet the demands of applications running in the cluster.

16.Difference between create and apply in kubernetes?

create is suitable for initial resource creation or when you want to ensure that a resource does not already exist before creating it.

The kubectl apply command is used to create or update resources based on their current state.