🚀 Go From Zero to K8s Hero: Local Kubernetes Dev with DevSpace + Kind
Md Imran

Md Imran @narmidm

About: Building the Reliability Layer for the AI Era | ex-EM @ Razorpay, Avesha | Docker Captain 🐳 | CNCF Maintainer (KubeSlice) | Infra Reliability & Open Source Advocate

Location:
India
Joined:
Aug 26, 2024

🚀 Go From Zero to K8s Hero: Local Kubernetes Dev with DevSpace + Kind

Publish Date: Mar 30
0 0

Let’s face it—Kubernetes is awesome, but developing on it can feel like trying to debug spaghetti code blindfolded. Between setting up clusters, syncing code, and wondering why the pod isn't picking up your changes again, it's easy to lose momentum.

But not today. Today, you’re going to slap Kubernetes in the face with DevSpace, spin up your own local cluster with Kind, and build a Node.js app that updates faster than your caffeine intake.

This isn’t just a guide—it’s your fast-track to becoming a local K8s boss.


⚙️ What We’re Building (and Why You Should Care)

We’ll build a simple, live-reloading Node.js app that runs inside Kubernetes—locally. You’ll get:

✅ A real Kubernetes cluster (with Kind, not “pretend-Kube”)

✅ DevSpace-powered live reloads and two-way code sync

✅ Clean, production-style deployment setup

✅ An app that actually works and updates without you rage-refreshing Chrome

GitHub Repo: narmidm/devspace-k8s-local-dev


🧪 Prerequisites

Before we dive in, make sure you’ve got:

Bonus: Install Kind & DevSpace with Homebrew (macOS)

brew install kind
brew install devspace
Enter fullscreen mode Exit fullscreen mode

Linux? No worries. Use these instead:

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.27.0/kind-$(uname)-amd64
chmod +x ./kind && sudo mv ./kind /usr/local/bin/kind

curl -L -o devspace https://github.com/loft-sh/devspace/releases/latest/download/devspace-linux-amd64
chmod +x devspace && sudo mv devspace /usr/local/bin/
Enter fullscreen mode Exit fullscreen mode

🛠 Step 1: Clone & Explore the Repo

git clone https://github.com/narmidm/devspace-k8s-local-dev.git
cd devspace-k8s-local-dev
npm install
Enter fullscreen mode Exit fullscreen mode

What’s inside?

├── app.js                 # Node server (hello, world!)
├── index.html             # Served from the app
├── Dockerfile             # Our container recipe
├── devspace.yaml          # DevSpace magic
└── k8s/
    └── deployment.yaml    # K8s deployment config
Enter fullscreen mode Exit fullscreen mode

🔧 Step 2: Create a Local K8s Cluster with Kind

kind create cluster
Enter fullscreen mode Exit fullscreen mode

Boom. You now have a fully functional Kubernetes cluster… running inside Docker. Inception vibes? Maybe. Cool? Definitely.

Verify it’s up:

kubectl cluster-info
Enter fullscreen mode Exit fullscreen mode

📦 Step 3: Understand the App

Your app is a super-basic HTTP server that serves index.html. But it’s also smart enough to reload live (thanks to nodemon) and update as soon as you change files.

// app.js
http.createServer((req, res) => {
  // Serve index.html and show changes
}).listen(PORT)
Enter fullscreen mode Exit fullscreen mode

Try editing the timestamp in index.html. DevSpace will sync it live into the container 💥.


🧙‍♂️ Step 4: DevSpace Setup (a.k.a. “Magic Happens Here”)

DevSpace takes care of:

  • 🛠 Building Docker image
  • 🚀 Deploying to your cluster
  • 🔄 Syncing code (two-way!)
  • 🔁 Auto-restarting your app on change

The devspace.yaml defines it all:

images:
  app:
    image: devspace-k8s-local-dev:latest
    dockerfile: Dockerfile

dev:
  app:
    sync:
      - path: ./:/app
    command: ["npm", "run", "dev"]
    ports:
      - port: 3000
Enter fullscreen mode Exit fullscreen mode

So when you run:

devspace dev
Enter fullscreen mode Exit fullscreen mode

DevSpace will:

  1. Build your image
  2. Deploy it using k8s/deployment.yaml
  3. Forward port 3000 to localhost
  4. Keep your code in sync
  5. Restart the app if you change stuff

Now open http://localhost:3000 and you’ll see your live app. 🎉


✍️ Edit and Watch the Magic

Open index.html, change a heading or the timestamp. Save.

Boom. Reloaded inside the pod.
No rebuilds. No redeploys. No tears.


🧼 Cleaning Up

Done for the day?

kind delete cluster
Enter fullscreen mode Exit fullscreen mode

Free up Docker space too:

docker system prune -f
Enter fullscreen mode Exit fullscreen mode

🧠 Bonus: Common Issues

Pod restarting repeatedly?

Check logs: kubectl logs <pod-name>

No updates in browser?

Restart DevSpace. Or turn it off and on again (classic).

Permission denied?

Docker may need sudo. Or you need to add your user to the Docker group.


🎯 Final Thoughts

Kubernetes local dev doesn’t have to suck.

With Kind + DevSpace, you’ve got a blazing-fast dev loop, production-like consistency, and fewer WTF moments per minute. Whether you're working solo or onboarding a team, this setup just works.

Next time someone says “but K8s is hard for devs,” send them this article—and a link to your working setup.


🧑‍💻 GitHub Repo: 👉 https://github.com/narmidm/devspace-k8s-local-dev

Happy coding, fellow new warrior! 💙🐳


Comments 0 total

    Add comment