gpt4 book ai didi

kubernetes - 如何避免将默认密码附加到 ServiceAccount?

转载 作者:行者123 更新时间:2023-12-02 12:22:41 24 4
gpt4 key购买 nike

我正在尝试创建一个没有 secret 或只有我指定的 secret 的服务帐户,而无论怎样,kubelet 似乎总是附加默认 secret 。

服务帐户定义

apiVersion: v1
automountServiceAccountToken: false
kind: ServiceAccount
metadata:
name: test
secrets:
- name: default-token-4pbsm

提交

$ kubectl create -f service-account.yaml
serviceaccount "test" created

获取

$ kubectl get -o=yaml serviceaccount test
apiVersion: v1
automountServiceAccountToken: false
kind: ServiceAccount
metadata:
creationTimestamp: 2017-05-30T12:25:30Z
name: test
namespace: default
resourceVersion: "31414"
selfLink: /api/v1/namespaces/default/serviceaccounts/test
uid: 122b0643-4533-11e7-81c6-42010a8a005b
secrets:
- name: default-token-4pbsm
- name: test-token-5g3wb

正如您在上面看到的那样,test-token-5g3wb 是自动创建并附加到服务帐户的,我没有指定它。

据我所知,automountServiceAccountToken 只会影响将这些 secret 安装到通过该服务帐户启动的 pod。 (?)

有什么方法可以避免创建和附加默认 secret ?

版本

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T20:41:24Z", GoVersion:"go1.8.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:33:17Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}

最佳答案

你对automountServiceAccountToken的理解是对的,它是为即将启动的pod准备的。

token 自动添加由 token Controller 完成。即使您编辑配置以删除 token ,它也会被再次添加。

You must pass a service account private key file to the token controller in the controller-manager by using the --service-account-private-key-file option. The private key will be used to sign generated service account tokens. Similarly, you must pass the corresponding public key to the kube-apiserver using the --service-account-key-file option. The public key will be used to verify the tokens during authentication.

以上摘自k8s docs .所以尽量不要传递这些标志,但不确定该怎么做。但我不建议这样做。

还有 this doc你可能会有所帮助。

关于kubernetes - 如何避免将默认密码附加到 ServiceAccount?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44262350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com