Kubernetes Interview Questions And Answers

1. What is Kubernetes?

Answer: Kubernetes is an open source orchestration system for Docker containers. It manages containerized applications across multiple hosts and provides basic mechanisms for deployment, maintenance, and scaling of applications.

It allows the user to provide declarative primitives for the desired state, for example, “need 5 WildFly servers and 1 MySQL server running”. Kubernetes self-healing mechanisms, such as auto-restarting, re-scheduling, and replicating containers then ensure this state is met. The user just defines the state and Kubernetes ensures that the state is met at all times on the cluster.

2. How do we share Docker containers with different nodes?

Answer: It is possible to share Docker containers on different nodes by using Docker swarm
Docker swarm is a tool which allows IT administrators and developers to create and manage a cluster of swarm nodes within the Docker platform
A swarm consists of two types of nodes: manager node and worker node

3. How is Kubernetes related to Docker?

Answer: It’s a known fact that Docker provides the lifecycle management of containers and a Docker image builds the runtime containers. But, since these individual containers have to communicate, Kubernetes is used. So, Docker builds the containers and these containers communicate with each other via Kubernetes. So, containers running on multiple hosts can be manually linked and orchestrated using Kubernetes.

4. What do you know about clusters in Kubernetes?

Answer: The fundamental behind Kubernetes is that we can enforce the desired state management, by which I mean that we can feed the cluster services of a specific configuration, and it will be up to the cluster services to go out and run that configuration in the infrastructure.
So, as you can see in the above diagram, the deployment file will have all the configurations required to be fed into the cluster services. Now, the deployment file will be fed to the API and then it will be up to the cluster services to figure out how to schedule these pods in the environment and make sure that the right number of pods are running.
So, the API which sits in front of services, the worker nodes & the Kubelet process that the nodes run, all together make up the Kubernetes Cluster. (Best Online Training Institute)

5. What are the different components of Kubernetes Architecture

Answer: The Kubernetes Architecture has mainly 2 components – the master node and the worker node. As you can see in the below diagram, the master and the worker nodes have many inbuilt components within them. The master node has the Kube-controller-manager, Kube-API server, Kube-scheduler, etc. Whereas the worker node has kubelet and Kube-proxy running on each node.

6. What do you understand by the Cloud controller manager?

Answer: The Cloud Controller Manager is responsible for persistent storage, network routing, abstracting the cloud-specific code from the core Kubernetes specific code, and managing the communication with the underlying cloud services. It might be split out into several different containers depending on which cloud platform you are running on and then it enables the cloud vendors and Kubernetes code to be developed without any inter-dependency. So, the cloud vendor develops its code and connects with the Kubernetes cloud-controller-manager while running the Kubernetes.

7. What is the Kube proxy?

Answer: The Kube proxy does simple tasks like TCP, UDP Forwarding, etc. and runs on each of the nodes.
It also shows the services in the Kubernetes API on each node.

8. What is the Kubernetes Node?

Answer: A node is a worker machine in the Kubernetes cluster. A node may be a Virtual Machine (VM) or Host (Physical machine). Each node contains the services necessary to run the pods and is managed by the master Node. The services on a node include the container runtime, kubelet, and Kube-proxy.

9. How to run multiple containers using a single service?

Answer: It is possible to run multiple containers as a single service by using Docker compose
Here, each container runs in isolation but can interact with each other
All Docker Compose files are YAML files

10. How to create a Docker container?

Answer: Task: Create a MySQL Docker container
A user can either build a Docker Image or pull an existing Docker Image (like MySQL) from Docker hub
Now, Docker creates a new container MySQL from the existing Docker Image. Simultaneously, container layer of a read-write filesystem is also created on top of the image layer
Command to create a Docker container: Docker runt –I MySQL
Command to list down the running containers: Docker ps

11. What is a Node Controller?

Answer: The node controller is a Kubernetes master component that manages various aspects of nodes.

The node controller has multiple roles in a node’s life. The first is assigning a CIDR block to the node when it is registered (if the CIDR assignment is turned on).

12. Explain Kubectl?

Answer: Kubectl is a Kubernetes command-line tool that used to deploy and manage applications on Kubernetes.
It is especially useful while inspecting the cluster resources and while creating, updating and deleting the components.

13. What are the functions of the Kube-scheduler?

Answer: The Kube-scheduler is used to assign nodes to the newly created pods.

14. What is the use of a Dockerfile?

Answer: In Docker, Docker File is used for creating Docker Images using the build command
With Docker Image, any user can run the code to create Docker Containers
Once a Docker image is built, it’s uploaded in a Docker registry
From the Docker Registry, users can get the Docker Image and build new containers whenever they want.

