Skip to content

atulkamble/minikube-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minikube-nginx

Minikube NGINX Setup: Deploying and Exposing NGINX on Kubernetes

Minikube-NGINX Setup

This guide will walk you through running an NGINX app on a Minikube cluster. Follow the instructions below to set up the necessary Kubernetes configurations and deploy your NGINX app.

Prerequisites

  • Minikube installed and running
  • kubectl installed
  • Basic knowledge of Kubernetes and YAML configuration files

Steps

1. Start Minikube

First, start your Minikube cluster. This command will initiate a local Kubernetes cluster using Minikube.

minikube start

2. Create a Project Directory

Create a new directory for your project and navigate into it.

mkdir Project
cd ./Project/

3. Create Deployment File

Now, create a deployment.yaml file using the following command. You will edit this file to define the Kubernetes Deployment for NGINX.

New-Item deployment.yml
New-Item deployment.yaml
rm ./deployment.yml
notepad deployment.yaml

Edit the deployment.yaml file to define the NGINX deployment. Example content:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

4. Apply the Deployment

Once the deployment.yaml file is ready, apply the deployment configuration to the Minikube cluster.

kubectl apply -f deployment.yaml

5. Create Service File

Next, create a service.yaml file to expose your NGINX app as a service.

New-Item service.yaml
notepad service.yaml

Edit the service.yaml file with the following content:

apiVersion: v1
kind: Service
metadata:
  name: access-app-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: NodePort

6. Apply the Service Configuration

After editing the service.yaml file, apply the service configuration.

kubectl apply -f service.yaml

7. Verify Kubernetes Resources

Check the nodes and services to ensure that the deployment and service are running.

kubectl get nodes
kubectl get services

8. Access the Service

To access your NGINX app, use the following command to open the service in your default browser.

minikube service access-app-service

This will expose your NGINX app on a Minikube local IP.

Conclusion

Now you have successfully deployed an NGINX application on Minikube and exposed it through a Kubernetes service. You can modify the deployment and service configurations as needed.

For more information, check the Minikube documentation and the Kubernetes documentation.

About

Minikube Project runnning nginx container

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published