how to access local kubernetes minikube dashboard remotely

前端 未结 9 472
离开以前
离开以前 2021-01-30 14:46

Kubernetes newbie (or rather basic networking) question: Installed single node minikube (0.23 release) on a ubuntu box running in my lan (on IP address 192.168

相关标签:
9条回答
  • 2021-01-30 15:11

    Wanted to link this answer by iamnat.

    https://stackoverflow.com/a/40773822

    1. Use minikube ip to get your minikube ip on the host machine
    2. Create the NodePort service
    3. You should be able to access the configured NodePort id via < minikubeip >:< nodeport >

    This should work on the LAN as well as long as firewalls are open, if I'm not mistaken.

    0 讨论(0)
  • 2021-01-30 15:13

    I was able to get running with something as simple as:

    kubectl proxy --address='0.0.0.0' --disable-filter=true
    
    0 讨论(0)
  • 2021-01-30 15:13

    @Jeff provided the perfect answer, put more hints for newbies.

    1. Start a proxy using @Jeff's script, as default it will open a proxy on '0.0.0.0:8001'.

      kubectl proxy --address='0.0.0.0' --disable-filter=true
      
    2. Visit the dashboard via the link below:

      curl http://your_api_server_ip:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/
      

    More details please refer to the officially doc.

    0 讨论(0)
  • 2021-01-30 15:15

    I had the same problem recently and solved it as follows:

    1. Get your minikube VM onto the LAN by adding another network adapter in bridge network mode. For me, this was done through modifying the minikube VM in the VirtualBox UI and required VM stop/start. Not sure how this would work if you're using hyperkit. Don't muck with the default network adapters configured by minikube: minikube depends on these. https://github.com/kubernetes/minikube/issues/1471
    2. If you haven't already, install kubectl on your mac: https://kubernetes.io/docs/tasks/tools/install-kubectl/
    3. Add a cluster and associated config to the ~/.kube/config as below, modifying the server IP address to match your newly exposed VM IP. Names can also be modified if desired. Note that the insecure-skip-tls-verify: true is needed because the https certificate generated by minikube is only valid for the internal IP addresses of the VM.

      clusters:
      - cluster:
          insecure-skip-tls-verify: true
          server: https://192.168.0.101:8443
        name: mykubevm
      contexts:
      - context:
          cluster: mykubevm
          user: kubeuser
        name: mykubevm
      users:
      - name: kubeuser
        user:
          client-certificate: /Users/myname/.minikube/client.crt
          client-key: /Users/myname/.minikube/client.key
      
    4. Copy the ~/.minikube/client.* files referenced in the config from your linux minikube host. These are the security key files required for access.

    5. Set your kubectl context: kubectl config set-context mykubevm. At this point, your minikube cluster should be accessible (try kubectl cluster-info).

    6. Run kubectl proxy http://localhost:8000 to create a local proxy for access to the dashboard. Navigate to that address in your browser.

    It's also possible to ssh to the minikube VM. Copy the ssh key pair from ~/.minikube/machines/minikube/id_rsa* to your .ssh directory (renaming to avoid blowing away other keys, e.g. mykubevm & mykubevm.pub). Then ssh -i ~/.ssh/mykubevm docker@<kubevm-IP>

    0 讨论(0)
  • 2021-01-30 15:17

    Thanks for your valuable answers, If you have to use the kubectl proxy command unable to view permanently, using the below "Service" object in YAML file able to view remotely until you stopped it. Create a new yaml file minikube-dashboard.yaml and write the code manually, I don't recommend copy and paste it.

    apiVersion : v1
    kind: Service
    metadata:
      labels:
        app: kubernetes-dashboard
      name: kubernetes-dashboard-test
      namespace: kube-system
    spec:
      ports:
      - port: 80
        protocol: TCP
        targetPort: 9090
        nodePort: 30000
      selector:
        app: kubernetes-dashboard
      type: NodePort
    

    Execute the command,

    $ sudo kubectl apply -f minikube-dashboard.yaml
    

    Finally, open the URL: http://your-public-ip-address:30000/#!/persistentvolume?namespace=default

    0 讨论(0)
  • 2021-01-30 15:17

    Slight variation on the approach above.

    I have an http web service with NodePort 30003. I make it available on port 80 externally by running:

    sudo ssh -v -i ~/.ssh/id_rsa -N -L 0.0.0.0:80:localhost:30003 ${USER}@$(hostname)

    0 讨论(0)
提交回复
热议问题