k8s:服务账号service-account相关参数设置:【重点一篇文章】
为何写这篇文章?!
主要在k8s中,service account 是很要要的一个安全特性,官方资料、以及网上资料对这款的 相关参数配置又语焉不详。
这里也是自己的理解和解释。如有不对,请指正。
apiserver的配置
kube-apiserver \ --etcd-servers=http://127.0.0.1:2379 \ --service-cluster-ip-range=10.0.0.0/24 \ --tls-cert-file=/root/tls/apiserver.crt \ --tls-private-key-file=/root/tls/apiserver.pem \ --client-ca-file=/root/tls/ca.crt \ --enable-bootstrap-token-auth=true \ --service-account-issuer=https://kubernetes.service.account.issuer \ --service-account-signing-key-file=/root/tls/sa.pem \ --service-account-key-file=/root/tls/sa.crt \ --feature-gates=LegacyServiceAccountTokenNoAutoGeneration=false \ #无效果的配置,应在controller中设置该开关
controller的配置
kube-controller-manager \ --kubeconfig=/root/tls/kubeconfig.yaml \ --cluster-signing-cert-file=/root/tls/ca.crt \ --cluster-signing-key-file=/root/tls/ca.pem \ --cluster-signing-duration=87600h \ --root-ca-file=/root/tls/ca.crt \ --allocate-node-cidrs=true \ --cluster-cidr=10.244.0.0/16 \ --service-account-private-key-file=/root/tls/sa.pem \ --feature-gates=LegacyServiceAccountTokenNoAutoGeneration=false \
附注:
######## apiserver ########
--service-account-issuer stringArray
Identifier of the service account token issuer.
The issuer will assert this identifier in "iss" claim of issued tokens.
This value is a string or URI. In practice, this means that service-account-issuer must be an https URL.
When this flag is specified multiple times, the first is used to generate tokens
and all are used to determine which issuers are accepted.
概要翻译:标识sa账号token的发行者;必须是https格式的url地址;(k8s新版)可以设置多个值——第1个用来对token进行签名,其他的表示可以合法接受
--service-account-signing-key-file string
The file that contains the 【private】 key of the service account token issuer.
The issuer will sign issued ID tokens with this private key.
As following, you must specify "--service-account-key-file".
概要翻译:sa账号token的签名私钥。注意是私钥! 同时要求设置“--service-account-key-file”参数。
特别说明:这个“--service-account-signing-key-file ”参数就是令人困惑的地方,它的名字内多了“signing” ,还要求是私钥。
官方及网上资料说不清楚的地方就是这个参数。
其实它就是sa账号token的签名公私钥对中的私钥,也就是controller的配置参数中的“--service-account-private-key-file”!
为什么不用相同的参数名字!!!!!
--service-account-key-file stringArray
File containing 【private or public】keys, used to verify ServiceAccount tokens.
The specified file can contain multiple keys,
and the flag can be specified multiple times with different files.
概要翻译:sa账号token的签名公钥。可以指定多个或多次指定。
特别说明:目前我自己也没搞清楚多次指定如何使用??? 因为,在controller中对应的“--service-account-private-key-file”没有说明可以指定多次!
######## controller manager ########
--service-account-private-key-file string
Filename containing a 【private】key used to sign service account tokens.
概要翻译:sa账号token签名的私钥。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
2016-11-20 ubuntu-15.10-server-i386.iso 安装 Oracle 11gR2 数据库
2016-11-20 ubuntu-15.04-server-i386.iso 安装 Oracle 11gR2 数据库
2012-11-20 Sqlserver 2005+:查看索引【index】的【使用情况】:无效的索引、高成本索引
2012-11-20 Sqlserver 2005+:查看索引【index】的【碎片】
2012-11-20 Sqlserver 2005+:数据库【推荐】的【丢失索引】信息
2012-11-20 Sqlserver 2005+:【当前】【正在运行】的【进程会话的请求信息】