Day 37 : Kubernetes Important interview Questions.
DevOps Learning

1. What is Kubernetes and why is it important?
Kubernetes is an open-source platform designed to automate deploying, scaling, and operating application containers. It helps manage containerized applications in a clustered environment, providing mechanisms for deployment, maintenance, and scaling of applications.
Importance:
Scalability: Automatically scales applications up or down based on demand.
High Availability: Ensures applications are always running and accessible.
Resource Efficiency: Optimizes the use of hardware resources.
Portability: Works across different environments, from local development to production.
2. What is the difference between Docker Swarm and Kubernetes?
Docker Swarm and Kubernetes are both container orchestration tools, but they have some key differences:
Complexity: Kubernetes is more complex and feature-rich, while Docker Swarm is simpler and easier to set up.
Scalability: Kubernetes offers better scalability and is more suitable for large-scale applications.
Community and Ecosystem: Kubernetes has a larger community and more extensive ecosystem.
Networking: Kubernetes has a more robust networking model with built-in service discovery and load balancing.
3. How does Kubernetes handle network communication between containers?
Kubernetes uses a flat network structure, where each pod (a group of one or more containers) gets its own IP address. This allows containers within different pods to communicate with each other directly. Kubernetes also provides services, which are stable IP addresses and DNS names, to enable communication between different sets of pods.
4. How does Kubernetes handle scaling of applications?
Kubernetes handles scaling through Horizontal Pod Autoscaling (HPA). HPA automatically adjusts the number of pod replicas based on observed CPU utilization or other select metrics. This ensures that the application can handle varying loads efficiently.
5. What is a Kubernetes Deployment and how does it differ from a ReplicaSet?
A Deployment in Kubernetes is a higher-level abstraction that manages a ReplicaSet and provides declarative updates to applications. It ensures that the desired number of pod replicas are running at any given time.
A ReplicaSet ensures that a specified number of pod replicas are running at all times. While a Deployment manages ReplicaSets, it also provides additional features like rolling updates and rollbacks.
6. Can you explain the concept of rolling updates in Kubernetes?
Rolling updates allow you to update the application without downtime. Kubernetes gradually replaces old pods with new ones, ensuring that a certain number of pods are always available during the update process. This minimizes disruption and maintains application availability.
7. How does Kubernetes handle network security and access control?
Kubernetes handles network security and access control through several mechanisms:
Network Policies: Define rules for how pods can communicate with each other and with other network endpoints.
Role-Based Access Control (RBAC): Manages permissions for users and applications, ensuring that only authorized entities can perform specific actions.
8. Can you give an example of how Kubernetes can be used to deploy a highly available application?
To deploy a highly available application, you can use a Deployment with multiple replicas spread across different nodes. Additionally, you can use a Service to load balance traffic across these replicas. This ensures that if one pod or node fails, the application remains accessible.
9. What is a namespace in Kubernetes? Which namespace does any pod take if we don’t specify any namespace?
A namespace in Kubernetes is a way to divide cluster resources between multiple users or teams. It provides a scope for names, allowing you to create resources with the same name in different namespaces.
If you don’t specify a namespace, the pod is created in the default namespace.
10. How does ingress help in Kubernetes?
Ingress is an API object that manages external access to services within a cluster, typically HTTP. It provides load balancing, SSL termination, and name-based virtual hosting, making it easier to expose multiple services under a single IP address.
11. Explain different types of services in Kubernetes?
Kubernetes provides several types of services:
ClusterIP: Exposes the service on a cluster-internal IP. This is the default type.
NodePort: Exposes the service on each node’s IP at a static port.
LoadBalancer: Exposes the service externally using a cloud provider’s load balancer.
ExternalName: Maps the service to a DNS name.
12. Can you explain the concept of self-healing in Kubernetes and give examples of how it works?
Self-healing in Kubernetes means that the system automatically detects and replaces failed or unhealthy pods. Examples include:
Restarting failed containers.
Rescheduling pods on healthy nodes if a node fails.
Replacing and rescheduling pods when nodes are marked as unschedulable.
13. How does Kubernetes handle storage management for containers?
Kubernetes handles storage through Persistent Volumes (PVs) and Persistent Volume Claims (PVCs). PVs are storage resources in the cluster, while PVCs are requests for storage by users. Kubernetes also supports dynamic provisioning, where storage is automatically provisioned based on PVCs.
14. How does the NodePort service work?
A NodePort service exposes the service on each node’s IP at a static port. This allows external traffic to access the service by sending requests to the node’s IP and the specified port.
15. What is a multinode cluster and single-node cluster in Kubernetes?
Single-node cluster: All Kubernetes components run on a single node. It’s typically used for development and testing.
Multinode cluster: Consists of multiple nodes, with some acting as masters (control plane) and others as workers (where the applications run). This setup is used for production environments to ensure high availability and scalability.
16. Difference between create and apply in Kubernetes?
kubectl create: Creates resources from a file or stdin. It is typically used for creating new resources.
kubectl apply: Applies changes to resources defined in a file. It is used for updating existing resources and supports declarative configuration management.
Thank you for reading😉.



