Joe Blog

升级了新版本的Dashboard(这里使用的v1.8.3),使用了较为复杂的双因子登录,正确输入用户名和密码之后还需要Token或者kubeconfig再次认证,保障了系统安全,同时也带来了一些不便。默认的Token失效时间是900秒,也就是15分钟,这意味着你每隔15分钟就要认证一次。

// Expiration time (in seconds) of tokens generated by dashboard. Default: 15 min.
DefaultTokenTTL = 900

  详细源码可以参考:Expiration time ,显然我们可以设置更长的时间来满足需求。

操作

参数名 默认值 说明
token-ttl 15 minutes Expiration time (in seconds) of JWE tokens generated by dashboard. Default: 15 min. 0 - never expires.

  Dashboard的Token失效时间可以通过 token-ttl 参数来设置,修改创建Dashboard的yaml文件,并重新创建即可。

ports:
- containerPort: 8443
  protocol: TCP
args:
  - --auto-generate-certificates
  - --token-ttl=43200

  除了删除后重新创建,也可以直接修改原有Dashboard的配置,使用kubectl或者Dashboard可视化页面操作。

![image.png center 674x244](http://upload-images.jianshu.io/upload_images/3481257-caa9bf83eb3090a5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

添加token-ttl参数后,更新即可。

![image.png center 562x154](http://upload-images.jianshu.io/upload_images/3481257-f610866c67c1b7ae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
kubectl edit deployment kubernetes-dashboard -n kube-system

  同理,添加相同参数,更新即可。

dashboard参数 https://github.com/kubernetes/dashboard/wiki/Dashboard-arguments