k8s1.24+ dashboard不能自动生成token的问题

创建k8s-admin.yaml文件

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: admin
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: admin
  namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin
  namespace: kube-system
  labels:
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile

~                                                           

根据yaml文件配置内容创建更新资源对象,可以看到没有生成admin-token类似字眼

root@ubt:/# kubectl apply -f k8s-admin.yaml 
clusterrolebinding.rbac.authorization.k8s.io/admin created
serviceaccount/admin created
root@ubt:/# kubectl get secrets -n kube-system
NAME                              TYPE                            DATA   AGE
bootstrap-token-q7dfxz            bootstrap.kubernetes.io/token   6      20h
bootstrap-token-xcpobh            bootstrap.kubernetes.io/token   7      21h
kubernetes-dashboard-certs        Opaque                          0      19h
kubernetes-dashboard-key-holder   Opaque                          2      107m

较早版本会自动生成secret,v1.28.2版本需要手动生成,执行命令即可。

root@ubt:/# kubectl create token admin  --namespace kube-system
eyJhbGciOiJSUzI1NiIsImtpZCI6InV2SUtYXzI2WEk4XzVwX1I4OEZvU0Y3TktBdUpReGNyeGY1Mlg0dlJGWGMifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNzE1OTI3MDI3LCJpYXQiOjE3MTU5MjM0MjcsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsInNlcnZpY2VhY2NvdW50Ijp7Im5hbWUiOiJhZG1pbiIsInVpZCI6ImRlOTEyZDI0LTUzOTgtNGFiYi1hYjYyLTdiYjhiMzIxYzBlZiJ9fSwibmJmIjoxNzE1OTIzNDI3LCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4ifQ.wYAbvl7_de5K-Sl1CyZbQsvwmLqwR6nJOS5AKEOEsvDFCXYFHAFfSNOMutZ0tbc-eeTMkwpHgRgyJeEs6qkIWEZRt3uWLSiLAtMPYENmaVxdogqBNtqG9Ldcaknt2eCu8mdA599ezkSC9F5lHK07kNpuyVCRTktdAviy3iu736wWUrw0n8-_GiWZDRkTUW7_C46Ym603SckW_7Z5TyoyK_Jv0Hinb3D89UztOlonqDEuzMgTeZxDx01rE6UxkMc8acIGUZfh8o7aRs2BGyKBSDSrFnslZIP2XDESk0Ma3w0MLAd3luzosRZHyaSqkSZc7ZOOdDN3uQykrrJQyOGJjA

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值