Kubernetes FAQ

Basic Concepts

What is Kubernetes?

Kubernetes, also known as K8s, is an open source system for automating deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery.

What is the difference between Pod and Container?

Pod is the smallest deployable unit in Kubernetes. A Pod can contain one or more containers. It's generally recommended to run only one container per Pod. Containers within the same Pod share network and storage resources.

What is the difference between Deployment and StatefulSet?

Deployment is used to manage stateless applications, supporting declarative updates, scaling, and rollbacks. StatefulSet is used to manage stateful applications, providing stable network identities and persistent storage, suitable for databases and other applications requiring persistence.

What is Namespace?

Namespace divides cluster resources into multiple logical partitions, helping to isolate resources between different teams or projects. Common default namespaces include default, kube-system, and kube-public.

Installation and Configuration

What is the difference between Minikube and Kind?

Minikube creates a full single-node Kubernetes cluster, suitable for learning and development. Kind (Kubernetes in Docker) uses Docker containers to simulate Kubernetes nodes, more lightweight, suitable for quick testing.

How to choose a container runtime?

Common container runtimes include Docker, containerd, and CRI-O. containerd is the core container runtime from Docker and is currently widely recommended.

What to do if kubeadm init fails?

Common reasons include:

  • Ports already in use: check ports 6443, 10250, 10255
  • Swap not disabled: run swapoff -a
  • Firewall rules: ensure network communication between nodes
  • SELinux/AppArmor: can be set to permissive mode or disabled

How to configure a multi-control plane cluster?

Using kubeadm to create high-availability clusters:

  1. Prepare multiple server nodes
  2. Use kubeadm init to create the first control plane node
  3. Generate certificates and copy to other nodes
  4. Use kubeadm join to add additional control plane nodes

Network and Storage

What to do if Pods cannot communicate with each other?

Common reasons include:

  • Network plugin not installed correctly
  • Firewall blocking Pod network CIDR communication
  • CNI plugin configuration errors
  • Check if kube-proxy is running correctly

How to configure persistent storage for Pods?

You need to create PersistentVolume (PV) and PersistentVolumeClaim (PVC). PV can be local storage, network storage (NFS, iSCSI), or cloud storage (AWS EBS, GCE PD, Azure Disk).

What are the Service types?

  • ClusterIP: Virtual IP accessible within the cluster
  • NodePort: Opens a port on each node
  • LoadBalancer: Uses cloud provider's load balancer
  • ExternalName: Maps service to external domain name

Resource Management

How to set container resource limits?

Add resources field in Pod or Deployment spec:

resources:
  limits:
    memory: "512Mi"
    cpu: "500m"
  requests:
    memory: "256Mi"
    cpu: "250m"

What is ResourceQuota?

ResourceQuota is used to limit total resources in a namespace, preventing a single team or project from consuming too many resources.

What is LimitRange?

LimitRange is used to set default resource limits and requests for Pods and containers in a namespace.

Deployment and Operations

How to achieve rolling updates for applications?

When using Deployment, Kubernetes automatically performs rolling updates:

kubectl set image deployment/my-app my-app=my-app:v2
kubectl rollout status deployment/my-app

How to rollback a deployment?

# Rollback to previous version
kubectl rollout undo deployment/my-app

# Rollback to specific revision
kubectl rollout undo deployment/my-app --to-revision=2

What is HPA?

Horizontal Pod Autoscaler (HPA) automatically adjusts Pod replica count based on metrics like CPU and memory. Requires Metrics Server to work.

How to configure health checks?

Configure liveness and readiness probes:

livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  initialDelaySeconds: 30
  periodSeconds: 10
readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 5

Security

What is RBAC?

Role-Based Access Control (RBAC) is used to manage permissions in Kubernetes clusters. You can create Role and ClusterRole, and bind them to users or groups.

How to manage sensitive information?

Use Secret to store sensitive information such as passwords, keys, and certificates. Can be created using kubectl command line or defined through YAML files.

How to secure your cluster?

  • Enable RBAC authorization
  • Use network policies to restrict Pod communication
  • Regularly update Kubernetes versions
  • Encrypt etcd data
  • Use TLS for communication
  • Restrict kubelet access permissions

Troubleshooting

Pod stays in Pending state?

Possible reasons:

  • Insufficient resources (CPU or memory)
  • Node selector or taint mismatch
  • PVC not bound correctly
  • Use kubectl describe podfor details

Pod stays in ImagePullBackOff?

Common reasons:

  • Incorrect image name
  • Image tag doesn't exist
  • Private registry authentication issues
  • Network issues preventing image pull

Pod stays in CrashLoopBackOff?

  • Check container logs: kubectl logs --previous
  • Verify application starts correctly
  • Check if resource configuration is correct
  • Check if dependent services are available

How to debug network issues?

  • Check if kube-proxy is running correctly
  • Check CNI plugin status
  • Use kubectl exec to enter container and test network connectivity
  • View iptables rules
  • Use network diagnostic tools (curl, ping, traceroute)

Performance Optimization

How to improve cluster performance?

  • Configure appropriate resource requests and limits
  • Use anti-affinity to distribute Pods
  • Enable API caching to reduce requests
  • Use local storage to reduce network latency
  • Optimize image sizes to reduce pull time

How to handle large-scale clusters?

  • Use Federation to manage multiple clusters
  • Configure appropriate etcd hardware
  • Enable API caching
  • Use load balancers to distribute requests