为何写这篇文章?!

主要在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签名的私钥。

 

原文地址:http://www.cnblogs.com/jinzhenshui/p/16908075.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性