15. What is an Active Set?

Answer: The set of rows that a Cursor holds at a single point of time is called an Active Set.

[nextpage title=”Page 04″]

16. What is load-balancing?

Answer: Load-balancing is a service used to expose the services. There are two types of load-balancing in Kubernetes.

Internal load balancing: Used for auto load balancing and allocating the pods with the required configuration.
External load balancing: Directs traffic from external loads to the backend pods.

17. What is Minikube?

Answer: Minikube is a type of tool that makes the Kubernetes easy to run locally. Minikube runs on the single nodes Kubernetes cluster that is inside the virtual machine on your laptop. This is also used by the developers who are trying to develop by using Kubernetes day today.

18. What do you understand by Kubernetes?

Answer: Kubernetes is a type of open-source container. Kubernetes has the potential to hold the container deployment, scaling, and descaling of the container and load balancing. Kubernetes was being developed in the year of 2014. It is also used to manage the Linux containers across the privates, hybrid and cloud environments.

19. What are the advantages of Kubernetes?

Answer: The advantages of using Kubernetes are as follows-
Automated Scheduling- Kubernetes provides an advanced scheduler to launch a container on cluster nodes. Kubernetes’ role is to automate the distribution (scheduling) of application containers across a cluster in an efficient way.
Auto Healing Capabilities – Kubernetes auto-healing mechanisms, such as auto-restarting, re-scheduling, and replicating containers
Automated Rollback – Sometimes you may want to rollback a Deployment; for example, when the Deployment is not stable, such as crash looping. By default, all of the Deployment rollout histories are kept in the system so that you can rollback anytime you want.
Horizontal Scaling – Autoscaling is one of the key features in the Kubernetes cluster. It is a feature in which the cluster is capable of increasing the number of nodes as the demand for service response increases and decreases the number of nodes as the requirement decreases.

[nextpage title=”Page 05″]

20. How to control the resource usage of a POD?

Answer: With requests and limits resource usage of a POD can be controlled.

request: the number of resources being requested for a container. If a container exceeds its request for resources, it may be throttled back down to its request.

limit: an upper cap on the resources a container can use. If it tries to exceed this limit it may be terminated if Kubernetes decides that another container needs the resources. If you’re sensitive to pod restarts, it makes sense to have the sum of all container resource limits equal or less than the total resource capacity for your cluster.

21. What’s the init container and when it can be used?

Answer: init containers will set a stage for you before running the actual POD.

Wait for some time before starting the app Container with a command like sleep 60.
Clone a git repository into a volume.

22. What are the taints and toleration

Answer: Taints allow a node to repel a set of pods. You can set taints on the node and only the POD which have tolerations matching the taints condition will be able to run on those nodes. This is useful in the case when you allocated node for one user and don’t want to run the PODs from other users on that node.

23. What’s the difference between node port and load balancer?

Answer: no port relies on the IP address of your node. Also, you can use the node ports only from the range 30000–32767, on another hand load balancer will have it’s own IP address. All the major cloud providers support creating the LB for you if you specify LB type while creating the service. On bare metal-based clusters, metal is promising.

24. How POD to service communication works?

Answer: PODs are ephemeral their IP address can change hence to communicate with POD in reliable way service is used as a proxy or load balancer. A service is a type of Kubernetes resource that causes a proxy to be configured to forward requests to a set of pods. The set of pods that will receive traffic is determined by the selector, which matches labels assigned to the pods when they were created. K8 provides an internal cluster DNS that resolves the service name.

25. What is a DEFAULT option in a table?

Answer: A column can be given a default value by using the DEFAULT option. This option prevents null values from entering the column if a row is inserted without a value for that column. The DEFAULT value can be a literal, an expression, or a SQL function such as SYSDATE and USER but the value cannot be the name of another column or a pseudo column such as NEXTVAL or CURRVAL.

Service is using a different internal network than the POD network. netfilter rules which are injected by Kube-proxy are used to redirect the request destined for service IP to right POD.

26. How does the service know about healthy endpoints?

Answer: kubelet running on worker node is responsible for detecting the unhealthy endpoints, it passes that information to the API server then eventually this information is passed to Kube-proxy which will adjust the Netfilter rules accordingly.

I highly recommend reading the following series to get a solid understanding of K8 networking.

27. What are pods in Kubernetes?

Answer: A Kubernetes pod is a particular group of containers, which are deployed, in the same host. The Pods can operate on a level, which is higher as compared to the individual containers. That is because the pods have a group of containers, which work together to produce an artifact or to process a particular set of work.

