Kubernetes Debugging and Clean Installation Guide for Experienced DevOps Engineers
Kubernetes (K8s) is a powerful and complex tool, and even for experienced DevOps engineers, troubleshooting and maintaining a clean environment can sometimes get tricky. This guide covers essential commands and best practices for debugging your Kubernetes setup, checking installed versions, and completely removing and reinstalling Kubernetes on an Ubuntu machine.
Debugging Kubernetes Like a Pro
1. Checking Cluster Status
kubectl cluster-info
kubectl get nodes
kubectl get pods --all-namespaces
2. Diagnosing Issues
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl get events --sort-by=.metadata.creationTimestamp
3. Checking Resource Usage
kubectl top nodes
kubectl top pods
4. Debugging Networking
kubectl get svc
kubectl get endpoints
kubectl describe svc <service-name>
Identifying Installed Kubernetes Distribution
If you’re not sure which lightweight Kubernetes distribution you have installed (Minikube, K3s, MicroK8s, Kind), use the following commands:
1. Checking Minikube
minikube status
2. Checking K3s
k3s --version
sudo k3s kubectl get nodes
3. Checking MicroK8s
microk8s status
4. Checking Kind
kind get clusters
Completely Removing Kubernetes
Sometimes you need a fresh start. Here’s how to remove different Kubernetes distributions:
1. Removing Minikube
minikube stop
minikube delete
sudo rm -rf ~/.minikube ~/.kube
2. Removing K3s
sudo /usr/local/bin/k3s-uninstall.sh
3. Removing MicroK8s
sudo snap remove microk8s
sudo rm -rf ~/.kube
4. Removing Kind
kind delete cluster
sudo rm -rf ~/.kube
Reinstalling Kubernetes
1. Reinstalling Minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube start --driver=docker
2. Reinstalling K3s
curl -sfL https://get.k3s.io | sh -
3. Reinstalling MicroK8s
sudo snap install microk8s --classic
microk8s status --wait-ready
4. Reinstalling Kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
kind create cluster
Final Thoughts
For an experienced DevOps engineer, knowing how to efficiently debug, remove, and reinstall Kubernetes distributions is crucial for maintaining clean and efficient environments. By using the commands and practices above, you’ll keep your local Kubernetes development environment running smoothly and avoid common issues.
Have more advanced debugging techniques or tools you swear by? Share them in the comments below!
✅ A personalized DevOps roadmap tailored to your experience
✅ Hands-on guidance on real-world DevOps tools
✅ Tips on landing a DevOps job and interview preparation
Comments
Post a Comment