Kubernetes has become the go-to platform for deploying and managing containerized applications at scale. But if you’re just starting out, it can feel overwhelming pods, clusters, services, deployments… it’s a lot.
This guide is designed to simplify things. By the end, you’ll understand the core concepts and deploy your first application on Kubernetes step by step.
Table of Contents
ToggleWhat is Kubernetes?
Kubernetes (often abbreviated as K8s) is an open-source platform that automates:
- Deployment of applications
- Scaling based on demand
- Management of containerized workloads
Think of it as a system that ensures your app is always running smoothly even if parts of your infrastructure fail.
Prerequisites
Before we begin, make sure you have:
- Basic knowledge of containers (Docker helps)
- A Kubernetes cluster (you can use Minikube or a cloud provider)
- kubectl CLI installed and configured
Step 1: Set Up Your Kubernetes Environment
If you’re a beginner, the easiest way to start is by using Minikube, which runs Kubernetes locally.
Install Minikube
brew install minikube # macOSOr follow official installation instructions for your OS.
Start Minikube
minikube startVerify installation
kubectl get nodesYou should see a node listed as “Ready”.
Step 2: Create a Simple Application
Let’s deploy a basic application using a Docker container.
Here’s a simple example using an Nginx server.
Step 3: Create a Deployment YAML File
In Kubernetes, we define resources using YAML files.
Create a file called:
deployment.yamlAdd the following content:
apiVersion: apps/v1 kind: Deployment metadata: name: my-first-app spec: replicas: 2 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: – name: nginx-container image: nginx:latest ports: – containerPort: 80What this does:
- Creates a Deployment
- Runs 2 replicas (copies) of the container
- Uses the Nginx image
- Exposes port 80 inside the container
Step 4: Apply the Deployment
Run the following command:
kubectl apply -f deployment.yamlCheck deployment status:
kubectl get deploymentsCheck running pods:
kubectl get podsYou should see two pods running.
Step 5: Expose Your Application
Right now, your app is running but not accessible from outside the cluster.
To fix that, create a Service.
Step 6: Create a Service YAML File
Create a file:
service.yamlAdd this:
apiVersion: v1 kind: Service metadata: name: my-first-service spec: type: NodePort selector: app: my-app ports: – protocol: TCP port: 80 targetPort: 80 nodePort: 30007What this does:
- Exposes your app externally
- Maps port 80 inside the cluster to port 30007 on your machine
Step 7: Apply the Service
kubectl apply -f service.yamlVerify:
kubectl get servicesStep 8: Access Your Application
If you’re using Minikube:
minikube service my-first-serviceThis will open your browser and show the Nginx welcome page.
Step 9: Scale Your Application
One of Kubernetes’ strengths is scaling.
To scale from 2 pods to 4:
kubectl scale deployment my-first-app –replicas=4Check pods:
kubectl get podsNow you should see 4 running pods.
Step 10: Update Your Application
Let’s say you want to update your app version.
Edit your deployment:
kubectl edit deployment my-first-appChange:
image: nginx:latestTo:
image: nginx:1.25Kubernetes will automatically perform a rolling update no downtime.
Step 11: Monitor Your Application
Useful commands:
kubectl get allkubectl describe podkubectl logsThese help you debug and understand what’s happening.
Step 12: Clean Up Resources
Once you’re done, delete everything:
kubectl delete -f deployment.yaml kubectl delete -f service.yamlKey Concepts Recap
Here are the main Kubernetes building blocks you just used:
- Pod: Smallest unit, runs your container
- Deployment: Manages pods and scaling
- Service: Exposes your app to the network
- Node: Machine running your workloads
- Cluster: Group of nodes
Common Beginner Mistakes
- Forgetting labels and selectors
If they don’t match, your service won’t connect to pods. - Using wrong ports
Always double-check containerPort vs targetPort vs nodePort. - Not checking logs
Logs are your best friend when debugging.
What’s Next?
Once you’re comfortable with this basic setup, you can explore:
- Ingress controllers for better routing
- Helm for package management
- Persistent volumes for storage
- CI/CD pipelines with Kubernetes
Final Thoughts
Kubernetes might seem complex at first, but the core workflow is straightforward:
- Define your application
- Deploy it using YAML
- Expose it with a service
- Scale and manage it
Start small, experiment often, and gradually build confidence.
Your first deployment is just the beginning.



