gpt4 book ai didi

rest - Kubernetes Rest API 用于更改 Pod 中现有的 secret/configmap

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

我已经使用 kubernetes Rest API POST/api/v1/namespaces/{namespace}/pods 部署了 Pod
请求正文具有卷的 podspec,如下所示:

{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "test",
"namespace": "default"
},
"spec": {
"volumes": [
{
"name": "test-secrets",
"secret": {
"secretName": "test-secret-one"
}
}
],
"containers":[
<<container json>>.........
]
}
}
  • 现在我想将 Pod 的 secret 名称 test-secret-one 更改为 test-secret-2?
  • 我怎样才能做到这一点?我需要使用什么 Rest API?
  • Patch rest API - 我可以使用更改容器镜像,但不能用于卷。如果可以使用,你能给我一个例子或引用吗?
  • 是否有任何 Kubernetes Rest API 来重新启动 Pod。请注意,我们没有使用部署对象模型。它直接部署为 Pod,而不是部署。

  • 有人可以在这里帮忙吗?

    最佳答案

    我将答案发布为社区 Wiki,因为解决方案来自 @Matt在评论中。

    Volumes aren't updatable fields, you will need to recreate the pod with the new spec.

    The answer to most of your questions is use a deployment and patch it. The deployment will manage the updates and restarts for you.



    @Kitt 建议使用不同的方法。 :

    If you only update the content of Secrets and Configmap instead of renaming them, the mounted volumes will be refreshed by kubelet in the duration --sync-frequency(1m as default).

    关于rest - Kubernetes Rest API 用于更改 Pod 中现有的 secret/configmap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61108579/

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