使用Kustomize批量编辑Kubernetes注释,无需重新启动POD

使用Kustomize批量编辑Kubernetes注释,无需重新启动POD,kubernetes,kustomize,Kubernetes,Kustomize,我正试图找到在大量Kubernetes资源上批量编辑注释的最佳方法。看起来Kustomize可能是最好的选择: 这些资源已经是kustomization.yaml的一部分 然后,我可以使用新的或修订的注释编辑kustomization.yaml kubectl apply-k./根据需要使用新注释更新所有相关资源 不幸的是,这使得所有的pod终止并重新启动,这有时比我希望的要长。在没有对YAML进行其他更改的情况下,在没有Kustomize的情况下应用注释不需要重新部署,我很想做一些类似的事情,

我正试图找到在大量Kubernetes资源上批量编辑注释的最佳方法。看起来Kustomize可能是最好的选择:

这些资源已经是kustomization.yaml的一部分 然后,我可以使用新的或修订的注释编辑kustomization.yaml kubectl apply-k./根据需要使用新注释更新所有相关资源
不幸的是,这使得所有的pod终止并重新启动,这有时比我希望的要长。在没有对YAML进行其他更改的情况下,在没有Kustomize的情况下应用注释不需要重新部署,我很想做一些类似的事情,但是批量进行。任何提示都将不胜感激

您的POD似乎是由一些副本集部署、守护程序集、状态集等管理的,这是正确的。更新这些将导致更新pod规范,从而重新部署

您可以查看kubectl注释命令

kubectl annotate-help中的一些示例


您的POD似乎是由一些副本集部署、守护程序集、状态集等管理的。更新这些将导致更新pod规范,从而重新部署

您可以查看kubectl注释命令

kubectl annotate-help中的一些示例


是的,主要使用statefulset。我最初使用的是kubectl annotate,它和kubectl在编辑YAML后应用都很好,因为它们不需要重新部署标签和注释。但是kubectl annotate不会更改基础YAML,手动编辑YAML,然后再执行kubectl应用太手动和耗时。kubectl在跑步吊舱2上的注释。使用kubectl卷展栏暂停3暂停状态集合的卷展栏,直到不需要重新部署为止。使用kustomize更新/创建/应用新的YAML。由于在上一步中暂停了卷展栏,因此不会发生重新部署。恢复卷展栏kubectl卷展栏在准备重新部署时恢复,主要使用状态集。我最初使用的是kubectl annotate,它和kubectl在编辑YAML后应用都很好,因为它们不需要重新部署标签和注释。但是kubectl annotate不会更改基础YAML,手动编辑YAML,然后再执行kubectl应用太手动和耗时。kubectl在跑步吊舱2上的注释。使用kubectl卷展栏暂停3暂停状态集合的卷展栏,直到不需要重新部署为止。使用kustomize更新/创建/应用新的YAML。由于在上一步中暂停了卷展栏,因此不会发生重新部署。准备重新部署时,恢复“kubectl”卷展栏“恢复”
Examples:
  # Update pod 'foo' with the annotation 'description' and the value 'my frontend'.
  # If the same annotation is set multiple times, only the last value will be applied
  kubectl annotate pods foo description='my frontend'

  # Update a pod identified by type and name in "pod.json"
  kubectl annotate -f pod.json description='my frontend'

  # Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', overwriting any
existing value.
  kubectl annotate --overwrite pods foo description='my frontend running nginx'

  # Update all pods in the namespace
  kubectl annotate pods --all description='my frontend running nginx'

  # Update pod 'foo' only if the resource is unchanged from version 1.
  kubectl annotate pods foo description='my frontend running nginx' --resource-version=1

  # Update pod 'foo' by removing an annotation named 'description' if it exists.
  # Does not require the --overwrite flag.
  kubectl annotate pods foo description-