<p>I am trying to find the best way to bulk edit the annotations on a number of Kubernetes resources. It seems like Kustomize might be the best option:</p>
<ol>
<li>The resources are already part of kustomization.yaml</li>
<li>I can then edit kustomization.yaml with my new or revised annotation</li>
<li><code>kubectl apply -k ./</code> updates all the relevant resources with the new annotation as desired</li>
</ol>
<p>Unfortunately this makes all the pods terminate and restart, which is sometimes more lengthy than I'd hoped. Applying an annotation without Kustomize, when there are no other changes to the YAML, does not require redeployments and I'd love to do something similar, but in bulk. Any tips are appreciated!</p>

Zeke MC
<p>It seems your pods are managed by some replica-set(deployment, daemonset, statefulset etc) and rightly so. Updating these will result in updated pod spec and hence the redeployments.</p>
<p>You can look at <code>kubectl annotate</code> command.</p>
<p>Some examples from <code>kubectl annotate --help</code></p>
<pre><code>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 &quot;pod.json&quot;
  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-
</code></pre>
