In this blog I have added the solution for ArgoCD Metadata.annotations: Too long
Error.
Issue - Annotation Exceeding Limit
When I tried to deploy the Prometheus-stack helm chart using ArgoCD, I faced the following error.
metadata.annotations: Too long: must have at most 262144 bytes
This issue occurs because the size of the resources annotation exceeds the Kubernetes 256 KiB (262 144 bytes) limit.
That is a very good limit for storing many annotation. But here is why it exceeds in ArgoCD.
When ArgoCD applies the YAML, it stores a copy inside the object itself under kubectl.kubernetes.io/last-applied-configuration
annotation. That hidden copy counts toward the 256 KB limit on metadata.annotations
So, if the object itself is large (big CRDs, Prometheus, Grafana‑dashboard ConfigMaps, etc.), the annotation pushes the total size over 256 KiB and the API server rejects the object, so Argo CD
You won't face this issue when you try to deploy the helm chart directly using helm install
or kubectl apply
Solution - Using ServerSideApply
To solve this issue, you can use the ServerSideApply
option available on ArgoCD.
This option tells Argo CD to let the Kubernetes API server take care of the apply instead of storing the configuration in annotations.
If you are using the declarative method
for deploying the application, you can specify the ServerSideApply
option under the syncPolicy
as given in the example below.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: prometheus
namespace: argocd
spec:
destination:
name: in-cluster
namespace: monitoring
project: default
source:
repoURL: '<your-repo>'
targetRevision: HEAD
path: kube-prometheus-stack
helm:
valueFiles:
- values.yaml
syncPolicy:
syncOptions:
- CreateNamespace=true
- ServerSideApply=true
If you are deploying using ArgoCD UI
, enable the Server-Side Apply
option under the SYNC OPTIONS
during the configuration.
