This guide will help you set up and deploy a Node.js application on Kubernetes using Minikube. The instructions below cover both Windows and macOS environments.
- Docker
- kubectl
- Minikube
- Download and install Docker Desktop for Mac from the official Docker website.
- Once installed, start Docker Desktop from your Applications folder.
- Download and install Docker Desktop for Windows from the official Docker website.
- After installation, start Docker Desktop from the Start Menu.
- Install kubectl using Homebrew:
brew install kubectl
- First, install Chocolatey if you haven't already.
- Open an administrative command prompt and run:
choco install kubernetes-cli
- Install Minikube using Homebrew:
brew install minikube
- Start Minikube:
minikube start
- Install Minikube using Chocolatey:
choco install minikube
- Start Minikube:
minikube start
- Run the following command in the source folder to configure Docker to use Minikube's Docker daemon:
eval $(minikube docker-env)
- Build the Docker image:
docker build -t basicnodeapp .
- Open PowerShell and run the following command in the source folder to configure Docker to use Minikube's Docker daemon:
minikube docker-env | Invoke-Expression
- Build the Docker image:
docker build -t basicnodeapp .
- Apply the deployment configuration:
kubectl apply -f deployment.yaml
- Apply the service configuration:
kubectl apply -f service.yaml
- Open the Node.js application in your browser:
minikube service basicnodeapp-service
This command will launch your default browser and navigate to the Node.js app running on Minikube.