Top 7+ Kubernetes interview questions for experienced professionals | Part-1

Manoj Kumar
7 min readMar 12, 2023

Kubernetes interview questions and answers |Kubernetes technical interview questions for DevOps Engineer | Senior DevOps position

Question-1 : Can you walk us through the steps you would take to deploy an application in a Kubernetes cluster?

Deploying an application in a Kubernetes cluster involves several steps that ensure the application runs smoothly and is easily accessible. The first step is to package the application in a Docker image, which is a format that allows the application to be run as a container. This image should contain all the dependencies and configurations needed for the application to run properly. Next, the Docker image is pushed to a container registry such as Docker Hub or Google Container Registry, making it accessible to the Kubernetes cluster.

Once the Docker image is in the registry, the next step is to create a Kubernetes deployment. This involves writing a YAML file that describes the desired state of the application, such as the number of replicas and the Docker image to use. The deployment is then applied to the cluster using the kubectl apply command. After the deployment has been applied, it can be verified using the kubectl get command to ensure that the desired number of replicas are running and available.

Question-2: Can you explain how you would set up a highly available Kubernetes cluster?

Setting up a highly available Kubernetes cluster requires careful planning and attention to detail. To ensure high availability, it’s important to choose a cloud provider (AWS, Azure, GCP or on-premises) infrastructure that supports redundancy and fault tolerance. The cluster should have a minimum of three nodes to allow for redundancy in case one or two nodes fail. Setting up a load balancer to distribute traffic across the nodes and configuring Kubernetes to use a highly available etcd cluster to store configuration data are also important steps. Additionally, monitoring and alerting tools should be set up to quickly identify and respond to issues. Finally, having a disaster recovery plan in place with regular backups and procedures for restoring the cluster is critical. Overall, with proper planning and attention to detail, a highly available Kubernetes cluster can provide a reliable and scalable platform for deploying and managing containerized applications.

Question-3: Can you discuss your experience with using Kubernetes network plugins such as Calico, Flannel, or Weave Net?

Kubernetes network plugins, such as Calico, Flannel, and Weave Net, are essential components of a Kubernetes cluster that enable communication between the various components of the cluster, such as pods, nodes, and services.

Calico is a popular network plugin that provides network security, network segmentation, and network policy enforcement. It is known for its high performance and ease of use, making it a popular choice for many Kubernetes deployments.

Flannel is another popular network plugin that provides network overlay support for Kubernetes. It is known for its simplicity, as it does not require a lot of configurations, and for its support for many different networking backends, such as VXLAN, host-gw, and AWS VPC.

Weave Net is a third popular network plugin that provides a fully featured network fabric for Kubernetes. It is known for its support for multiple networking modes, such as VLAN and overlay networking, and for its support for encrypted and unencrypted network traffic.

Question-4: How do you handle rolling updates in a Kubernetes cluster? Can you discuss the strategies you have used to manage application updates?

Rolling updates in a Kubernetes cluster refers to the process of updating an application without disrupting its availability to users. This is typically achieved by gradually updating the application pods one-by-one, rather than updating all of them at once.

There are several strategies that can be used to manage rolling updates in a Kubernetes cluster:

  1. RollingUpdate: This is the default update strategy in Kubernetes, and involves updating the pods one-by-one, starting with a single pod, and proceeding to the next one only after the first one has successfully been updated.
  2. Recreate: In this strategy, all pods are deleted and recreated at once, which results in a brief disruption in service availability.
  3. Blue-Green Deployment: This involves running two versions of the application in parallel, with one version being updated while the other remains unchanged. When the update is complete, traffic is redirected to the updated version.
  4. Canary Deployment: This involves gradually rolling out the updated application to a small subset of users, and gradually increasing the percentage of users who receive the update over time. This allows for testing and validation of the updated application before it is rolled out to all users.

Question-5: Can you explain how you would configure resource limits and requests in a Kubernetes cluster to ensure that resources are used efficiently?

Configuring resource limits and requests in a Kubernetes cluster is an important aspect of ensuring that resources are used efficiently. Resource limits and requests are used to control the amount of CPU, memory, and other resources that a pod can use.

To configure resource limits and requests, the following steps can be followed:

1.Define the resource limits and requests for the pod in the pod specification. The resource limits define the maximum amount of resources that a pod can use, while the resource requests define the minimum amount of resources that a pod requires to function correctly.

