How to remove (delete) annotation in Kubernetes

An alternative way to achieve this goal, might be using kubectl patch command by invoking JSON patch method. Unfortunately it is more weighty solution comparing to your answer:

kubectl patch svc <Service_name> --type=json -p='[{"op": "remove", "path": "/metadata/annotations/prometheus.io~1scrape"}]'

More detailed information can be found in Jsonpatch document.


Use minus - sign at the end of the annotation in kubectl annotate.

Example:

kubectl annotate service shopping-cart prometheus.io/scrape-

Removes annotation prometheus.io/scrape from shopping-cart service.

Tags:

Kubernetes