Dave Lobos | Web Developer About Me

Setting Up a Local Development Stack with Minikube, NodeJS, and Nginx

Having a reliable and efficient local development environment is a must for every Web Developer. This guide aims to walk you through setting up such an environment, focusing on a containerized application using Minikube for Kubernetes, NodeJS for server-side logic, and Nginx as a reverse proxy.


You can find the code for this project on GitHub:
https://github.com/DaveLobos/node-nginx-app

Requirements

Before diving in, make sure you have the following tools installed:

Getting started

Clone the project repository

git clone https://github.com/DaveLobos/node-nginx-app.git

Navigate to the project directory

cd node-nginx-app

Start Minikube

minikube start

Run Skaffold

skaffold dev

Understanding the Application Structure

It is important to understand the directory structure of our project:
.
├── LICENSE
├── README.md
├── bash
│   ├── expose.sh
├── deployment.yaml
├── nginx
│   ├── Dockerfile
│   ├── default.conf
│   └── public
│       └── css
│           └── style.css
├── node
│   ├── Dockerfile
│   └── app
│       └── main.js
└── skaffold.yaml

Kubernetes Deployment Configuration

The `deployment.yaml` file dictates how the application will run within the Kubernetes cluster. It specifies the two containers that make our deployment.

Nginx Configuration

The `nginx/default.conf` configuration manages incoming web requests:

Node.js Application

The `main.js` file in the Node.js container acts as a simple web server, demonstrating how to serve a basic HTML page and include static assets like CSS.

Final Thoughts

This setup offers a foundation for building more complex web applications or microservices. Understanding each component's role allows you to take this template and scale it according to your project’s needs, from adding additional routes to incorporating new technologies. Feel free to build upon this foundation.