CrunchyData / postgres-operator

Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
https://access.crunchydata.com/documentation/postgres-operator/v5/
Apache License 2.0
3.96k stars 594 forks source link

Problem applying CRD postgres-operator.crunchydata.com_postgresclusters #3989

Closed EricGregMiller closed 3 weeks ago

EricGregMiller commented 2 months ago

Overview

I get an error when I try to manually add the postgres-operator.crunchydata.com_postgresclusters CRD. The error is "The CustomResourceDefinition "postgresclusters.postgres-operator.crunchydata.com" is invalid: metadata.annotations: Too long: must have at most 262144 bytes"

Environment

Steps to Reproduce

REPO

This is what it looks like. The following uses kubectl apply in an attempt to create the problem CRD.

kubectl apply -f postgres-crds/templates/postgres-operator.crunchydata.com_postgresclusters.yaml`
The CustomResourceDefinition "postgresclusters.postgres-operator.crunchydata.com" is invalid: metadata.annotations: Too long: must have at most 262144 bytes

The same error occurs if I try to load from a folder. Three of the CRDs are OK but postgres-operator.crunchydata.com_postgresclusters fails with the same error. The templates folder contains the four PGO CRD definitions.

kubectl apply -f templates
customresourcedefinition.apiextensions.k8s.io/crunchybridgeclusters.postgres-operator.crunchydata.com created
customresourcedefinition.apiextensions.k8s.io/pgadmins.postgres-operator.crunchydata.com created
customresourcedefinition.apiextensions.k8s.io/pgupgrades.postgres-operator.crunchydata.com created
The CustomResourceDefinition "postgresclusters.postgres-operator.crunchydata.com" is invalid: metadata.annotations: Too long: must have at most 262144 bytes

If I install with a helm chart all four CRDs install OK. For the following I have a simple helm chart in the postgres-crds folder with the four CRDs in the chart's templates folder.

$ helm install postgres-crds ./postgres-crds/
NAME: postgres-crds
LAST DEPLOYED: Tue Sep 10 23:32:17 2024
NAMESPACE: pg
STATUS: deployed
REVISION: 1
TEST SUITE: None
$ kubectl get crds | grep crunchy
crunchybridgeclusters.postgres-operator.crunchydata.com   2024-09-10T23:32:20Z
pgadmins.postgres-operator.crunchydata.com                2024-09-10T23:32:20Z
pgupgrades.postgres-operator.crunchydata.com              2024-09-10T23:32:20Z
postgresclusters.postgres-operator.crunchydata.com        2024-09-10T23:32:20Z

EXPECTED

No error for any postgres-operator.crunchydata.com_postgresclusters CRD creation scenario.

ACTUAL

Error when I use kubectl apply with either the individual manifest file or with a folder containing the manifest file.

I also get errors when I try to run using an in-house tool built upon ArgoCD. That's more complex and I don't expect you to deal with it. But it is why this bug is making my life difficult.

Logs

I am not sure what logs would help with this but just let me know what you'd like and I'll do my best to provide.

andrewlecuyer commented 2 months ago

Hi @EricGregMiller!

This is due to a limitation with kubectl apply, that can fortunately be addressed by using Server-Side Apply. More specifically, simply use the --server-side flag with kubectl apply:

$ kubectl apply --server-side -f postgres-operator.crunchydata.com_postgresclusters.yaml
customresourcedefinition.apiextensions.k8s.io/postgresclusters.postgres-operator.crunchydata.com serverside-applied

And you should then be able to successfully install the various CRD's.

EricGregMiller commented 2 months ago

Thanks for your feedback. it really helps since now I at least know what is happening. I got pulled away but should be able to try this soon. For our setup we probably need ArgoCD to support server-side apply and it looks like they are working on it.

tgruenert commented 2 months ago

stumbled into same problem yet. i can confirm that

  syncPolicy:
    syncOptions:
    - ServerSideApply=true 

will help you @EricGregMiller