,

Deploy Your First App in Kubernetes in 10 Minutes (Step-by-Step Guide)

Posted by


🚀 Deploy Your First App in Kubernetes in 10 Minutes (Step-by-Step Guide)

So you’ve heard about Kubernetes (K8s) — the cloud-native orchestrator used by Google, Netflix, and every serious tech company.

Now it’s time to get your hands dirty.

In this blog, you’ll go from zero to deployed — launching your very first web application on Kubernetes in just 10 minutes. And you’ll learn what’s really happening under the hood at each step.


🧰 What You’ll Need


🧱 Step 1: Start Your Kubernetes Cluster

If using Docker Desktop:

  • Open Docker → Enable Kubernetes in Settings → Wait for the green “Kubernetes is running” status

If using Minikube:

minikube start

Test it with:

kubectl cluster-info
kubectl get nodes

You now have a single-node Kubernetes cluster running on your machine 🎉


📦 Step 2: Choose a Simple App to Deploy

We’ll use a pre-built Docker image:

nginxdemos/hello

This is a lightweight “Hello from NGINX” app — perfect for testing.


📄 Step 3: Create Your First Deployment

A Deployment tells Kubernetes:

  • What app to run
  • How many copies (replicas)
  • Which Docker image to use

Create a file: deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: hello
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
      - name: hello-container
        image: nginxdemos/hello
        ports:
        - containerPort: 80

Apply it with:

kubectl apply -f deployment.yaml

Check if it’s running:

kubectl get pods

🌐 Step 4: Expose the App with a Service

Your pods are running — but not accessible yet.

Let’s expose them using a Service.

Create service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: hello-service
spec:
  selector:
    app: hello
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: NodePort

Apply it:

kubectl apply -f service.yaml

Get the port:

kubectl get svc

Look for something like:

hello-service   NodePort   <your-ip>   80:30080/TCP

Visit in your browser:

http://localhost:30080/

🎉 You just deployed your first app on Kubernetes!


⚙️ Step 5: Scale Your App

Want more replicas?

Update in YAML or run:

kubectl scale deployment hello-deployment --replicas=4
kubectl get pods

🔁 Step 6: Update Your App (Rolling Update)

Let’s simulate an update. Change the image to a new version (if available) or update text if building your own.

To update:

kubectl set image deployment/hello-deployment hello-container=nginxdemos/hello:latest

Kubernetes will roll out the update gradually with zero downtime.

Check rollout status:

kubectl rollout status deployment/hello-deployment

📦 Step 7: Clean Up

When done:

kubectl delete service hello-service
kubectl delete deployment hello-deployment

🧠 What You Just Learned (Behind the Scenes)

ConceptWhat It Did
DeploymentManages pod lifecycle, self-heals
PodSmallest runnable unit, holds your container
ServiceRoutes traffic to pods
NodePortExposes app outside the cluster
kubectlCLI to interact with your cluster
RolloutSmoothly updates your app in production

🔁 Bonus: Run Everything in One File

Create a k8s-app.yaml to include both Deployment and Service:

# deployment and service YAMLs combined here

Then:

kubectl apply -f k8s-app.yaml

🧰 What’s Next?

After you’ve deployed your first app, level up with:

TopicWhy It Matters
HelmKubernetes package manager
ArgoCDGitOps-based deployments
Ingress ControllersSmart traffic routing
Secrets/ConfigMapsManage app configs and secrets
Horizontal Pod Autoscaler (HPA)Auto-scale based on load

🏁 Final Thoughts

Kubernetes might feel complex — but once you deploy your first app, it all clicks.

You don’t need to be a K8s guru to get started.
You just need a terminal, some YAML, and 10 minutes.


Leave a Reply

Your email address will not be published. Required fields are marked *

0
Would love your thoughts, please comment.x
()
x