Skip to content

Express.js app on Minikube using k8s ☸️ ConfigMap & Secret for configuration and sensitive data. Liveness/readiness probes,, env var injection, supports local builds and prebuilt Docker Hub image.

License

Notifications You must be signed in to change notification settings

ILXNAH/minikube-express-configmap-secret

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Express.js App with ConfigMap and Secret

This project demonstrates deploying a simple Express.js application to a Minikube cluster.
It uses Kubernetes ConfigMap for non-sensitive settings and Secret for sensitive data.


📚 Table of Contents


📝 Prereqs


📁 Project Structure

.
├── app.js
├── package.json
├── Dockerfile
├── k8s/
│   ├── configmap.yaml
│   ├── secret.yaml
│   ├── deployment.yaml
│   └── service.yaml
└── README.md
└── K8S-CHEATSHEET.md

🚀 Quickstart

1️⃣ Start Minikube

minikube start

✅ Check node is ready:

kubectl get nodes

2️⃣ Build Docker Image & Load into Minikube (Optional if using Docker Hub image)

eval $(minikube docker-env)
docker build -t express-k8s-app:latest .

If using Docker Hub image (recommended for portability), ensure your deployment.yaml uses:

image: ilouckov/express-k8s-app:latest

3️⃣ Deploy Kubernetes Resources

kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/secret.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml

✅ Check resources:

kubectl get all

4️⃣ Access the Application

minikube service express-service --url

Open the URL in your browser or use curl:

curl http://<minikube-ip>:<nodePort>/
curl http://<minikube-ip>:<nodePort>/check-api
curl http://<minikube-ip>:<nodePort>/healthz
curl http://<minikube-ip>:<nodePort>/ready

✅ Endpoints

Endpoint Description
/ Returns app name & environment from ConfigMap
/check-api Shows if API key is configured from Secret
/healthz Health check endpoint (200 OK)
/ready Readiness probe endpoint (200 OK)

🔥 Cheatsheet

See K8S-CHEATSHEET.md for quick reference commands and testing.


🔑 Note on Secret

Your k8s/secret.yaml contains the API_KEY value encoded in base64.

To create your own secret value:

echo -n 'YourSecretValueHere' | base64

Replace the value in secret.yaml.


🐳 Docker Hub Image

The Docker image for this app is publicly available at:

ilouckov/express-k8s-app

You can pull it directly using:

docker pull ilouckov/express-k8s-app:latest

💾 Get the Code

If you want to clone the repo:

git clone https://github.com/ILXNAH/minikube-express-configmap-secret

Then follow the Quickstart steps above!


📄 License

This project is licensed under the MIT License.


👤 Author

Built by ILXNAH as part of a hands-on DevOps assessment.

About

Express.js app on Minikube using k8s ☸️ ConfigMap & Secret for configuration and sensitive data. Liveness/readiness probes,, env var injection, supports local builds and prebuilt Docker Hub image.

Topics

Resources

License

Stars

Watchers

Forks