Basic Kubernetes Interview Questions
1. Explain Kubernetes Architecture.
Kubernetes is an open-source container deployment and administration platform. It offers container orchestration, container runtime, container-centric infrastructure orchestration, balance of load, self-healing mechanisms, and service discovery. A Kubernetes cluster has several control planes and one or more worker nodes.
2. Explain the concept of Container Orchestration.
Container orchestration is a tool that developers may use anywhere there are containers to automate the life cycle management of the containers. It provides a automatic deployment, scaling, and management of containerized applications so that the developers do not have any worry about that the underlying infrastructure.
3. What is a Pod in Kubernetes?
A cluster of one or more Linux containers makes up a Kubernetes pod, the smallest unit of a Kubernetes application. From the more common scenario of a single container to an advanced use case with numerous tightly coupled containers within a pod, this basic structure allows for an array of designs.
kubectl get pods -n <namespace-name>
4. How does Kubernetes handle container scaling?
To automatically scale the workload to match demand, a Horizontal Pod Autoscaling in Kubernetes updates a workload resource (such a deployment or stateful set). Horizontal scaling indicates that more pods are added in response to an increase in load.
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: my-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment # or StatefulSet, or ReplicaSet, depending on your workload
name: my-deployment
minReplicas: 3
maxReplicas: 5
metrics:
– type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 65
5. What is Kubelet?
Kubelet is an important component of Kubernetes that manages containers within pods on a node. It registers the node with the control plane and provides resource information. Kubelet keeps an eye on container health and responds to problems—lik isnces of pods that contain a containerized application. Deployments can help to efficiently scale the number of replica pods, enable the rollout of updated code in a controlled manner, or roll back to the earlier deployment version if necessary.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
– name: my-nginx
image: nginx:latest
resources:
limits:
memory: “125Mi”
cpu: “750m”
ports:
– containerPort: 80
7. Explain the difference between a StatefulSet and a Deployment.
StatefulSet |
Deployment |
---|---|
A collection of identical stateful pods are handled by the resource is called StatefulSet. | This resource controls identical pods deployment. |
Statefulset helpful in managing stateful applications that need persistent storage with a dependable network ID. | It enables you to control your application’s state and ensure that the right number of replicas are always running. |
8. What is a Service in Kubernetes?
The idea of the Service is to group a set of Pod endpoints into a single resource. We can configure various ways to access the grouping. By default, we can get a stable cluster IP address that the clients inside the cluster can use to contact Pods in Service.
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
Tomcat: deploymentapp
ports:
– protocol: TCP
port: 80
targetPort: 8080
9. How does Kubernetes manage configuration?
Kubernetes employs ConfigMaps and Secrets to manage configuration. ConfigMaps store non-sensitive setup data, while Secrets handles sensitive information like passwords. These resources have different configurations from the application code, making updates easier. ConfigMaps have key-value pairs for different settings that can be accessed as environment variables or mounted files. Sensitive data is securely stored in Secrets, which are applied to the cluster using kubectl. Both ConfigMaps and Secrets are defined in YAML files and applied to the cluster using kubectl. Kubernetes tracks changes in these resources, triggering updates in Pods without needing changes to the application code.
10. Describe the role of a Master node in Kubernetes.
Kubernetes master node components can be run within Kubernetes itself, as a set of containers within the dedicated pod. The master node is responsible for cluster management and for providing the API that is used to configure and manage resources within the Kubernetes cluster.
11. What is the role of the kube-proxy in Kubernetes and how does it facilitate communication between Pods?
The networking part of Kubernetes that enables communication between pods & services is called Kube-proxy, and it may be installed on any cluster node. Its major function is to maintain network rules for service-to-pod mapping, which provides communication to and from Kubernetes clusters.
Kubernetes Interview Questions and Answers
Kubernetes is a powerful open-source platform for automating deployment, scaling, and operations of application containers across clusters of hosts. It provides a container-centric infrastructure that is efficient, making it a leading choice for managing complex applications. Derived from the Greek word meaning “captain,” “helmsman,” or “governor,” Kubernetes has become indispensable in the world of cloud-native applications. With its automation, scalability, and ease of deployment, Kubernetes offers unparalleled efficiency for developers and operations teams alike. Kubernetes is extensively used by top companies like Google, Red Hat, VMware, IBM, and many others due to its robust features and exceptional performance.
In this article, we will provide the Top 40 Kubernetes Interview Questions and Answers tailored for both freshers and experienced professionals. Here, we cover everything, including fundamental Kubernetes concepts, Kubernetes architecture, pods, StatefulSets, Monitoring and Logging, deployment strategies, and more, that will surely help you crack DevOps interviews.