EenProgrammeur
EenProgrammeur

Reputation: 279

Kubernetes (Minikube) external ip does not work

I am new to Kubernetes and i have been browsing looking and reading why my external ip is not resolving.

I am running minikube on a ubuntu 16.04 distro.

In the services overview of the dashboard i have this

    my-nginx | run: my-nginx | 10.0.0.11 | my-nginx:80 TCP my-nginx:32431 | TCP 192.168.42.71:80 

When i do an http get at http://192.168.42.165:32431/ i get the nginx page.

The configuration of the service is as follows

    # Please edit the object below. Lines beginning with a '#' will be ignored,
    # and an empty file will abort the edit. If an error occurs         while saving this file will be
    # reopened with the relevant failures.
    #
    apiVersion: v1
    kind: Service
    metadata:
      creationTimestamp: 2016-09-23T12:11:13Z
      labels:
        run: my-nginx
      name: my-nginx
      namespace: default
      resourceVersion: "4220"
      selfLink: /api/v1/namespaces/default/services/my-nginx
      uid: d24b617b-8186-11e6-a25b-9ed0bca2797a
    spec:
      clusterIP: 10.0.0.11
      deprecatedPublicIPs:
      - 192.168.42.71
      externalIPs:
      - 192.168.42.71
      ports:
      - nodePort: 32431
        port: 80
        protocol: TCP
        targetPort: 80
      selector:
        run: my-nginx
      sessionAffinity: None
      type: LoadBalancer
    status:
      loadBalancer: {}

These are parts of my ifconfog

    virbr0    Link encap:Ethernet  HWaddr fe:54:00:37:8f:41  
              inet addr:192.168.122.1  Bcast:192.168.122.255          Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:4895 errors:0 dropped:0 overruns:0 frame:0
              TX packets:8804 errors:0 dropped:0 overruns:0         carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:303527 (303.5 KB)  TX bytes:12601315 (12.6         MB)

    virbr1    Link encap:Ethernet  HWaddr fe:54:00:9a:39:74  
              inet addr:192.168.42.1  Bcast:192.168.42.255          Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:7462 errors:0 dropped:0 overruns:0 frame:0
              TX packets:12176 errors:0 dropped:0 overruns:0         carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:3357881 (3.3 MB)  TX bytes:88555007 (88.5 MB)


    vnet0     Link encap:Ethernet  HWaddr fe:54:00:37:8f:41  
              inet6 addr: fe80::fc54:ff:fe37:8f41/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:4895 errors:0 dropped:0 overruns:0 frame:0
              TX packets:21173 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:372057 (372.0 KB)  TX bytes:13248977 (13.2 MB)

    vnet1     Link encap:Ethernet  HWaddr fe:54:00:9a:39:74  
              inet addr:192.168.23.1  Bcast:0.0.0.0          Mask:255.255.255.255
              inet6 addr: fe80::fc54:ff:fe9a:3974/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:7462 errors:0 dropped:0 overruns:0 frame:0
              TX packets:81072 errors:0 dropped:0 overruns:0         carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:3462349 (3.4 MB)  TX bytes:92936270 (92.9 MB)

Does anyone have some pointers, because i am lost?

Upvotes: 27

Views: 46900

Answers (5)

Maheshvirus
Maheshvirus

Reputation: 7523

Minikube External IP :

minikube doesn’t allow to access the external IP`s directly for the service of a kind NodePort or LoadBalancer.

We don’t get the external IP to access the service on the local system. So the good option is to use minikube IP

Use the below command to get the minikube IP once your service is exposed.

minikube service service-name --url

Now use that URL to serve your purpose.

Upvotes: 5

Payam Khaninejad
Payam Khaninejad

Reputation: 7996

If you're running Minikube on windows just run:

minikube tunnel

Note: It must be run in a separate terminal window to keep the tunnel open.

The above command will tunnel your container to localhost. then you can get your service URL by:

kubectl get services [service name]

replace [service name] with your service name. don't forget to add a mapped port on the external IP endpoint.

Upvotes: 7

Stephen
Stephen

Reputation: 8168

TL;DR minikube has "addons" which you can use to handle ingress and load balancing. Just enable and configure one of those.

https://medium.com/faun/metallb-configuration-in-minikube-to-enable-kubernetes-service-of-type-loadbalancer-9559739787df

Upvotes: 0

Ezwig
Ezwig

Reputation: 448

Minikube doesn't support LoadBalancer services, so the service will never get an external IP.

But you can access the service anyway with its external port.

You can get the IP and PORT by running:

minikube service <service_name>

Upvotes: 23

Kamil
Kamil

Reputation: 461

I assume you are using minikube in virtualbox (there was no info how do you start it and what is your host OS).

When you create a service with type=LoadBalancer you should also run minikube tunnel to expose LoadBalancers from cluster. Then when you run kubectl get svc you will get external IP of LoadBalancer. Still it's minikube's IP, so if you want to expose it externally from your machine you should put some reverseproxy or tunnel on your machine.

Upvotes: 10

Related Questions