简体   繁体   English

有没有办法通过在 url 上传递令牌来访问 kubernetes 仪表板?

[英]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我可以通过访问下面的 url 并提供令牌并点击登录屏幕上的登录按钮来访问我的 kubernetes dashoard UI

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?有没有一种方法可以通过 URL 本身传递令牌,以便仪表板 UI 在登录状态下打开,这样我就不需要手动通过令牌并点击登录?

I am looking for something like this (which was suggested by ChatGPT which unfortunately didn't work, this just opens the login screen again):我正在寻找这样的东西(这是由 ChatGPT 建议的,不幸的是没有用,这只会再次打开登录屏幕):

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我们可以通过两种方式访问kubernetes dashboard UI

  1. Bearer token 不记名令牌
  2. KubeConfig KubeConfig

As to answer your question, we can't login by encoding the token in the URL.至于回答你的问题,我们无法通过在 URL 中编码令牌来登录。 But we can use Skip option to avoid giving the token every time we login .但是我们可以使用Skip选项来避免每次登录时都给令牌

To enable the Skip button to appear in UI we need to add following flags in the dashboard deployment under args section要使“ Skip ”按钮出现在 UI 中,我们需要在args部分下的仪表板部署中添加以下标志

--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.现在,当您重新部署仪表板时,您可以看到“ Skip ”按钮。 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有关更多信息,请参阅此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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