Day 37 Kubernetes Important interview Questions.

Day 37 Kubernetes Important interview Questions.

Day 37 of #90daysofdevops

Hey Techies! Welcome to this blog

In this blog, we are going to start with Kubernetes Important interview Questions.

1.What is Kubernetes and why it is important?

Kubernetes (also known as k8s or “Kube”) is an open-source container orchestration platform that automates many of the manual processes involved in deploying, managing, and scaling containerized applications.

Why it is important?

Containers are a good and easy way to bundle and run your applications. In a production environment, you need to manage the containers that run the applications and ensure that there is no downtime. For example, if a container goes down, another container needs to start.

You have to ssh to the server, then launch the container, again ssh to another server launch another one. maintain if any container fails… then again check and launch a new container.

Wouldn’t it be easier if this behavior was handled by a system?

That’s how Kubernetes comes to the rescue! Kubernetes provides us an interface to run distributed systems smoothly. It takes care of scaling and failover for your application, provides deployment patterns, and more.

2.What is difference between docker swarm and kubernetes?

  1. How is Kubernetes handle network communication between containers?

Kubernetes manages container networking through a flat, unified network model. Each pod in Kubernetes gets its own unique IP address, and containers within the same pod can communicate with each other using localhost. For communication between pods, Kubernetes uses a container network interface (CNI) plugin, which enables seamless and efficient communication by assigning unique IP addresses to each pod and handling network routing.

  1. How does Kubernetes handle scaling of applications?

Kubernetes provides both manual and automated scaling options. Horizontal Pod Autoscaling (HPA) automatically adjusts the number of pod replicas based on observed CPU utilization or other custom metrics. Vertical Pod Autoscaling (VPA) adjusts the CPU and memory resources allocated to a pod dynamically. Additionally, Kubernetes supports manual scaling through the kubectl scale command, allowing users to adjust the number of replicas for a specific deployment.

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

A Kubernetes Deployment is a higher-level abstraction that manages ReplicaSets and provides declarative updates to applications. It allows you to describe the desired state of an application and handles rolling updates and rollbacks. A ReplicaSet, on the other hand, ensures that a specified number of pod replicas are running at all times. In essence, a Deployment is a more user-friendly and powerful tool for managing application lifecycle compared to a ReplicaSet.

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

Rolling updates in Kubernetes involve gradually replacing instances of the old application version with the new one, ensuring continuous availability. During a rolling update, new pods are created with the updated version, and once they are ready, old pods are gradually terminated. This process avoids downtime and allows the application to seamlessly transition to the new version without service interruption.

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

Kubernetes employs various mechanisms for network security and access control. Network Policies define rules for controlling communication between pods. Role-Based Access Control (RBAC) regulates access to Kubernetes resources based on user roles and permissions. Service Accounts manage pod identities and their access scopes. Together, these features help secure the cluster and control communication between applications.

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

To deploy a highly available application in Kubernetes, you can use multiple replicas of your application components distributed across different nodes. Employing features like Deployments, StatefulSets, and LoadBalancers ensures redundancy, fault tolerance, and even distribution of traffic. Additionally, using persistent storage for stateful applications ensures data persistence in the event of pod failures.

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

A Kubernetes namespace is a way to divide cluster resources between multiple users, teams, or projects. If a pod doesn't specify a namespace, it is placed in the default namespace. The default namespace is where resources are created if no namespace is explicitly specified during deployment.

  1. How ingress helps in kubernetes?

In Kubernetes, Ingress is an API object that provides external access to services within a cluster. It acts as a traffic manager, routing external requests to the appropriate services based on defined rules. Ingress allows the definition of rules for path-based routing, SSL termination, and load balancing, providing a centralized and flexible way to manage external access to applications.

  1. Explain different types of services in kubernetes?

Kubernetes supports various service types, including ClusterIP, NodePort, LoadBalancer, and ExternalName.

  • ClusterIP: Exposes the service only within the cluster.

  • NodePort: Exposes the service on a static port on each node.

  • LoadBalancer: Exposes the service externally using a cloud provider's load balancer.

  • ExternalName: Redirects the service to a DNS name.

Each service type caters to different use cases and requirements.

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

Self-healing in Kubernetes refers to the system's ability to automatically recover from failures. If a pod or node fails, Kubernetes can automatically reschedule the pod to a healthy node. Additionally, features like liveness and readiness probes help identify and address issues with individual containers within a pod, ensuring continuous operation.

  1. How does Kubernetes handle storage management for containers?

Kubernetes manages storage using Persistent Volumes (PVs) and Persistent Volume Claims (PVCs). PVs represent physical storage resources in the cluster, while PVCs are requests for storage by users. Pods can use PVCs to access persistent storage, allowing data to persist even if a pod is rescheduled to a different node.

  1. How does the NodePort service work?

NodePort is a service type in Kubernetes that exposes the service on a static port on each node in the cluster. When external traffic reaches any node on that port, the NodePort service forwards it to the corresponding service within the cluster. This provides external access to services without requiring an external load balancer.

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

A multinode cluster in Kubernetes consists of multiple worker nodes, each running containerized applications. It allows for distribution of workloads, redundancy, and scalability. In contrast, a single-node cluster runs all Kubernetes components, including worker and control plane, on a single machine. Single-node clusters are typically used for development or testing purposes.

  1. Difference between create and apply in kubernetes?

In Kubernetes, kubectl create is used to create a resource based on a file or command-line arguments, while kubectl apply is used to either create a new resource or update an existing one. apply is preferred for managing resources over time because it can apply incremental changes to resources, making it more suitable for declarative configuration and continuous delivery workflows.

That's it! You've just completed the task. 🎉

Thank you so much for taking the time to read till the end! Hope you found this blog informative and helpful.

Feel free to explore more of my content, and don't hesitate to reach out if need any assistance from me or in case of you have any questions.

Happy Learning!

~kritika :)

Connect with me: linkedin.com/in/kritikashaw