Skip to main content

Command Palette

Search for a command to run...

Kubernetes Interview Questions

Day37

Published
5 min readView as Markdown
Kubernetes Interview Questions
  1. What is Kubernetes and why is it important?

    Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It's important because it simplifies and streamlines container management, ensuring that applications are highly available, scalable, and reliable. Kubernetes abstracts the underlying infrastructure, making it easier to manage containers across different environments.

  2. What is the difference between Docker Swarm and Kubernetes?

    Docker Swarm and Kubernetes are both container orchestration tools, but Kubernetes is more feature-rich and widely adopted. Kubernetes offers more advanced scheduling, scaling, and management capabilities, while Docker Swarm is simpler and better suited for smaller-scale deployments. Kubernetes has a larger ecosystem and community support.

  3. How does Kubernetes handle network communication between containers?

    Kubernetes manages network communication using a container network model (CNI). Each pod gets its own IP address, and containers within a pod can communicate over localhost. Kubernetes also supports services and load balancers to expose pods to the network, and it provides network policies for controlling traffic between pods.

  4. How does Kubernetes handle scaling of applications?

    Kubernetes supports horizontal and vertical scaling. Horizontal scaling is achieved through ReplicaSets or Deployments, which create additional pods as needed. Vertical scaling involves changing the resource limits of a pod. Kubernetes can also auto-scale based on metrics like CPU and memory usage.

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

    A Kubernetes Deployment is a higher-level abstraction that manages ReplicaSets. It allows declarative updates to applications, supports rollbacks, and provides strategies for rolling updates. A ReplicaSet, on the other hand, ensures a specified number of pod replicas are running at all times.

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

    Rolling updates in Kubernetes involve gradually replacing old pods with new ones to update an application without downtime. This is achieved by creating a new ReplicaSet with the updated containers and gradually scaling it up while scaling down the old ReplicaSet.

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

    Kubernetes provides Network Policies to control traffic between pods. It also offers Role-Based Access Control (RBAC) to define who can access and manipulate resources within the cluster. Authentication and authorization are configurable through various plugins.

  8. 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 pods, distribute them across different nodes, and set up load balancers or services to balance traffic. You can also use features like StatefulSets for stateful applications and configure health checks for automatic recovery.

  9. What is a namespace in Kubernetes? Which namespace does any pod take if we don't specify any namespace?

    A namespace in Kubernetes is a logical partition within a cluster that allows you to isolate and organize resources. If you don't specify a namespace for a pod, it is created in the default namespace.

  10. How does Ingress help in Kubernetes?

    Ingress is an API object in Kubernetes that manages external access to services within the cluster. It provides HTTP and HTTPS routing, load balancing, and can be used to expose multiple services through a single entry point. Ingress controllers handle the actual traffic routing.

  11. Explain different types of services in Kubernetes?

    There are four types of services in Kubernetes:

  • ClusterIP: Exposes a service internally within the cluster.

  • NodePort: Exposes a service on a specific port of each node, making it accessible from outside the cluster.

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

  • ExternalName: Maps a service to an external DNS name.

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

    Self-healing in Kubernetes means that the system automatically detects and recovers from failures. For example, if a pod becomes unhealthy, Kubernetes can restart it. If a node fails, the pods are rescheduled onto healthy nodes. Kubernetes continually monitors the desired state and takes actions to maintain it.

  2. How does Kubernetes handle storage management for containers?

    Kubernetes uses Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) to manage storage. PVCs request storage resources, and PVs provide the actual storage. Storage classes define the type and location of storage. Containers can then use PVCs to access persistent storage.

  3. How does the NodePort service work?

    NodePort is a service type that exposes a service on a static port on each node's IP address. It allows external access to the service by connecting to any node's IP and the assigned port. The traffic is then forwarded to the service within the cluster.

  4. What is a multi-node cluster and single-node cluster in Kubernetes?

    A multi-node cluster consists of multiple physical or virtual machines (nodes) that work together to run containerized applications. A single-node cluster, as the name suggests, runs all Kubernetes components on a single machine, primarily for development or testing purposes. Production clusters typically have multiple nodes for high availability.

  5. Difference between create and apply in Kubernetes?

    • kubectl create: This command creates a new resource based on the YAML or JSON configuration provided. If the resource already exists, it will return an error.

    • kubectl apply: This command creates or updates a resource based on the configuration provided. If the resource exists, it updates it; if it doesn't exist, it creates it. It is a preferred way for managing resources as it allows for declarative configuration management.