Kubernetes Important interview Questions

Photo by Growtika on Unsplash

Kubernetes Important interview Questions

Questions

  1. What is Kubernetes and why it is important?
  • Kubernetes is a container orchestration tool created by the company Google.

  • Kubernetes services provide load balancing and simplify container management on multiple hosts. They make it easy for an enterprise's apps to have greater scalability and be flexible, portable and more productive.

  1. What is the difference between docker swarm and Kubernetes?
  • Docker Swarm is a lightweight, easy-to-use orchestration tool with limited offerings compared to Kubernetes.

  • In contrast, Kubernetes is complex but powerful and provides self-healing, auto-scaling capabilities out of the box.

  1. How does Kubernetes handle network communication between containers?
  • From a network standpoint, each container within the pod shares the same networking namespace. This gives each container access to the same network resources, such as the pod's IP address. Containers within the same pod can also communicate with each other over localhost.
  1. How does Kubernetes handle the scaling of applications?
  • The Kubernetes autoscaling mechanism uses two layers: Pod-based scaling—supported by the Horizontal Pod Autoscaler (HPA) and the newer Vertical Pod Autoscaler (VPA). Node-based scaling—supported by the Cluster Autoscaler.
  1. What is a Kubernetes Deployment and how does it differ from a ReplicaSet?
  • A Kubernetes Deployment tells Kubernetes how to create or modify instances of the pods that hold a containerized application.

  • A ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features.

  1. Can you explain the concept of rolling updates in Kubernetes?
  • RollingUpdate implements automated, rolling updates for the Pods in the StatefulSet. RollingUpdate causes the controller to delete and recreate each of its Pod, and each Pod one at a time. It waits until an updated Pod is running and ready before to updating its predecessor.
  1. How does Kubernetes handle network security and access control?
  • Kubernetes ships an integrated Role-Based Access Control (RBAC) component that matches an incoming user or group to a set of permissions bundled into roles. These permissions combine verbs (get, create, delete) with resources (pods, services, nodes) and can be namespace-scoped or cluster-scoped.
  1. Can you give an example of how Kubernetes can be used to deploy a highly available application?
  • Can you give an example of how Kubernetes can be used to deploy a highly available application?
  1. What is a namespace in Kubernetes? Which namespace any pod takes if we don't specify any namespace?
  • Namespaces are a way to organize clusters into virtual sub-clusters — they can be helpful when different teams or projects share a Kubernetes cluster. Any number of namespaces are supported within a cluster, each logically separated from others but with the ability to communicate with each other.

  • The default namespace will be used if we don't specify any specific namespace.

  1. How does ingress help in Kubernetes? -The Ingress concept lets you map traffic to different backends based on rules you define via the Kubernetes API. An API object that manages external access to the services in a cluster, typically HTTP.

  2. Explain different types of services in Kubernetes?

  • There are five types of Services:

  • ClusterIP (default): Internal clients send requests to a stable internal IP address.

  • NodePort: Clients send requests to the IP address of a node on one or more nodePort values that are specified by the Service.

  • LoadBalancer: Clients send requests to the IP address of a network load balancer.

  • ExternalName: Internal clients use the DNS name of a Service as an alias for an external DNS name.

  • Headless: You can use a headless service when you want a Pod grouping, but don't need a stable IP address.

  1. Can you explain the concept of self-healing in Kubernetes and give examples of how it works?
  • Self-healing is a feature provided by the Kubernetes open-source system. If a containerized app or an application component fails or goes down, Kubernetes re-deploys it to retain the desired state. Kubernetes provides self-healing by default.
  1. How does Kubernetes handle storage management for containers?
  • In Kubernetes, the most basic type of storage is non-persistent—also known as ephemeral. Each container has ephemeral storage by default—this storage uses a temporary directory on the machine that hosts the Kubernetes pod. It is portable, but not durable. Kubernetes supports multiple types of persistent storage.
  1. How does the NodePort service work?
  • The NodePort service serves as the external entry point for incoming requests for your app. The assigned NodePort is publicly exposed in the Kube proxy settings of each worker node in the cluster. Every worker node starts listening on the assigned NodePort for incoming requests for the service.
  1. What is a multinode cluster and a single-node cluster in Kubernetes?
  • A single cluster is a basic infrastructure platform. Everything that needs to be executed is deployed to the current Kubernetes cluster.

  • Multiple Kubernetes clusters make up a Kubernetes multi-cluster environment. They can be set up in various ways – within the confines of a single physical host, with a variety of hosts in the same data center, or using the same cloud provider in multiple geographies.

  1. Difference between create and apply in Kubernetes?
  • kubectl apply command can be used to update an already existing deployment, kubectl create but cannot. kubectl create can only be used when the resource does not already exist.