Unable to access minikube IP address

Viewed 1996

I am an absolute beginner to Kubernetes, and I was following this tutorial to get started. I have managed writing the yaml files. However once I deploy it, I am not able to access the web app.

This is my webapp yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
 name: webapp-deployment
 labels:
  app: webapp
spec:
 replicas: 1
 selector:
  matchLabels:
   app: webapp
 template:
  metadata:
   labels:
    app: webapp
spec:
  containers:
  - name: webapp
    image: nanajanashia/k8s-demo-app:v1.0
    ports:
    - containerPort: 3000
    env:
    - name: USER_NAME
      valueFrom:
        secretKeyRef:
          name: mongo-secret
          key: mongo-user
    - name: USER_PWD
      valueFrom:
        secretKeyRef:
          name: mongo-secret
          key: mongo-password
    - name: DB_URL
      valueFrom:
        configMapKeyRef:
          name: mongo-config
          key: mongo-url

apiVersion: v1 kind: Service metadata: name: webapp-servicel spec: type: NodePort selector: app: webapp ports: - protocol: TCP port: 3000 targetPort: 3000 nodePort: 30200

When I run the command : kubectl get node

> Blockquote

When I run the command: kubectl get pods, i can see the pods running enter image description here

kubectl get svc enter image description here

I then checked the logs for webapp, I dont see any errors enter image description here

I then checked the details logs by running the command: kubectl describe pod podname enter image description here

I dont see any obvious errors in the result above, but again I am not experienced enough to check if there is any config thats not set properly.

Other things I have done as troubleshooting

  1. Ran the following command for the minikube to open up the app : minikube service webapp-servicel, it opens up the web page, but again does not connect to the IP.
  2. Uninstalled minikube, kubectl and all relevant folders, and run everything again.
  3. pinged the ip address directly from command line, and cannot reach.

I would appreciate if someone can help me fix this.

4 Answers

Try these 3 options

  1. can you do the kubectl get node -o wide and get the ip address of node and then open in web browser NODE_IP_ADDRESS:30200

  2. Alternative you can run this command minikube service <SERVICE_NAME> --url which will give you direct url to access application and access the url in web browser.

  3. kubectl port-forward svc/<SERVICE_NAME> 3000:3000 and access application on localhost:3000

I got stuck here as well. After looking through some of the gitlab issues, I found a helpful tip about the minikube driver. The instructions for starting minikub are incorrect in the video if you used

minikube start -driver docker

Here's how to fix your problem.

  1. stop minikube

    minikube stop

  2. delete minikube (this deletes your cluster)

    minikube delete

  3. start up minikube again, but this time specify the hyperkit driver

    minikube start --vm-driver=hyperkit

  4. check status

    minikube status

  5. reapply your components in this order by.

    kubectl apply -f mongo-config.yaml kubectl apply -f mongo-secret.yaml kubectl apply -f mongo.yaml kubectl aplly -f webapp.yaml

  6. get your ip

    minikube ip

  7. open a browser, go to ip address:30200 (or whatever the port you defined was, mine was 30100). You should see an image of a dog and a form.

Some information in this SO post is useful too.

On Windows 11 with Ubuntu 20.04 WSL, it worked for me by using:

minikube start --driver=hyperv

Related