Unit 10 Bonus - Kubernetes
NOTE: This is an optional bonus section. You do not need to read it, but if you're interested in digging deeper, this is for you.
This section provides advanced troubleshooting techniques, security best practices, and real-world challenges to strengthen your Kubernetes knowledge.
Step 1: Troubleshooting Kubernetes Cluster Issues
When things go wrong, systematic troubleshooting is key. Here’s how you diagnose common Kubernetes issues.
Node Not Ready
Check node status
Investigate Kubelet logs
Verify system resources
Possible Fixes
- Restart K3s on the failing node:
- Ensure network connectivity:
Pods Stuck in "Pending" or "CrashLoopBackOff"
Check pod status
Possible Fixes
- If insufficient resources, scale up the cluster.
- If missing images, check container registry authentication.
- If misconfigured storage, inspect volumes:
Step 2: Securing Kubernetes Deployments
Security is crucial in enterprise environments. Here are quick wins for a more secure Kubernetes cluster.
Limit Pod Privileges
Disable privileged containers
Enforce read-only file system
Restrict Network Access
Use Network Policies to restrict pod communication
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
spec:
podSelector: {}
policyTypes:
- Ingress
Use Pod Security Admission (PSA)
Enable PSA to enforce security levels:
Step 3: Performance Optimization Tips
Enhance Kubernetes efficiency with these quick optimizations:
Optimize Resource Requests & Limits
Set appropriate CPU & Memory limits in deployments:
Why? Prevents a single pod from consuming excessive resources.
Enable Horizontal Pod Autoscaling (HPA)
Auto-scale pods based on CPU or memory usage:
Step 4: Bonus Challenge - Build a Secure, Scalable App
Challenge:
- Create a secure containerized app
- Deploy it in Kubernetes
- Implement Network Policies
- Apply Pod Security Standards
Helpful Resources:
Conclusion
This bonus section strengthens your Kubernetes troubleshooting, security, and performance tuning skills. Apply these principles in real-world deployments!