🐳 A Beginner’s Guide to Kubernetes Deployment and Management
Kubernetes, also known as K8s, is an open-source platform that automates the deployment, scaling, and management of containerized applications. In simple terms, it helps developers run applications in containers (like Docker) efficiently.
✅ Step 1: Understand What Kubernetes Is
Kubernetes is a container orchestration tool.
That means it manages multiple containers (like Docker containers) across many servers. Think of it like a traffic controller for your apps.
KEY CONCEPTS
- Pod: A group of one or more containers.
- Node: A single server (virtual or physical).
- Cluster: A group of nodes managed by Kubernetes.
- Deployment: A set of instructions to run your app.
- Service: Exposes your app to the internet or internal users.
✅Step 2: Install Docker (Required for Kubernetes)
- Go to Docker website
- Download Docker Desktop.
- Install and run Docker.
- Verify by running:
docker –version
✅Step 3: Install Kubernetes (via Minikube)
Minikube allows you to run Kubernetes locally.
- Visit the official Minikube GitHub releases page:
- Download the Linux Minikube binary from there (the file is named minikube-linux-amd64).
- After downloading, rename the file to minikube and make it executable by running the following in your terminal:
Use the command to change permissions: chmod +x minikube
- Move the Minikube file to your system path:
Move it using: sudo install minikube /usr/local/bin/minikube
- Once done, check the installation by typing:
minikube version
- Start Minikube:
minikube start
- Check it’s working:
kubectl get nodes
You should see output showing your Minikube cluster node in a “Ready” state
✅ Step 4: Deploy Your First Application
- Let’s deploy a simple NGINX application to your cluster.
- Run
kubectl create deployment nginx-app –image=nginx
This command tells Kubernetes to deploy an app named nginx-app
using the official NGINX Docker image.
- Now, check the deployment:
kubectl get deployments
- To see the running pods:
kubectl get pods
✅Step 5: Expose the Application
Your NGINX app is running, but it’s not accessible from your browser yet.
- To expose it:
kubectl expose deployment nginx-app –type=NodePort –port=80
This exposes the app on a port on your local machine.
- To find out which URL you can access it on:
minikube service nginx-app –url
Open that URL in your browser to see the NGINX welcome page.
✅ Step 6: Scale Your Application
Want to run multiple instances of your app?
- Scale it like this:
kubectl scale deployment nginx-app –replicas=3
- Check the pods again:
kubectl get pods
You’ll now see three pods running the same application.
✅Step 7: Clean Up
Your NGINX app is running, but it’s not accessible from your browser yet.
- Once you’re done testing:
kubectl delete service nginx-app
kubectl delete deployment nginx-app
minikube stop
🎯 Wrapping Up
You’ve now:
- Installed Minikube and started a local Kubernetes cluster
- Deployed your first app
- Exposed it to the browser
- Scaled it
- Cleaned up the resources