grafana / grafana-operator

An operator for Grafana that installs and manages Grafana instances, Dashboards and Datasources through Kubernetes/OpenShift CRs
https://grafana.github.io/grafana-operator/
Apache License 2.0
893 stars 393 forks source link

[Bug] kubectl apply invalid: metadata.annotations: Too long #989

Closed rajeevsh990 closed 1 year ago

rajeevsh990 commented 1 year ago

Describe the bug Installation of CRDs using kustomize reports following output.

namespace/grafana created customresourcedefinition.apiextensions.k8s.io/grafanadashboards.grafana.integreatly.org created customresourcedefinition.apiextensions.k8s.io/grafanadatasources.grafana.integreatly.org created customresourcedefinition.apiextensions.k8s.io/grafanafolders.grafana.integreatly.org created serviceaccount/grafana-operator-controller-manager created clusterrole.rbac.authorization.k8s.io/grafana-operator-permissions created clusterrolebinding.rbac.authorization.k8s.io/grafana-operator-permissions created deployment.apps/grafana-operator-controller-manager created The CustomResourceDefinition "grafanas.grafana.integreatly.org" is invalid: metadata.annotations: Too long: must have at most 262144 bytes

The last line of the log errors out which indicates the total size of the CRD "grafanas.grafana.integreatly.org" exceeded the size limit.

Version v5.0.0-rc0

To Reproduce

  1. Go to path 'grafana-operator/deploy/kustomize/overlays/cluster_scoped'
  2. execute 'kubectl apply -k .'
  3. Scroll down to see 'Few of the CRDs will be created'
  4. See error: The last line will show the error as explained above. etc.

Expected behavior A clear and concise description of what you expected to happen.

Suspect component/Location where the bug might be occurring Please provide this if you know where this bug might occur otherwise leave as unknown

Screenshots If applicable, add screenshots to help explain your problem.

Runtime (please complete the following information):

Additional context Add any other context about the problem here. Other blogs of similar issues suggest to break-down the content of CRDs to avoid such issues. Is there any way to do that?

NissesSenap commented 1 year ago

Man, I dislike the solution around last-applied-configuration so much, I understand why they did it, but it doesn't help.

@rajeevsh990 When installing the operator, use kubectl create -k deploy/kustomize/overlays/cluster_scoped instead of apply. If you need to upgrade, you can use kubectl replace

Found a good blog explaining what replace actually does, but it seems safe to use as long as you don't use the --force flag; https://blog.atomist.com/kubernetes-apply-replace-patch/

I will update the documentation to match this.

rajeevsh990 commented 1 year ago

Thanks. I tried the command kustomize build . | kubectl create -f - and it worked. I guess, it's doing the same thing other way round which you mentioned above. Though it was tricky to find out.

weisdd commented 1 year ago

prometheus-operator CRDs lead to the same error. I think the best way to deploy big CRDs is just by adding --server-side flag to kubectl apply:

    --server-side=false:
    If true, apply runs in the server instead of the client.