Rakesh Jain
Rakesh Jain

@devops_tech

32 Tweets 3 reads Oct 07, 2023
Kubernetes Interview Guide!
A thread with 20+ mid-level to advanced Kubernetes interview questions with concise answers ๐Ÿšขโš“๏ธ ๐Ÿ‘‡
1/ ๐Ÿš€ Q: What is Kubernetes and why is it essential for container orchestration?
A: Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications, ensuring high availability and reliability.
2/ ๐Ÿ› ๏ธ Q: Name the key components of a Kubernetes cluster.
A: A Kubernetes cluster consists of the Master (API Server, Controller Manager, Scheduler, etcd) and Nodes (where containers run).
#Kubernetes #Interview
3/ ๐Ÿ“ฆ Q: What is a Pod in Kubernetes?
A: A Pod is the smallest deployable unit in Kubernetes, containing one or more containers sharing the same network namespace. #Kubernetes #Interview
4/ โš–๏ธ Q: Differentiate between a Deployment and a StatefulSet.
A: Deployments manage stateless apps with rolling updates, while StatefulSets are used for stateful apps with stable network identities. #Kubernetes #Interview
5/ ๐ŸŒ Q: How does Kubernetes handle service discovery?
A: Kubernetes uses DNS for service discovery, and you can access services via their DNS names. #Kubernetes #Interview
6/ ๐Ÿ”’ Q: Explain the concept of Kubernetes Secrets.
A: Kubernetes Secrets are used to securely store sensitive information like API keys, passwords, and tokens. They are base64 encoded and can be mounted as volumes or used as environment variables. #Kubernetes #Interview
7/ ๐Ÿ”„ Q: What is a Kubernetes ConfigMap, and why is it useful?
A: ConfigMaps store configuration data as key-value pairs, which can be injected into Pods as environment variables or mounted as files. Useful for separating configuration from application code. #Kubernetes
8/ ๐Ÿ“ Q: How can you expose an application outside the Kubernetes cluster?
A: You can expose an app using Services (ClusterIP, NodePort, LoadBalancer) or Ingress controllers to manage HTTP traffic. #Kubernetes #Interview
9/ ๐Ÿงฉ Q: What are Labels and Selectors in Kubernetes?
A: Labels are key-value pairs attached to resources, and Selectors are used to filter and group resources based on labels. #Kubernetes #Interview
10/ ๐Ÿงน Q: Explain Kubernetes Rolling Updates and Rollbacks.
A: Rolling Updates gradually replace old Pods with new ones to ensure zero downtime. Rollbacks revert to a previous version if issues arise. #Kubernetes #Interview
11/ ๐Ÿ”„Q: How can you perform a rolling update in a Kubernetes Deployment?
A: You can use kubectl set image to update a Deployment's image.
For example, to update a "web" container in a Deployment named "myapp," run:
kubectl set image deployment/myapp web=mynewimage:v2
12/ ๐Ÿ•ต๏ธ Q: How do you troubleshoot a Pod that is stuck in the "Pending" state?
A: Check events with kubectl describe pod, inspect resource requests/limits, and ensure the node has available resources.
Example: kubectl describe pod mypod.
13/ ๐Ÿ“‚ Q: Explain ConfigMap with an example.
A: A ConfigMap stores configuration data.
Example: Create a ConfigMap to store database credentials and mount it as an environment variable in a Pod:
14/ ๐Ÿ” Q: Explain how to create and use a Kubernetes Secret.
A: Create a Secret and use it in a Pod as an environment variable or volume.
Example: Create a Secret for an API key and use it in a Pod:
15/ โš™๏ธ Q: How can you horizontally scale a Deployment using Horizontal Pod Autoscaling (HPA)?
A: Configure HPA with a metric, like CPU utilization. Example:
16/ ๐Ÿ“ฆ Q: What is a DaemonSet, and can you provide a practical use case?
A: A DaemonSet ensures that a Pod runs on all or specific nodes. Use it for monitoring agents. Example: Deploy a DaemonSet for a logging agent:
7/ ๐Ÿงช Q: How can you create a Kubernetes Job, and when would you use it?
A: Create a Job to run a task to completion.
Example: Create a Job to back up a database:
18/ ๐Ÿ›ก๏ธ Q: What are Pod Security Policies (PSPs), and why are they important?
A: PSPs define security policies for Pods.
Example: Create a PSP to restrict privilege escalation:
9/ ๐ŸŒ Q: Explain how Ingress controllers work and provide an example.
A: Ingress controllers manage HTTP and HTTPS routing to services.
Example: Define an Ingress to route traffic to different services based on the host:
20/ ๐Ÿงฉ Q: What are Helm charts, and how can you use them to deploy applications?
A: Helm charts are packages for Kubernetes apps.
Example: Install a Helm chart for a WordPress application:
21/ ๐Ÿ”„ Q: How can you perform a rollback in Kubernetes when an update goes wrong?
A: Use kubectl rollout undo to revert a Deployment to a previous version.
Example: Rollback "myapp" Deployment to the previous revision:
kubectl rollout undo deployment/myapp
22/ ๐ŸŒ Q: How can you configure an Ingress controller to enable SSL termination?
A: You can configure an Ingress resource with TLS settings.
Example: Define an Ingress with SSL termination:
23/ Q: Describe Kubernetes Persistent Volumes (PVs) and Persistent Volume Claims (PVCs).
๐Ÿ’ผ Persistent Volume Claims (PVCs) request storage resources from PVs. They act like "storage requests" from apps.
Eg: PVC requests storage from a PV with 1GB capacity for a database Pod:
24/ ๐ŸŒ Q: What is Kubernetes Federation, and when is it useful?
A: Kubernetes Federation allows managing multiple clusters as a single entity, helpful for multi-cloud or multi-region deployments. #Kubernetes #Interview
25/ ๐Ÿ’ก Q: How can you ensure application configuration consistency across multiple environments in Kubernetes?
A: Use Helm charts, ConfigMaps, and environment-specific overrides to manage configuration effectively.
26/ ๐Ÿ“ˆ Q: Explain the concept of Custom Resource Definitions (CRDs) in Kubernetes.
A: CRDs extend Kubernetes to support custom resource types, allowing you to define and manage your own resources and controllers.
27/ ๐Ÿ›ก๏ธ Q: What is Kubernetes RBAC, and why is it important?
A: Role-Based Access Control (RBAC) defines who can perform actions in a cluster, ensuring fine-grained access control for users and service accounts.
28/ ๐Ÿ•ต๏ธ Q: How can you secure a Kubernetes cluster?
A: Secure the cluster with RBAC, Pod Security Policies, network policies, and use tools like Helm for package management.
29/ โš™๏ธ Q: Explain the differences between a Pod, a ReplicaSet, and a Deployment.
A: A Pod is the smallest unit, a ReplicaSet ensures a specified number of Pods run, and a Deployment manages rolling updates and rollbacks.
30/ ๐ŸŒ Q: What is Network Policy in Kubernetes?
A: Network Policies define rules for controlling ingress and egress traffic to and from Pods, providing network segmentation.
Repost the thread if you find it useful. Thanks!

Loading suggestions...