Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ConfigMap is invalid: metadata.annotations: Too long: must have at most 262144 characters #820

Closed
kuznero opened this issue Nov 20, 2018 · 46 comments
Milestone

Comments

@kuznero
Copy link

kuznero commented Nov 20, 2018

Does it apply to Argo CD managed helm charts? Can it be overwritten/overcome somehow?

@jessesuen
Copy link
Member

This error is happening during kubectl apply phase for one of your ConfigMap resources, and is not just specific to helm. We use kubectl apply to perform deployments. One of the downsides of using kubectl apply is that it stores the entire spec as an annotation in the object (which it uses to understand how handle defaulted vs. deleted fields). What's happening is that the data fields in the ConfiMap is likely exceeding 262144 characters enforced by the K8s API server, and thus it cannot fit in the last-applied-configuration kubectl annotation.

Theres not a workaround other than a Sync hook which performs the deploy in a manner different than apply (e.g. kubectl replace). Which helm chart is causing problems?

@kuznero
Copy link
Author

kuznero commented Nov 21, 2018

This is a custom made helm chart with a bit config map that I currently need to deploy with kubectl create. Could you please reference an example with a Sync hook you mentioned?

@stale
Copy link

stale bot commented Apr 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Apr 10, 2019
@alexmt alexmt removed the wontfix This will not be worked on label Apr 10, 2019
@stale
Copy link

stale bot commented Jun 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 9, 2019
@stale stale bot closed this as completed Jun 16, 2019
@basvandenbrink
Copy link

This error is happening during kubectl apply phase for one of your ConfigMap resources, and is not just specific to helm. We use kubectl apply to perform deployments. One of the downsides of using kubectl apply is that it stores the entire spec as an annotation in the object (which it uses to understand how handle defaulted vs. deleted fields). What's happening is that the data fields in the ConfiMap is likely exceeding 262144 characters enforced by the K8s API server, and thus it cannot fit in the last-applied-configuration kubectl annotation.

Theres not a workaround other than a Sync hook which performs the deploy in a manner different than apply (e.g. kubectl replace). Which helm chart is causing problems?

@jessesuen This issue occurs when install Grafana with a large dashboard using ConfigMaps.

Wouldn't it be better to use kubectl create or kubectl replace?

I am also curious to the sync hook workaround.

@phantomnat
Copy link

phantomnat commented Dec 10, 2019

I also have problem with grafana.
For the workaround, try adding these annotations to the resources that need to be deleted before apply.

  annotations:
    "helm.sh/hook": pre-install
    "helm.sh/hook-weight": "-1"
    "helm.sh/hook-delete-policy": before-hook-creation

@cabrinha
Copy link
Contributor

I also have problem with grafana.
For the workaround, try adding these annotations to the resources that need to be deleted before apply.

  annotations:
    "helm.sh/hook": pre-install
    "helm.sh/hook-weight": "-1"
    "helm.sh/hook-delete-policy": before-hook-creation

Using these annotations seems to have kinda-worked... I still get caught up on a few of the larger config-maps. They just won't sync with the same error.

@Thakurvaibhav
Copy link
Contributor

I also have problem with grafana.
For the workaround, try adding these annotations to the resources that need to be deleted before apply.

annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-1"
"helm.sh/hook-delete-policy": before-hook-creation

This does not seem to work in case of a grafana dashboards configmap. Please suggest a workaround / fix

@mprzygrodzki
Copy link

I also have problem with grafana.
For the workaround, try adding these annotations to the resources that need to be deleted before apply.
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-1"
"helm.sh/hook-delete-policy": before-hook-creation

This does not seem to work in case of a grafana dashboards configmap. Please suggest a workaround / fix

Same problem, annotations doesnt seem to work in case of Grafana chart.

@jdomag
Copy link

jdomag commented Jan 13, 2021

Same here. @kuznero can you reopen the issue?

@ebuildy
Copy link
Contributor

ebuildy commented Feb 9, 2021

Hello @jessesuen where did you see argocd can use "create" instead of "apply"?

Tried with

annotations:
   argocd.argoproj.io/hook: PostSync
   argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
   argocd.argoproj.io/sync-options: Validate=false

Capture d’écran 2021-02-09 à 11 59 38

@abdennour
Copy link

same issue here . exactly same.
image

@abdennour
Copy link

abdennour commented Mar 15, 2021

any deadline for fixing this issue ?
Could you , for example, patching the YAML before applying it ( removing the annotation last-applied-configuration , .. so on) ?
If the resource does not work because of this error, try to run k replace instead of k apply ?

@diranged
Copy link

diranged commented Mar 25, 2021

We just ran into this on a CRD from Strimzi.io:

apiextensions.k8s.io/v1beta1/CustomResourceDefinition
strimzi-operator
kafkas.kafka.strimzi.io
 SyncFailed
CustomResourceDefinition.apiextensions.k8s.io "kafkas.kafka.strimzi.io" is invalid: metadata.annotations: Too long: must have at most 262144 bytes

