skip to Main Content

I have been able to successfully setup kubernetes on my Centos 7 server.
On trying to get the dashboard working after following the documentation, running ‘kubectl proxy’ it
attempts to run using 127.0.0.1:9001 and not my server ip. Do this mean I cannot access kubernetes dashboard outside the server?
I need help on getting the dashboard running using my public ip

2

Answers


  1. As I understand, you would like to access the dashboard from your laptop. What you should do is create an admin account called k8s-admin:

    $ kubectl --namespace kube-system create serviceaccount k8s-admin
    $ kubectl create clusterrolebinding k8s-admin --serviceaccount=kube-system:k8s-admin --clusterrole=cluster-admin
    

    Then setup kubectl on your laptop, e.g. for macOS it looks like this (see documentation):

    $ brew install kubernetes-cli
    

    Setup a proxy to your workstation. Create a ~/.kube directory on your laptop and then scp the ~/.kube/config file from the k8s (Kubernetes) master to your ~/.kube directory.

    Then get the authentication token you need to connect to the dashboard:

    $ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep k8s-admin | awk '{print $1}')
    

    Now start the proxy:

    $ kubectl proxy
    

    Now open the dashboard by going to:

    http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
    

    You should see the Token option and then copy-paste the token from the prior step and Sign-In.

    You can follow this tutorial.

    Login or Signup to reply.
  2. You can specify on which address you want to run kubectl proxy, i.e.

    kubectl proxy --address <EXTERNAL-IP> -p 9001
    Starting to serve on 100.105.***.***:9001
    

    You can also use port forwarding to access the dashboard.

    kubectl port-forward --address 0.0.0.0 pod/dashboard 8888:80
    

    This will listen port 8888 on all addresses and route traffic directly to your pod.

    For instance:

    rsha:~$ kubectl port-forward --address 0.0.0.0 deploy/webserver 8888:80
    Forwarding from 0.0.0.0:8888 -> 80
    

    In another terminal running

    rsha:~$ curl 100.105.***.***:8888
    <html><body><h1>It works!</h1></body></html>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search