Listen to this Post
You Should Know:
Kubernetes is a powerful tool for managing containerized applications in a clustered environment. Below are some verified commands and steps to get started with Kubernetes:
1. Install Kubernetes:
- On Ubuntu, you can install Kubernetes using the following commands:
sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list sudo apt-get update sudo apt-get install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl
2. Initialize Kubernetes Cluster:
- Use `kubeadm` to initialize the cluster:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
- After initialization, set up the kubeconfig file:
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
3. Deploy a Pod Network:
- Deploy a pod network (e.g., Flannel) to enable communication between pods:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
4. Deploy an Application:
- Deploy a sample Nginx application:
kubectl create deployment nginx --image=nginx kubectl expose deployment nginx --port=80 --type=NodePort
5. Check Cluster Status:
- Verify the status of the cluster and nodes:
kubectl get nodes kubectl get pods --all-namespaces
6. Scale Applications:
- Scale the Nginx deployment to 3 replicas:
kubectl scale deployment nginx --replicas=3
7. Update and Rollback Deployments:
- Update the Nginx image to a specific version:
kubectl set image deployment/nginx nginx=nginx:1.19
- Rollback to the previous deployment:
kubectl rollout undo deployment/nginx
What Undercode Say:
Kubernetes is an essential tool for modern cloud-native development. By mastering Kubernetes, you can efficiently manage containerized applications, ensuring scalability, resilience, and high availability. The commands and steps provided above are foundational for anyone starting with Kubernetes. For more advanced topics, consider exploring the official Kubernetes documentation and additional resources from The Linux Foundation.
Useful URLs:
- Kubernetes Official Documentation
- The Linux Foundation – Kubernetes Courses
- Flannel GitHub Repository
References:
Reported By: Ranas Mukminov – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅



