kubectl apply "metadata.annotations: Too long" in CI
Client-side kubectl apply stores the whole manifest in a last-applied-configuration annotation. On a large object (big CRD, fat ConfigMap) that annotation exceeds Kubernetes’ 256 KB metadata limit and the apply is rejected.
What this error means
kubectl apply fails with metadata.annotations: Too long: must have at most 262144 bytes. It hits large resources - CRDs with big schemas, or ConfigMaps embedding large files.
The CustomResourceDefinition "prometheuses.monitoring.coreos.com" is invalid:
metadata.annotations: Too long: must have at most 262144 bytesCommon causes
last-applied-configuration overflow
Client-side apply embeds the full manifest in an annotation. For very large objects this pushes total metadata past the 256 KB cap.
Large embedded data in the object
A ConfigMap/Secret embedding a big file, or a CRD with an enormous OpenAPI schema, makes the stored configuration too large.
How to fix it
Use server-side apply
Server-side apply tracks ownership in managedFields instead of the last-applied annotation, avoiding the size limit entirely.
kubectl apply --server-side --force-conflicts -f bigcrd.yamlOr create/replace large CRDs
- For first install of a huge CRD, use
kubectl create -f(no annotation written). - For updates,
kubectl replace -for server-side apply. - Avoid embedding large blobs in annotations/ConfigMaps; mount them instead.
How to prevent it
- Prefer
kubectl apply --server-sidefor large objects and CRDs. - Keep object metadata lean; do not stuff large data into annotations.
- Install big operator CRDs via their documented method (server-side/create).