postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Problem applying CRD postgres-operator.crunchydata.com_postgresclusters

Open EricGregMiller opened this issue 1 year ago • 3 comments

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

  • Platform: Kubernetes using AWS EKS.
  • Platform Version: 1.3.0
  • PGO Image Tag: postgres-operator:ubi8-5.6.0-0 (Helm chart version 5.6.1)
  • Postgres Version 16
  • Storage: gp2

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.

EricGregMiller avatar Sep 11 '24 00:09 EricGregMiller

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.

andrewlecuyer avatar Sep 11 '24 00:09 andrewlecuyer

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.

EricGregMiller avatar Sep 12 '24 16:09 EricGregMiller

stumbled into same problem yet. i can confirm that

  syncPolicy:
    syncOptions:
    - ServerSideApply=true 

will help you @EricGregMiller

tgruenert avatar Sep 20 '24 10:09 tgruenert