gpt4 book ai didi

templates - 有没有办法通过模板将 imagePullSecrets 添加到默认的 ServiceAccount?

转载 作者:行者123 更新时间:2023-12-05 06:56:00 27 4
gpt4 key购买 nike

我必须将参数化的 Secrets 添加到默认的 ServiceAccount。我试图将默认的 ServiceAccount 作为对象添加到模板中,但这似乎没有任何作用。

或者我应该创建一个新的 SA,注入(inject)这些 Secret 并在 DC 中使用 useServiceAccount: newSA 引用它?

谢谢!!

最佳答案

正如评论中提到的@user6242207

What I ended up using was to create a new Service Account with the template, add the secrets I needed and link the Service Account to all DC's that needed it.


澄清一下,有 Kubernetes documentation它一步一步地描述了一切。

1.创建一个imagePullSecret

Create an imagePullSecret, as described in Specifying ImagePullSecrets on a Pod.

kubectl create secret docker-registry myregistrykey --docker-server=DUMMY_SERVER \
--docker-username=DUMMY_USERNAME --docker-password=DUMMY_DOCKER_PASSWORD \
--docker-email=DUMMY_DOCKER_EMAIL

验证它是否已创建。

kubectl get secrets myregistrykey

2.服务账号添加镜像pull secret

Modify the default service account for the namespace to use this secret as an imagePullSecret.

kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "myregistrykey"}]}'

You can instead use kubectl edit, or manually edit the YAML manifests as shown below:

kubectl get serviceaccounts default -o yaml > ./sa.yaml

3.也可以验证结果

Now, when a new Pod is created in the current namespace and using the default ServiceAccount, the new Pod has its spec.imagePullSecrets field set automatically:

kubectl run nginx --image=nginx --restart=Never
kubectl get pod nginx -o=jsonpath='{.spec.imagePullSecrets[0].name}{"\n"}'

输出应该是:

myregistrykey

如果您使用 Open Shift,那么这个 documentation可能更有用。

关于templates - 有没有办法通过模板将 imagePullSecrets 添加到默认的 ServiceAccount?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65201040/

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