Kubernetes, often abbreviated as K8s, is a powerful open-source platform for automating the deployment, scaling, and management of containerized applications. Originally developed by Google, it is now maintained by the Cloud Native Computing Foundation (CNCF).
At its core, Kubernetes helps organizations run applications reliably across clusters of machines by abstracting infrastructure complexities. It enables features like automatic scaling, self-healing, load balancing, and seamless rollouts/rollbacks. With its rich ecosystem of tools and integrations, Kubernetes has become the backbone of modern DevOps and cloud-native architectures.
Whether you're managing a microservices-based application or scaling a monolithic app, Kubernetes provides the flexibility and control needed to operate in dynamic, production-grade environments.
Kubernetes Knowledge Boost: 60 Advanced Questions Explained |
Here is a list of 60 advanced Kubernetes questions with concise answers. They cover architecture, concepts, troubleshooting, security, and more:
Kubernetes Architecture and Core Concepts
What is a Kubernetes control plane?
- The control plane manages the Kubernetes cluster, maintaining the desired state via components like
kube-apiserver
,etcd
,kube-scheduler
,kube-controller-manager
, andcloud-controller-manager
.
- The control plane manages the Kubernetes cluster, maintaining the desired state via components like
What is etcd, and why is it important?
etcd
is a distributed key-value store that Kubernetes uses to store all cluster data, such as configurations, secrets, and states.
Explain how a Kubernetes scheduler works.
- The scheduler assigns Pods to nodes by evaluating resource requirements, policies, and constraints, ensuring an optimal placement.
What is a Pod? Why is it the smallest deployable unit in Kubernetes?
- A Pod is a group of one or more containers sharing the same network namespace and storage. It encapsulates the application and its dependencies, making it the basic unit of deployment.
How do you ensure high availability in a Kubernetes cluster?
- By setting up a multi-master architecture, load balancers for the API server, and using tools like kubeadm, Kops, or managed Kubernetes services.
Advanced Networking
What is a Kubernetes Service?
- A Service abstracts a set of Pods, providing stable networking and load balancing. Types include ClusterIP, NodePort, LoadBalancer, and ExternalName.
How does kube-proxy work?
kube-proxy
maintains network rules to allow communication between Pods and Services using IP tables, IPVS, or user-space proxies.
What is the role of CNI in Kubernetes?
- Container Network Interface (CNI) is a standard for configuring container networking, enabling plugins like Flannel, Calico, and Weave.
What are Network Policies?
- Network Policies control traffic between Pods or Pods and external endpoints, using rules to allow or deny ingress and egress.
How do you expose an application in Kubernetes to external traffic?
- Use a Service of type LoadBalancer or NodePort, or an Ingress resource with an Ingress controller.
Storage
What is Persistent Volume (PV) and Persistent Volume Claim (PVC)?
- PV is a storage resource in the cluster, while PVC is a request for storage by a user. PVCs bind to PVs for dynamic or static provisioning.
How does dynamic volume provisioning work?
- StorageClasses define storage types, and when a PVC is created, Kubernetes dynamically provisions a matching PV.
What is CSI in Kubernetes?
- The Container Storage Interface (CSI) standardizes storage plugin management for dynamic provisioning and attaching volumes.
What is ephemeral storage?
- Temporary storage tied to the Pod lifecycle, used for caching, logs, or temporary files.
How can you back up and restore etcd?
- Use
etcdctl
commands to take snapshots and restore the data to another etcd cluster.
- Use
Security
What is RBAC, and how does it work?
- Role-Based Access Control (RBAC) manages access to Kubernetes resources using roles and bindings.
What are Kubernetes Secrets, and how are they used?
- Secrets store sensitive data like credentials securely, referenced by Pods via volumes or environment variables.
What is Pod Security Admission (PSA)?
- PSA enforces security standards for Pods by controlling privilege levels like baseline or restricted.
How do you secure the API server?
- By using TLS, enabling RBAC, restricting anonymous access, and enabling audit logs.
What are Pod security contexts?
- Security contexts define Pod-level permissions, such as running as a non-root user or mounting filesystems as read-only.
Troubleshooting
How do you troubleshoot Pod CrashLoopBackOff?
- Check logs using
kubectl logs
, inspect events usingkubectl describe pod
, and validate container configurations.
- Check logs using
How do you debug network issues in Kubernetes?
- Use tools like
kubectl exec
, network policies,traceroute
, or external tools likecilium
andtcpdump
.
- Use tools like
What is the significance of Node Conditions?
- Node Conditions (e.g., MemoryPressure, DiskPressure) indicate health and resource status, guiding scheduler decisions.
How do you handle etcd failure?
- Restore from a backup and ensure quorum by adding healthy nodes.
What tools can you use for Kubernetes observability?
- Prometheus, Grafana, Fluentd, ELK stack, and Jaeger.
Scaling and Performance
How does Kubernetes autoscaling work?
- Kubernetes supports horizontal (HPA), vertical (VPA), and cluster autoscaling based on resource utilization or custom metrics.
What is a ReplicaSet, and how does it differ from a Deployment?
- A ReplicaSet ensures a specified number of Pod replicas, while Deployments manage ReplicaSets for updates and rollbacks.
How do you optimize resource usage in a cluster?
- Define resource requests/limits, monitor usage with tools like Prometheus, and right-size workloads.
What is pod affinity and anti-affinity?
- Affinity defines Pod co-location preferences, while anti-affinity enforces separation.
How do you handle resource contention in a cluster?
- Use priorities, preemption, and resource quotas.
Custom Resources and Operators
What are Custom Resource Definitions (CRDs)?
- CRDs enable users to define and manage custom Kubernetes objects.
What is a Kubernetes Operator?
- An Operator automates operational tasks for applications using custom controllers and CRDs.
How do you extend Kubernetes functionality?
- Use CRDs, admission controllers, or plugins like CNI and CSI.
How do you write a custom controller?
- Use Kubernetes client libraries (e.g., client-go) to reconcile the desired and actual states of resources.
What are finalizers in Kubernetes?
- Finalizers delay resource deletion until specific cleanup tasks complete.
Cluster Administration
How do you upgrade a Kubernetes cluster?
- Upgrade control plane components first, then worker nodes, following the Kubernetes release cycle.
What is taint and toleration in Kubernetes?
- Taints prevent Pods from scheduling on specific nodes unless they tolerate the taint.
How do you perform node maintenance in Kubernetes?
- Drain the node (
kubectl drain
) and cordon it to prevent scheduling.
- Drain the node (
What is kubelet, and what is its role?
- Kubelet is an agent running on each node, responsible for managing Pods and reporting to the control plane.
How does Kubernetes handle rolling updates?
- Deployments update Pods incrementally, creating new Pods while scaling down old ones.
Advanced Scenarios
What is the difference between StatefulSets and Deployments?
- StatefulSets manage stateful applications with stable network identities, while Deployments are for stateless applications.
How do you ensure consistency in StatefulSets?
- Use headless services and persistent volumes.
What is a Helm chart, and how is it used?
- Helm is a package manager for Kubernetes, and Helm charts define application configurations and resources.
What are the differences between DaemonSets and Deployments?
- DaemonSets ensure one Pod runs on each node, while Deployments scale Pods across nodes.
How do you implement canary deployments?
- Use multiple versions of Deployments with traffic splitting via Ingress or a Service mesh.
Security and Best Practices
What is a Pod disruption budget (PDB)?
- PDB defines minimum available or maximum unavailable Pods during disruptions.
What is Kubernetes admission control?
- Admission controllers validate and mutate API requests based on policies.
How do you implement encryption for Secrets?
- Enable encryption at rest using Kubernetes encryption configuration.
What are the best practices for managing ConfigMaps and Secrets?
- Use immutable ConfigMaps/Secrets, manage access with RBAC, and avoid exposing sensitive data in logs.
What are namespace quotas?
- Quotas limit resource consumption in namespaces, ensuring fair resource distribution.
Miscellaneous
What is kubeadm, and how is it used?
- Kubeadm bootstraps Kubernetes clusters by setting up the control plane and nodes.
What is the difference between a job and a cronjob?
- A job runs a task to completion, while a cronjob schedules jobs at regular intervals.
What is kube-state-metrics?
- It exposes Kubernetes resource states as Prometheus metrics for monitoring.
How do you use Service mesh in Kubernetes?
- Service meshes like Istio or Linkerd add features like traffic routing, observability, and security to microservices.
What is Horizontal Pod Autoscaler (HPA)?
- HPA scales Pods based on CPU/memory utilization or custom metrics.
Emerging Trends
How does Kubernetes integrate with serverless frameworks?
- Use Knative or OpenFaaS to run serverless workloads on Kubernetes.
What is Kubernetes Federation?
- Federation manages multiple clusters for global deployment and high availability.
What is the role of policy engines like OPA/Gatekeeper?
- Open Policy Agent (OPA) enforces policies like security or compliance in Kubernetes.
What is KubeEdge?
- KubeEdge extends Kubernetes to edge devices for IoT and edge computing.
What is Multi-tenancy in Kubernetes?
- Multi-tenancy isolates resources and workloads for different users or teams within a cluster.
No comments:
Post a Comment