28. What is the significance of Container Orchestration?

Answer: Consider there are 5 to 6 micro-services for a single application performing different tasks and all of them are living within containers. To make sure these containers communicate with one other properly, there is a need for what is called container orchestration, which is built right into Kubernetes.

29. What positive things can you say about clusters within Kubernetes??
Answer: The fundamental thesis behind Kubernetes is it is possible to enforce the desired state management. As a result, it is possible to feed the cluster services a particular configuration. This is going to then go to the cluster services to go out and run the configuration within the [configured] infrastructure. As such, the deployment file is going to have all of the configurations, which required nourishment within the cluster services. The file will also require feeding to the API and so it would mean the cluster services retained the means for scheduling the pods in the appropriate setting and making sure the appropriate pods are running. That way the worker nodes, Kubelet, and the API make up the Kubernetes cluster.

30. Can you discuss how the master node works in Kubernetes?
Answer: Kubernetes master controls the nodes and the containers are within the nodes. These individual containers are stored within pods and inside each pod, based according to the configuration and requirements. Because of this, if the Kubernetes pods have to be deployed, then they may either be accessed using a user interface or command-line tool. These pods would be scheduled to run on the nodes and based on the source requirements, the pods are allocated to see these nodes. The job of the Kube API server is to make certain there is absolute communication between the Kubernetes node and its master components.

31. What is the role of the Kube API server and the Kube scheduler?
Answer: The Kube API server follows the scale-out architecture plan and is the front end which comes to the master node control panel. That would expose all the APIs of the Kubernetes Master Node components. It is responsible for the establishment of communication between the Kubernetes node and the Kubernetes master components. The Kube scheduler is at its core, responsible for the distribution and management of the workload on the worker nodes. It selects the most suitable nodes to run the unscheduled pod depending on the resource needs and keeps track of the overall resource utilization. It makes certain the workload is not scheduled on the nodes that may already be full.

32. Describe the different types of services within Kubernetes?
Answer: Cluster IP: this function exposes the services on a cluster’s internal IP address. It is also the default service type and makes the service only reachable from inside of the cluster.
• Node Port: it is a Cluster IP service to which Node Port service is going to route and is automatically created. It also exposes the service on each Node IP at a static port.<
• External Name: this service maps the contents of the External Name field through returning a CNAME record with that particular value. There is no proxying of any sort, which is set up.
• Load Balancer: this one exposes the services from an external perspective with the use of a cloud provider’s load balancer. The services to which the external load balancer is going to route are automatically created.

33. What is the difference between Kubernetes and Docker Swarm?
Answer: Consider a scenario – You have just joined a new organization as a developer. You will now have to set up the project with the assistance of a fellow developer. He suggests you follow certain steps for setting up the required environment and then start the project deployable like a WAR. You do the same, but keep getting some or other issues regarding environment configuration. Maybe even your fellow developer has forgotten some configuration property he might have set. Well, you are stuck in such a situation. This is known as Dependency Hell. Another similar scenario of this dependency hell is – The application is running on my dev machine but not in production. Don’t know what issue is. There are also other scenarios like the Matrix of Hell. But this is mostly related to DEVOPS people. Docker to the rescue.
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.

34. Explain the role of CRD (Custom Resource Definition) in K8?
Answer: A custom resource is an extension of the Kubernetes API that is not necessarily available in a default Kubernetes installation. It represents a customization of a particular Kubernetes installation. However, many core Kubernetes functions are now built using custom resources, making Kubernetes more modular.

35. How to troubleshoot if the POD is not getting scheduled?
Answer: There are many factors that can lead to unstartable POD. A most common one is running out of resources, use commands like kubectl describe -n to see the reason why POD is not started. Also, keep an eye on kubectl get events to see all events coming from the cluster.

36. How to make Prometheus HA?
Answer: You may run multiple instances of Prometheus HA but grafana can use only of them as a data source. You may put a load balancer in front of multiple Prometheus instances, use sticky sessions and failover if one of the Prometheus instances dies. This makes things complicated. Thanos is another project which solves these challenges.

37. What are the uses of Google Kubernetes Engine?
Answer: The followings are the uses of the Google Kubernetes Engine:
Create or resize Docker container clusters
Creates container pods, replication controller, jobs, services or load balancer
Resize application controllers
Update and upgrade container clusters
Debug container clusters.

