MINIKUBE
MINIKUBE
EXERCISE – 7
TOPIC – 5
How to Set Up, Scale, and Stop Nginx Using Kubernetes (Minikube)
This process will work the same on Windows, macOS, and Linux, with only a few small
differences in how Minikube is set up on each system.
minikube start
1
RKR21 SOFTWARE ENGINEERING LAB CSE/IT/CSM/CSD III/I
Run the following command to create a new deployment (which is like creating an app) for
Nginx:
You can verify if the Nginx deployment was created correctly by running this command:
We will use the following command to expose the Nginx app to the outside world:
2
RKR21 SOFTWARE ENGINEERING LAB CSE/IT/CSM/CSD III/I
port 80).
To scale Nginx to 4 replicas (running 4 copies of the app), run the following command:
Port forwarding is a way to forward traffic from a port on your computer (like 8081) to a port
inside the Kubernetes cluster (like port 80 in the Nginx pod).
We need port forwarding because Jenkins is already using port 8080 on your computer.
That’s why we forward traffic from 8081 to port 80 on Nginx.
Run this command to forward port 8081 on your local machine to port 80 inside the Nginx
container:
3
RKR21 SOFTWARE ENGINEERING LAB CSE/IT/CSM/CSD III/I
http://localhost:8081
You should see the Nginx welcome page, confirming that the app is running!
If port forwarding doesn’t work for you, or if you prefer an alternative method, you can use
Minikube Tunnel.
Run this command to create a tunnel that lets you access the service directly:
minikube tunnel
Explanation: This command creates a tunnel between your local machine and the
Kubernetes cluster, allowing you to access the service.
Once the tunnel is running, get the URL of the service using:
What happens: This command gives you a URL (like http://192.168.x.x:80) that
you can open in your browser to access Nginx.
4
RKR21 SOFTWARE ENGINEERING LAB CSE/IT/CSM/CSD III/I
Copy and paste the provided URL into your browser to access Nginx directly.
minikube stop
minikube delete