We obviously cannot have the CRD deleted and re-created for an upgrade.. what should we do? This is the resource it's trying to apply: https://github.com/strimzi/strimzi-kafka-operator/blob/0.22.1/install/cluster-operator/040-Crd-kafka.yaml

@alexmt alexmt reopened this Mar 25, 2021
@alexmt alexmt removed the wontfix This will not be worked on label Mar 25, 2021
@alexmt alexmt added this to the v2.0 milestone Mar 25, 2021
@alexmt
Copy link
Collaborator

alexmt commented Apr 2, 2021

The argoproj/gitops-engine#252 adds special handling for CRDs. Argo CD will try to just use K8S update request for CRDs if Replace=true option present. The update won't try to recreate resource so it is safe to use with CRDs.

@alexmt alexmt closed this as completed Apr 2, 2021
@crenshaw-dev
Copy link
Member

I'm optimistic that we'll have an RC by the end of this week (i.e. by Friday, October 7).

We've been trying to get multi-source apps into the release, which is the reason for the delay.

@blackliner
Copy link

Similar thing happens with kube-prometheus-stack from https://prometheus-community.github.io/helm-charts. The prometheuses.**** CRD is HUGE, makes ArgoCD webUI lag like 1969

@dlemfh
Copy link

dlemfh commented Dec 16, 2022

The argoproj/gitops-engine#252 adds special handling for CRDs. Argo CD will try to just use K8S update request for CRDs if Replace=true option present. The update won't try to recreate resource so it is safe to use with CRDs.

Please mention that ArgoCD v2.5 is introducing an option to perform a manifest sync with side-server apply.

#9711

With ArgoCD 2.5+

apiVersion: argoproj.io/v1alpha1
kind: Application
spec:
  syncPolicy:
    syncOptions:
    - ServerSideApply=true

would resolve this issue in ArgoCD, because side-server apply would not create an annotation like kubectl.kubernetes.io/last-applied-configuration anymore.

Until its release, you can read about this feature here and why it would resolve this issue inside ArgoCD: master/docs/user-guide/sync-options.md#server-side-apply

Hey @alexmt, @crenshaw-dev,

now that argocd v2.5 is out, which solution would you recommend for the problem with CRD's being too long?

CustomResourceDefinition.apiextensions.k8s.io "kafkas.kafka.strimzi.io" is invalid: metadata.annotations: Too long: must have at most 262144 bytes
  • Replace=true

or

  • ServerSideApply=true

?

@nallenscott
Copy link

nallenscott commented Jan 4, 2023

In my experience, Replace is substantially faster than ServerSideApply when deploying lots of large CRDs, especially when you have a local copy. My CRDs spin up almost instantly with the following setup (if you deploy to the same cluster as Argo, replace the ApplicationSet with an Application):

  1. Use braid to copy the CRDs to a local directory (simply braid update to trigger a sync in Argo):
$ braid add --branch main --path bitnami/kube-prometheus/crds https://github.com/bitnami/charts <local_path>/crds
  1. Create an ApplicationSet pointing to the crds in your repo:
source:
  path: <path_to_crds>
  repoURL: git@github.com:<username>/<repo>.git
  targetRevision: <branch_or_commit>
syncPolicy:
  syncOptions:
    - Replace=true
  1. Create an Application to deploy the AppSet, or place the AppSet in the path of an existing App:
source:
  path: <path_to_app_set>
  repoURL: git@github.com:<username>/<repo>.git
  targetRevision: <branch_or_commit>

@jkroepke
Copy link
Contributor

jkroepke commented Jan 4, 2023

@nallenscott Nice catch, but it seems a bit outdated. There is an semi official helm chart now that holds the Prometheus CRDs

https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-operator-crds

which natively allows setup annotations, if required.

Local local copy required

@nallenscott
Copy link

nallenscott commented Jan 4, 2023

@jkroepke I tried that chart with and without Replace and ServerSideApply and CRDs take minutes to sync, if they sync at all. That's been consistent with all of the charts I've tried.

@jkroepke
Copy link
Contributor

jkroepke commented Jan 4, 2023

Not talking about Replace and ServerSideApply. But using the Chart replaces the braid hack

@nallenscott
Copy link

@jkroepke Clarified my comment.

@nallenscott
Copy link

Additionally, it seems wise to manage CRDs externally, seeing as helm is unable to upgrade or delete them after they're deployed. From the argo-cd helm repo: https://github.com/argoproj/argo-helm/tree/main/charts/argo-cd#custom-resource-definitions

@davhdavh
Copy link

Couldnt argo just recognize this specific error message and use create on it?

@crenshaw-dev
Copy link
Member

@davhdavh theoretically, but it's not always safe to Replace resources. I think it's better to leave it to the user to decide.

Although, I do think it would be worth adding a note in the UI to say, "Maybe you can use Replace (with the usual safety caveats) or ServerSideApply."

@matan-legit
Copy link

ServerSideApply doesn't fix the issue for me is there another way to fix the issue? specifically when using a helm type application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests