Deploying applications with Kubernetes can seem intimidating at first but once you understand the workflow, it becomes one of the most powerful tools in modern DevOps. This guide walks you through the full process of deploying an app step by step, using clear explanations and practical examples.
Table of Contents
ToggleWhat is Kubernetes (and Why Use It)?
Kubernetes is an open-source platform designed to automate deploying, scaling, and managing containerized applications.
Instead of manually handling servers, Kubernetes:
- Schedules containers automatically
- Restarts failed applications
- Scales apps up/down based on demand
- Manages networking and load balancing
If you’re already using Docker, Kubernetes is the next logical step for managing containers at scale.
Prerequisites
Before starting, make sure you have:
- Basic understanding of containers
- Docker installed
- kubectl installed
- A Kubernetes cluster (local or cloud-based like AWS, GCP, or Azure)
For beginners, you can use:
- Minikube (runs locally)
- Kind
Step 1: Create a Simple Application
Let’s start with a basic app. For example, a simple Node.js server:
// app.js const http = require(‘http’);const server = http.createServer((req, res) => { res.end(‘Hello from Kubernetes!’); });server.listen(3000, () => { console.log(‘Server running on port 3000’); });Create a package.json and install dependencies if needed.
Step 2: Containerize the Application
Now, package your app using Docker.
Create a Dockerfile:
FROM node:18 WORKDIR /app COPY . . RUN npm install CMD [“node”, “app.js”] EXPOSE 3000Build and run the image:
docker build -t my-k8s-app . docker run -p 3000:3000 my-k8s-appTest it locally in your browser:
👉 http://localhost:3000
Step 3: Set Up Kubernetes Cluster
Start your cluster using Minikube:
minikube startVerify cluster status:
kubectl get nodesYou should see one running node.
Step 4: Create a Deployment
A Deployment defines how your app runs in Kubernetes.
Create deployment.yaml:
Apply it:
kubectl apply -f deployment.yamlCheck pods:
kubectl get podsStep 5: Expose the Application (Service)
Pods are not directly accessible, so we create a Service.
Create service.yaml:
Apply it:
kubectl apply -f service.yamlAccess your app:
minikube service my-serviceStep 6: Scale Your Application
One of Kubernetes’ biggest advantages is scaling.
Scale to 5 replicas:
kubectl scale deployment my-app –replicas=5Verify:
kubectl get podsStep 7: Update Your Application
Make a change in your code (e.g., update the message), rebuild the image:
docker build -t my-k8s-app:v2 .Update deployment:
kubectl set image deployment/my-app my-app=my-k8s-app:v2Check rollout:
kubectl rollout status deployment/my-appStep 8: Monitor and Debug
Useful commands:
kubectl get pods kubectl describe pod kubectl logsFor dashboards, enable:
minikube dashboardKey Kubernetes Concepts Explained
- Pod: Smallest unit, runs containers
- Deployment: Manages pods and replicas
- Service: Exposes your app
- Node: Machine running your app
- Cluster: Group of nodes
Common Beginner Mistakes
- Forgetting to expose ports
- Using wrong image names
- Not checking logs when debugging
- Skipping YAML indentation rules
Best Practices
- Use versioned images (
v1,v2) - Keep deployments declarative
- Monitor resource usage
- Use namespaces for organization
Real-World Use Case
Imagine deploying an e-commerce app:
- Frontend + backend run as separate deployments
- Auto-scaling handles traffic spikes
- Rolling updates ensure zero downtime
That’s the real power of Kubernetes.
Conclusion
Deploying apps with Kubernetes may feel complex at first, but the workflow is straightforward:
- Build your app
- Containerize with Docker
- Create deployment
- Expose via service
- Scale and update
Once you practice these steps, you’ll be able to deploy production-ready applications with confidence.



