Kubernetes Interview Questions
Kubernetes Interview Questions
Kubernetes Q&A
1. What is Kubernetes and why it is important?
Kubernetes is an open-source platform used to automate the deployment, scaling, and management
of containerized applications. It is like a traffic controller for containerized applications. It ensures
that these applications are running efficiently and reliably, by managing their deployment, scaling,
and updating processes.
Kubernetes is important because it makes much easier to deploy and manage complex applications
across different environments and infrastructures. By providing a consistent platform for
containerized applications, Kubernetes allows developers to focus on building and improving their
applications, rather than worrying about the underlying infrastructure. Additionally, Kubernetes
helps organizations to achieve greater efficiency, scalability, and flexibility, which can result in
significant cost savings and faster time-to-market.
8. Can you give an example of how Kubernetes can be used to deploy a highly available
application?
Let's say you have a web application that needs to be highly available, meaning it can't go down if
one or more of its components fail. You can use Kubernetes to deploy this application in a highly
available manner by doing the following:
Create a Kubernetes cluster with multiple nodes (virtual or physical machines) that are spread
across multiple availability zones or regions.
Create a Kubernetes Deployment for your application, which specifies how many replicas
(copies) of your application should be running at any given time.
Create a Kubernetes Service for your application, which provides a stable IP address and DNS
name for clients to access your application.
Use a Kubernetes Ingress to route traffic to your application's Service, and configure the Ingress
to load-balance traffic across all the replicas of your application.
By following these steps, Kubernetes will automatically monitor your application and ensure that the
specified number of replicas are always running, even if one or more nodes fail. Clients will be able
to access your application through the stable IP address and DNS name provided by the Service, and
the Ingress will distribute traffic across all available replicas to ensure that the application remains
highly available.
9. What is namespace is Kubernetes? Which namespace any pod takes if we don't specify any
namespace?
Namespace can be recognised as a virtual cluster inside your Kubernetes cluster. We can have
multiple namespaces inside a single Kubernetes cluster, and they are all logically isolated from each
other. They can help us and our teams with organization, security, and even performance!
There are two types of Kubernetes namespaces: Kubernetes system namespaces and custom
namespaces.
If we don't specify a namespace for a pod, it will be created in the default namespace by default. This
is the namespace that Kubernetes creates automatically when we set up a cluster, and it is used for
objects that do not have a specific namespace specified.
Here are four default namespaces Kubernetes creates automatically
default
Kube-system
Kube-public
Kube-node-lease
12. 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.
Ex: Suppose we have a web application deployed in Kubernetes with 2 replicas. Each replica runs in
its own container. Kubernetes monitors the health of each container by sending periodic requests to
the application's endpoints.
If one of the replicas fails, Kubernetes detects it by monitoring the responses to the health check
requests. It then terminates the failed container and starts a new one to replace it, ensuring that the
total number of replicas is always maintained. The replacement container is created from the same
image and configuration as the original, which helps to ensure consistency across replicas.
Kubernetes also supports rolling updates, which allow you to update your application without
causing downtime. When you update your application, Kubernetes creates a new set of replicas with
the updated code and configuration. It then gradually replaces the old replicas with the new ones,
ensuring that the application remains available during the update process.