
Kubernetes (K8s) is the leading container orchestration platform that automates the deployment, scaling, and management of containerized applications. If you’re new to Kubernetes, this guide will walk you through setting up a Kubernetes cluster, deploying applications, and managing workloads efficiently.
Before starting Kubernetes, ensure you have the following:
✅ Basic Linux & Docker Knowledge (Containers, Images, Networking)
✅ A Machine with at least 2 vCPUs & 4GB RAM (for local cluster)
✅ Docker Installed (Required for Kubernetes container runtime)
✅ kubectl (Kubernetes CLI) Installed
✅ Minikube, Kind, or a Cloud Provider for Kubernetes Deployment
kubectl)kubectl is the Kubernetes command-line tool used to manage clusters and workloads.
# Linux
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
# macOS (Homebrew)
brew install kubectl
# Windows (Chocolatey)
choco install kubernetes-cli
kubectl version --client
There are multiple ways to run Kubernetes:
| Environment | Tool | Best For |
|---|---|---|
| Local Machine | Minikube, Kind | Learning, Development |
| Cloud | AWS EKS, GCP GKE, Azure AKS | Production Deployment |
| On-Premise | K3s, kubeadm | Self-Managed Cluster |
Minikube is the easiest way to create a local Kubernetes cluster.
# Linux/macOS
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
# Windows (Powershell)
choco install minikube
minikube start --driver=docker
kubectl cluster-info
kubectl get nodes
minikube dashboard
This opens a GUI dashboard for monitoring cluster resources.
For production, use managed Kubernetes services like:
| Cloud Provider | Kubernetes Service | Command to Deploy |
|---|---|---|
| AWS | Amazon EKS | eksctl create cluster |
| Google Cloud | Google Kubernetes Engine (GKE) | gcloud container clusters create |
| Azure | Azure Kubernetes Service (AKS) | az aks create |
Example (AWS EKS):
eksctl create cluster --name my-cluster --region us-west-2
Now that your Kubernetes cluster is running, let’s deploy an application.
A Deployment manages replica pods of your application.
# nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
Apply the deployment:
kubectl apply -f nginx-deployment.yaml
Verify the deployment:
kubectl get deployments
kubectl get pods
To access the app from outside the cluster, create a Service.
# nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
Apply the service:
kubectl apply -f nginx-service.yaml
Get the service details:
kubectl get svc
If using Minikube, open the service:
minikube service nginx-service
Kubernetes makes it easy to scale applications.
kubectl scale deployment nginx-deployment --replicas=5
Automatically scale based on CPU usage:
kubectl autoscale deployment nginx-deployment --cpu-percent=50 --min=2 --max=10
| Command | Description |
|---|---|
kubectl get nodes | List all cluster nodes |
kubectl get pods | List all running pods |
kubectl describe pod <pod-name> | Detailed info about a pod |
kubectl logs <pod-name> | View logs of a running pod |
kubectl delete pod <pod-name> | Delete a specific pod |
kubectl delete deployment nginx-deployment | Remove deployment |
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl top pod
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/kube-prometheus-stack
An Ingress Controller allows external access to services.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
spec:
rules:
- host: myapp.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 80
Apply the Ingress:
kubectl apply -f nginx-ingress.yaml
To remove resources:
kubectl delete -f nginx-deployment.yaml
kubectl delete -f nginx-service.yaml
To delete the Minikube cluster:
minikube delete
To remove AWS/GCP cluster:
eksctl delete cluster --name my-cluster
🚀 Kubernetes is the backbone of modern cloud-native applications! Mastering it will boost your DevOps & Cloud career. 🚀
When analyzing a stock, one of the first financial indicators you’ll encounter is EPS, or Earnings Per Share. It’s one… Read More
When you look at a stock’s profile on a financial website, one of the first things you’ll see is its… Read More
In the world of open-source software, simplicity and flexibility are often just as important as legal protection. That’s why the… Read More
If you want your software to be open source, but still compatible with commercial use—and not as restrictive as the… Read More
When it comes to open-source software, developers and businesses alike need licenses that balance freedom, legal clarity, and long-term security.… Read More
If you’re working on open-source projects or choosing third-party libraries for your software, understanding software licenses is essential. Among the… Read More