This GitHub project is intended to help you deploy a simple nginxdemo application on a minikube cluster.
The minikube cluster was deployed using the steps mentioned here - https://minikube.sigs.k8s.io/docs/start/
If you do not have the kubectl cli installed, you can install it from here - https://kubernetes.io/docs/tasks/tools/#kubectl
Please note that minikube makes use of level 2 hypervisor and runs the minikube cluster as a Virtual machine. It would be advisable to have tools like VirtualBox, or any other hypervisor readily installed.
Once the minikube cluster is started, try running basic commands like kubectl get pods
to see if it returns valid results like ‘No resources found in default namespace.'
Below is a sample manifest file that creates a simple nginxdemo pod using the image nginxdemos/hello
and a service of type NodePort that helps expose the nginxdemo pod locally on the machine.
apiVersion: v1
kind: Pod
metadata:
labels:
run: nginxdemo
name: nginxdemo
spec:
containers:
- image: nginxdemos/hello
name: nginxdemo
---
apiVersion: v1
kind: Service
metadata:
labels:
run: nginxdemo
name: nginxdemo-service
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginxdemo
type: NodePort
To run this yaml file on your minikube cluster (or any other kubernetes cluster):
-
Clone this repository:
git clone https://github.com/Hamza-Mandviwala/simple-nginx-demo-app-minikube.git
-
Navigate into the cloned repo directory:
cd simple-nginx-demo-app-minikube
-
Run the following command. This should create the
nginxdemo
pod and thenginxdemo-svc
service.kubectl apply -f nginxdemo-pod-svc.yaml
-
Run a
kubectl get svc
command to get the port number on which the nginxdemo-svc service will be serving the UI:Output:
As we can see from the above screenshot, port number 32165 on the machine will be used to serve the app requests.
-
We can now try to access the nginxdemo UI through the browser using the IP address of the minikube VM and port 32165. Alternatively, we can also run the command
minikube service nginxdemo-svc
(where 'nginxdemo-svc' is the service name) which will automatically open up the browser tab with the nginxdemo UI:
====================================================================================
Congratulations! We just deployed a simple nginxdemo application on a locally hosted minikube cluster.
====================================================================================
- Detailed guide for RedHat OpenShift 4.10 installation on GCP using UPI (User Provisioned Infrastructure method)
- Understanding a Two-tier Kubernetes application architecture on AWS