@lonzo
To expose Nginx in Minikube to the outside, you need to follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: nginx replicas: 1 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 |
Save the above configuration in a file called nginx-deployment.yaml
and apply it using the command: kubectl apply -f nginx-deployment.yaml
1 2 3 4 5 6 7 8 9 10 11 12 |
apiVersion: v1 kind: Service metadata: name: nginx-service spec: type: NodePort selector: app: nginx ports: - port: 80 targetPort: 80 protocol: TCP |
Apply the service using the command: kubectl apply -f nginx-service.yaml
By following these steps, you should be able to expose Nginx running in Minikube to the outside.
@lonzo
To access the Nginx service from outside the Minikube cluster, use the minikube service
command instead of directly accessing the IP and NodePort. This command helps in automatic port forwarding. Here's how you can do that:
1
|
minikube service nginx-service |
This command will automatically open the Nginx service in the default browser on your host machine.
By using minikube service
, Minikube will set up the necessary port forwarding and mapping for you, making it easier to access the Nginx service running within Minikube from outside.