Day 37 : Kubernetes Important interview Questions

Rahul SinghRahul Singh
5 min read
  1. What is Kubernetes and why it is important?

    Kubernetes is an open-source, automated container orchestration platform that manages and scales containerized applications. It's important because it automates many of the manual processes involved in deploying, managing, and scaling applications, making them easier to run at scale. Kubernetes helps organizations adopt cloud-native practices, improve DevOps efficiency, and build more resilient and scalable applications

  2. What is difference between docker swarm and Kubernetes?

    Docker Swarm and Kubernetes are both container orchestration platforms, but they differ in complexity and features. Docker Swarm is simpler, easier to set up, and suitable for smaller applications, while Kubernetes is more robust, powerful, and designed for large-scale, complex deployments

  3. How does Kubernetes handle network communication between containers?

    In Kubernetes, containers within the same Pod communicate over localhost, sharing the same network namespace. Pods, however, each have their own unique IP address and can communicate with other pods in the cluster using those IP addresses without NAT or additional configuration.

  4. How does Kubernetes handle scaling of applications?

    Kubernetes scales applications both vertically and horizontally. Vertical scaling increases resources (CPU, memory) on existing pods, while horizontal scaling adds more pods to distribute the load. Kubernetes offers tools like the Horizontal Pod Autoscaler (HPA) and Cluster Autoscaler to automate scaling based on resource usage and cluster capacity.

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

    In Kubernetes, a Deployment is a higher-level abstraction that manages Replica Sets, providing features like rolling updates and rollbacks. A Replica Set, on the other hand, is a lower-level object that ensures a specified number of identical Pods are always running. Deployments use Replica Sets to manage the deployment and scaling of pods, and they offer more advanced capabilities for managing updates and deployments.

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

    In Kubernetes, a rolling update is a deployment strategy that allows you to update your application to a new version while minimizing downtime. It works by gradually replacing old Pods with new ones, ensuring that some instances of the application are always available during the update process.

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

    Kubernetes secures network traffic and access control using a layered approach, including network policies, API authentication and authorization, and admission controllers. Network policies define rules for pod-to-pod communication, ensuring only authorized traffic flows. API access is controlled through authentication (verifying user identity) and authorization (granting specific permissions). Admission controllers validate and potentially modify API requests, further enhancing security.

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

    To achieve high availability with Kubernetes, you can deploy an application with multiple replicas, utilize health probes, and implement a load balancer to distribute traffic across healthy instances. This ensures that even if one instance fails, the application remains accessible to users

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

    In Kubernetes, a namespace is a virtual partition that helps organize and isolate resources within a cluster. If you don't specify a namespace when creating a Kubernetes object, it's automatically placed in the default namespace.

  10. How ingress helps in Kubernetes?

    In Kubernetes, Ingress acts as a gateway for external traffic, managing how incoming requests are routed to services within the cluster. It provides a way to expose HTTP and HTTPS routes to your services, offering features like load balancing, SSL/TLS termination, and name-based virtual hosting.

  11. How ingress helps in Kubernetes?

    In Kubernetes, Ingress acts as a gateway for external traffic, managing how incoming requests are routed to services within the cluster. It provides a way to expose HTTP and HTTPS routes to your services, offering features like load balancing, SSL/TLS termination, and name-based virtual hosting.

  12. Explain different types of services in Kubernetes?

    Kubernetes offers five main types of services, each serving a distinct purpose in exposing applications within a cluster or to the outside world: ClusterIP, NodePort, LoadBalancer, ExternalName, and Headless.

    • ClusterIP: is for internal communication.

    • NodePort: provides simple external access.

    • LoadBalancer: offers external access with load balancing.

    • ExternalName: maps to external DNS names.

    • Headless: provides direct access to Pods.

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

    Kubernetes self-healing is a built-in mechanism that automatically restores system health by identifying and correcting issues without human intervention. This is achieved by continuously monitoring the cluster's state and comparing it to the desired state, taking corrective action when a discrepancy is detected.

    Examples:

    Pod Restart: If a container in a Pod crashes due to a bug, the liveness probe detects the failure, and Kubernetes restarts the container to maintain its running state.

    Replica Replacement: If a node fails, Kubernetes identifies the Pods running on that node and creates new Pods on other healthy nodes to maintain the desired number of replicas, preventing application downtime.

    Service Load Balancing: If one of the Pods serving a web application fails, Kubernetes automatically removes it from the Service's endpoints, ensuring that traffic is still routed to the remaining healthy Pods.

  14. How does the NodePort service work?

    A NodePort service in Kubernetes exposes an application to external clients by opening a specific port on all worker nodes. This allows access to the application by connecting to the IP address of any worker node and the defined NodePort. The NodePort is typically within the range of 30000-32767.

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

    In Kubernetes, a multinode cluster utilizes multiple nodes to run applications, providing scalability, high availability, and resource balancing. A single-node cluster, conversely, runs Kubernetes on a single node, typically used for development or learning purposes.

  16. Difference between create and apply in Kubernetes?

    In Kubernetes, kubectl create is an imperative command used to create a new resource, while kubectl apply is a declarative command that applies a configuration to a resource, creating it if it doesn't exist, and updating it if it does. kubectl create is better for one-off operations, while kubectl apply is preferred for managing resources through manifest files and ensuring a desired state.

0
Subscribe to my newsletter

Read articles from Rahul Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rahul Singh
Rahul Singh