Deploying a Node.js App on Kubernetes with Minikube
dev.toΒ·4hΒ·
Discuss: DEV
Flag this post

Minikube downloaded the base image (kicbase:v0.0.48) and booted a control-plane node.

Everything ran on Windows Home β€” no Hyper-V needed.


🐳 Step 2: Dockerize the Node.js App

I wrote a simple Node.js server (app.js):

const http = require("http");
const PORT = 3000;
const server = http.createServer((req, res) => {
res.end("Hello from Node.js running inside Kubernetes!");
});
server.listen(PORT, () => console.log(`Server running on port ${PORT}`));

Then, I created a Dockerfile:

FROM node:18-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "app.js"]

Built the image:

docker build -t node-k8s-demo .


☸️ Step 3: Deploy on Kubernetes

Deployment YAML

apiVersion: apps/v1
k...

Similar Posts

Loading similar posts...