2. Specify the resource limits and requests in the pod specification using the ‘limits’ and ‘requests’ fields, respectively. For example, to specify a limit of 500m CPU and 256MB of memory, the following can be added to the pod specification:

resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi

3. Verify that the resource limits and requestsusing tools such as the Kubernetes Dashboard, kubectl top, or a third-party monitoring tool.

4. Tune the resource limits and requests based on the resource utilization of the pods. If a pod is consistently hitting its resource limits, it may be necessary to increase the limits, while if a pod is consistently underutilizing its resources, it may be possible to reduce the limits or requests.

Question-6:Can you explain how you would use Kubernetes role-based access control (RBAC) to secure a cluster and its resources?

Role-based access control (RBAC) is an important security feature in Kubernetes that allows administrators to manage and control access to the cluster and its resources. RBAC allows administrators to define who can perform specific actions on specific resources within a cluster.

Here are the steps to set up RBAC in a Kubernetes cluster:

  1. Define roles: Roles are sets of permissions that can be assigned to users or service accounts. Roles can be defined for different namespaces in a cluster, or for the entire cluster.
  2. Define role bindings: Role bindings associate a role with a user or service account. Role bindings can be defined for different namespaces in a cluster, or for the entire cluster.
  3. Assign roles to users and service accounts: Once roles have been defined and role bindings have been created, administrators can assign roles to users and service accounts. This can be done using the Kubernetes API or through the use of kubectl.
  4. Validate RBAC rules: After RBAC rules have been defined and role bindings have been created, administrators can validate the RBAC rules by attempting to perform actions with a user or service account that has been assigned a role. This can be done using the Kubernetes API or through the use of kubectl.
  5. Monitor and enforce RBAC rules: Administrators should regularly monitor and enforce RBAC rules to ensure that they are functioning correctly and that users and service accounts have the correct level of access to the cluster and its resources.

Question-7: Explain Kubernetes architecture and its components.

Kubernetes is a highly scalable and extensible open-source platform for managing containerized applications. The Kubernetes system consists of several components that work together to provide a complete solution for deploying, scaling, and managing containerized applications.

Here are some of the key components in a Kubernetes cluster:

  1. API server: The API server is the central component in a Kubernetes cluster. It is responsible for managing the state of the cluster and exposing the Kubernetes API. The API server is the endpoint for all requests to the Kubernetes cluster.
  2. Etcd: Etcd is a distributed key-value store that is used to store the configuration data for the Kubernetes cluster. This data includes information about nodes, pods, and services.
  3. Controller Manager: The controller manager is responsible for managing the state of the cluster. It watches the API server for changes and takes action to ensure that the desired state is maintained.
  4. Scheduler: The scheduler is responsible for scheduling pods to run on specific nodes in the cluster. It takes into account the resource requirements of each pod, as well as the available resources on each node, to determine the best node for each pod to run on.
  5. Kubelet: The kubelet is the agent that runs on each node in the cluster. It is responsible for ensuring that the containers in a pod are running and healthy.
  6. Kube-proxy: Kube-proxy is the network proxy that runs on each node in the cluster. It is responsible for routing traffic from the network to the correct pods in the cluster.
  7. Container Runtime: The container runtime is responsible for pulling the images and starting containers. Kubernetes supports multiple container runtimes, including Docker, rkt, and CRI-O.
Kubernets Architecture Diagram (reference from datacommcloud)

How do you manage secrets and configuration in a Kubernetes cluster? Can you discuss your experience with tools such as ConfigMap and Secret?

  1. Can you discuss your experience with using Kubernetes auto-scaling, such as horizontal pod auto-scaling (HPA) or vertical pod auto-scaling (VPA)?
  2. Can you explain how you would use Kubernetes role-based access control (RBAC) to secure a cluster and its resources?
  3. Can you discuss how you would diagnose and debug issues with a Kubernetes application, such as slow performance or resource utilization problems?
  4. Can you walk us through a recent project you worked on using Kubernetes, highlighting your role and responsibilities and the key challenges you faced?

I hope you enjoyed reading this article, feel free to add your comments, thoughts or feedback and please get in touch on LinkedIn: Manoj M Kumar | LinkedIn

Manoj Kumar

--

--

Manoj Kumar

Passionate about cloud security and sharing experience with friends and DevOps engineer.