在ServiceAccount中不会自动生成一个可安装的秘密和令牌
我下载了Kubernetes与Jenkins集成并创建了ServiceAccount,但秘密并非自动创建。
过去,我记得自动创建了一个秘密,并在创建ServiceAccount时安装了令牌。
如何像以前一样自动创建一个秘密?
I downloaded Kubernetes for integration with Jenkins and created a Serviceaccount, but the secret is not automatically created.
In the past, I remember that a Secret was automatically created and the Token was mounted when Serviceaccount was created.
How can I automatically create a Secret as before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如@P ....在Kubernetes版本1.24中所述,此行为已更改, legacyserviceaccounttokennoautogenation 默认情况下启用了1.24中的功能门。
包含服务帐户令牌的新秘密不再是自动生成的,并且在1.24+中的秘密中不会自动环境。现有的包含服务帐户令牌的秘密仍然可用。
API客户端从自动生成的秘密API对象刮擦令牌内容必须开始使用 tokenrequest api 获得令牌(首选,在所有受支持的版本中可用),或者,如果需要/需要一个基于秘密的令牌,则可以明确要求基于秘密的令牌。
请参阅手动创建服务帐户API令牌明确要求基于秘密的令牌。
As mentioned by @P.... In kubernetes version 1.24 this behaviour has been changed, the LegacyServiceAccountTokenNoAutoGeneration feature gate is enabled by default in 1.24.
New secrets containing service account tokens are no longer auto-generated and are not automatically ambient in secrets in 1.24+. Existing secrets containing service account tokens are still usable.
API clients scraping token content from auto-generated Secret API objects must start using the TokenRequest API to obtain a token (preferred, available in all supported versions), or you can explicitly request a secret-based token if a secret-based token is desired/needed.
Refer manually create a service account API token to explicitly request a secret-based token.
您可以将以下两个清单放入YAML文件中,并应用它们,也可以从命令行中进行操作:
在这里,我们有一个秘密,该秘密拥有证书和令牌:
You can put the below two manifests into YAML files and and apply them or you can do it from the command line like this:
Here we have a secret which holds a certificate and a token:
上面的答案并不能完全恢复1.24前的行为,但是我发现以下确实可以恢复它。
这可以解决我以前在运行时看到的错误,
这是在丢弃错误的
零件上丢失的零件正在配置服务帐户,以允许POD通过设置“秘密”列表来使用秘密。
The answers above do not completely restore the pre 1.24 behaviour, however I have found that the below does restore it.
This resolves the error I was previously seeing when running
Which was throwing the error
The part missing in the answers above is configuring the service account to allow the secret to be used by pods by setting the "secrets" list.
您可以使用选项
automountserviceaccounttoken启用它:true
else删除选项
automountserviceaccounttoken
,默认情况下它将创建秘密You can enabled it using the option
automountServiceAccountToken: true
else remove the option
automountServiceAccountToken
, by default it will create secret