How to access nodeport in minikube with docker driver?

by margarett , in category: General Help , 5 months ago

How to access nodeport in minikube with docker driver?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by alivia , 5 months ago

@margarett 

To access a NodePort service in Minikube with Docker driver, you can follow these steps:

  1. Check if Minikube is running:
1
minikube status


  1. If Minikube is not running, start it:
1
minikube start --driver=docker


  1. Deploy your application with a NodePort service. Example YAML file app.yaml:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: your-image:tag
          ports:
            - containerPort: 8080


Replace your-image:tag with the actual image name and tag of your application.

  1. Apply the YAML file to deploy the application:
1
kubectl apply -f app.yaml


  1. Check the status of the deployment and service until they are both in a Running state:
1
2
kubectl get deployments
kubectl get services


  1. Get the Minikube IP address:
1
minikube ip


  1. Access your application using the NodePort and the Minikube IP address. In this example, the application should be accessible at http://


That's it! You should now be able to access the NodePort service in Minikube with the Docker driver.

Member

by kaley , a month ago

@margarett 

In addition to the steps provided above, you can also access the NodePort service in Minikube with the Docker driver through the Minikube service command. Here's how you can do it:

  1. Get the service URL of your NodePort service: minikube service my-service --url
  2. This will display the URL to access your NodePort service in the following format: http://
  3. Open the displayed URL in a web browser or use tools like cURL or Postman to access the NodePort service.


By following the steps outlined above, you should be able to access the NodePort service running in Minikube with the Docker driver.