简体   繁体   中英

Is there a way to access kubernetes dashboard by passing token on the url?

I am able to access my kubernetes dashoard UI by accessing below url and providing the token and hitting sign in button on the login screen

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/workloads?namespace=default

Is there a way I can pass the token via the URL itself so the Dashboard UI opens in logged in state so i don't need to manually past the token and hit sign in?

I am looking for something like this (which was suggested by ChatGPT which unfortunately didn't work, this just opens the login screen again):

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/?token=<authentication-token>

We can access the kubernetes dashboard UI by two ways

  1. Bearer token
  2. KubeConfig

As to answer your question, we can't login by encoding the token in the URL. But we can use Skip option to avoid giving the token every time we login .

To enable the Skip button to appear in UI we need to add following flags in the dashboard deployment under args section

--enable-skip-login
--disable-settings-authorizer

After adding these flags the deployment looks something like this

spec:
      containers:
      - name: kubernetes-dashboard
        image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
        ports:
        - containerPort: 8443
          protocol: TCP
        args:
          - --enable-skip-login
          - --disable-settings-authorizer        
          - --auto-generate-certificates
          
          # If not specified, Dashboard will attempt to auto discover the API server and connect
          # to it. Uncomment only if the default does not work.
          # - --apiserver-host=http://my-address:port
        volumeMounts:

Now when you redeploy the dashboard you are able to see the Skip button. By skipping the login will save a lot of time when testing locally deployed clusters.

Note: This is not a suggested method in terms of security standpoint. However, if you are deploying in an isolated testing environment you can proceed with the above steps.

For more information refer this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM