kuberneteskubernetes-dashboard

Cannot configure remote access to Kubernetes Dashboard


I want to configure Kubernetes Dashboard on a remote server using this guide: https://k21academy.com/docker-kubernetes/kubernetes-dashboard/

I installed it using:

kubernetes@kubernetes1:~$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/recommended.yaml

List service:

kubernetes@kubernetes1:~$ kubectl get all -n kubernetes-dashboard
NAME                                             READY   STATUS    RESTARTS   AGE
pod/dashboard-metrics-scraper-64bcc67c9c-q8f7j   1/1     Running   0          71m
pod/kubernetes-dashboard-66c887f759-pq58q        1/1     Running   0          71m

NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/dashboard-metrics-scraper   ClusterIP   10.105.143.75    <none>        8000/TCP   71m
service/kubernetes-dashboard        ClusterIP   10.102.209.213   <none>        443/TCP    71m

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/dashboard-metrics-scraper   1/1     1            1           71m
deployment.apps/kubernetes-dashboard        1/1     1            1           71m

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/dashboard-metrics-scraper-64bcc67c9c   1         1         1       71m
replicaset.apps/kubernetes-dashboard-66c887f759        1         1         1       71m
kubernetes@kubernetes1:~$

But when I try to edit the port according to the guide I get:

kubernetes@kubernetes1:~$ kubectl edit service/kubernetes-dashboard
Error from server (NotFound): services "kubernetes-dashboard" not found
kubernetes@kubernetes1:~$

Do you know how I can change the port?


Solution

  • Seems like you are looking into default or some other namespace.

    you can try

    kubectl edit service/kubernetes-dashboard -n kubernetes-dashboard
    

    A nice tool for namespace switching

    curl -LO https://github.com/kvaps/kubectl-use/raw/master/kubectl-use
    chmod +x ./kubectl-use
    sudo mv ./kubectl-use /usr/local/bin/kubectl-use
    

    then

    kubectl use kubernetes-dashboard
    

    After this, you do not need to specify namespace -n kubernetes-dashboard in the edit command, or kubectl get pods, it will use kubernetes-dashboard as a default context.

    kubectl-use