38. What is a node in Kubernetes?
Answer: A node is a worker machine in Kubernetes, previously known as a minion. A node may be a VM or physical machine, depending on the cluster. Each node has the services necessary to run pods and is managed by the master components. The services on a node include Docker, kubelet, and Kube-proxy.

39. Whats is the difference between Kubernetes and Docker Swarm?
Answer: Docker already has its own orchestration manager named Docker Swarm. Docker Swarm is much easier to use and does not require to learn any new tool or technology since its part of Docker. Kubernetes helps manage more complex container deployments while Docker Swarm offers a simple approach to get started with. Kubernetes helps support higher demands production environments and is used by many large organizations.

40. Why we need service mesh?
Answer: A service mesh ensures that communication among containerized and often ephemeral application infrastructure services is fast, reliable, and secure. The mesh provides critical capabilities including service discovery, load balancing, encryption, observability, traceability, authentication and authorization, and support for the circuit breaker pattern.

41. Explain about Pragma Exception_Init?
Answer: It allows us to handle Oracle Pre Defined Messages wherein we can replace our own Message. We can, therefore, instruct the compiler to link the user-specified message to Oracle Pre Defined Message during Compilation Time.
Syntax: Pragma Exception_Init (Exception_Name, Error_Code).

42. Difference between the helm and K8 operator?
Answer: An Operator is an application-specific controller that extends the Kubernetes API to create, configure and manage instances of complex stateful applications on behalf of a Kubernetes user. It builds upon the basic Kubernetes resource and controller concepts, but also includes domain or application-specific knowledge to automate common tasks better managed by computers. On the other hand, the helm is a package manager like yum or apt-get.

43. How to monitor the K8 cluster?
Answer: Prometheus is used for K8 monitoring. The Prometheus ecosystem consists of multiple components.

main Prometheus server which scrapes and stores time-series data
client libraries for instrumenting application code
a push gateway for supporting short-lived jobs
special-purpose exporters for services like HAProxy, StatsD, Graphite, etc.
an alert manager to handle alerts
various support tools

44. What is the meaning of Kubernetes?
Answer: Kubernetes (commonly referred to as “K8s”) is an open-source system for automating deployment, scaling and management of containerized applications that were originally designed by Google and donated to the Cloud Native Computing Foundation.
Docker Kubernetes Interview Questions For Experienced

45. What is Docker and what does it do?
Answer: Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

46. What is Heapster?
Answer: The Heapster lets you do the container cluster monitoring. It lets you do cluster-wide monitoring and event data aggregation. It has native support for Kubernetes.

47. Give a description of Orchestration when it comes to software?
Answer: The service orchestration alludes to the integration of multiple services for them to allow the automation of the processes or synchronizing the information on a timely basis. As such, the point-to-point integration may be used as one such path for the least amount of resistance.

48. What are labels and annotations when it comes to Kubernetes?</strong
Answer: 
A label in Kubernetes is a meaningful type of tag word, which is attached to the Kubernetes objects in order to make them as part of a group. The Labels may be used for working on different instances for the purposes of management or even routing purposes. For one, the controller-based objects may use the labels to mark the pods they would operate on. The microservices use labels to understand the structure of the backend pods they route the requests toward. The labels are some of the key-value pairs. Each unit may have more than one label but each unit may only have one entry for each of the keys. The key is most commonly utilized as an identifier or unique ID. However, at the same time may classify the objects using other criteria according to public access, application versions, and the developmental stages.

The annotations attach arbitrary key-value information to the Kubernetes object. The levels, however, ought to be utilized for meaningful information in order to match a pod with selection criteria, so the annotations have less structured data. The annotations are a means for adding more metadata to the object, which is not helpful for selection purposes.

49. Give a description of what a Namespace is when it comes to Kubernetes?
Answer: The Namespace can be used in different environments with different users, who operate across a number of projects or even teams. They refer to the process of dividing the cluster resources between the different utilizations. For the future iterations, the objects within a similar Namespace would have a similar access control policy.

50. Can you please tell me what some of the main advantages of Kubernetes is?
Answer: With container orchestration tool Kubernetes, it has become easy for one to handle the containers. You may respond to different customer demands by deploying the applications in a faster manner and in a way, which is predictable. So there is:

  • Automated rollback
  • Automated scheduling
  • Horizontal scaling
  • Auto healing capabilities

Note: Browse Latest Kubernetes Interview Questions and Kubernetes tutorial. Here you can check Kubernetes Training details and Kubernetes training videos for self learning. Contact +91 988 502 2027 for more information.

Leave a Comment

FLAT 30% OFF

Coupon Code - GET30
SHOP NOW
* Terms & Conditions Apply
close-link