percona / percona-postgresql-operator

Percona Operator for PostgreSQL
https://www.percona.com/doc/kubernetes-operator-for-postgresql/index.html
Apache License 2.0
258 stars 50 forks source link

pgv2.percona.com/v2 PerconaPGCluster doesnt handle the replicaCertCopy sidecar resources #706

Open mgialelis-pm opened 4 months ago

mgialelis-pm commented 4 months ago

Report

When attempting to create a PerconaPGCluster we need to set the resource and limits on all pods/containers, I can see the that postgresclusters.postgres-operator.crunchydata.com has the ability to set the ReplicaCertCopy resources and seems to be documented https://github.com/percona/percona-postgresql-operator/blob/main/docs/content/tutorial/resize-cluster.md

Tho when attempting to add this to the PerconaPGCluster resource i seem to get errors of the below 2 variants depending how i try to add this in.

W0409 16:26:37.388986   40652 warnings.go:70] unknown field "spec.instances[0].sidecars.replicaCertCopy"
Error: UPGRADE FAILED: failed to replace object: PerconaPGCluster.pgv2.percona.com "svc-db01" is invalid: spec.instances[0].sidecars: Invalid value: "object": spec.instances[0].sidecars in body must be of type array: "object"

Or

"error": "failed to create typed patch object (dev-01/svc-db01-cluster-7429; apps/v1, Kind=StatefulSet): .spec.template.spec.containers: duplicate entries for key [name=\"replication-cert-copy\"]",

Ive checked the CRD for the PerconaPGCluster and there isnt a way that this can be set at any levels at the moment within the yaml files.

I can see the the Crunchy data operators have the https://github.com/percona/percona-postgresql-operator/blob/main/pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go#L534

While the PerconaPGCLuster only implements the core.Container type from the k8s client library's
https://github.com/percona/percona-postgresql-operator/blob/main/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go#L524

There also doesnt appear to be any methods on the https://github.com/percona/percona-postgresql-operator/blob/main/pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types.go#L534

to have similar functionality exposed

More about the problem

See above

Steps to reproduce


# Source: vortex-postgres-cluster/templates/cluster.yaml
apiVersion: pgv2.percona.com/v2
kind: PerconaPGCluster
metadata:
  namespace: dev-01
  annotations:
    current-primary: scheduler-svc-db01
    rollme: "vslEs"
  labels:
    crunchy-pgha-scope: scheduler-svc-db01
    deployment-name: scheduler-svc-db01
    name: scheduler-svc-db01
    pg-cluster: scheduler-svc-db01
    pgo-version: 2.3.1
    pgouser: admin
    helm.sh/chart: vortex-postgres-cluster-0.0.10
    app.kubernetes.io/name: vortex-postgres-cluster
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: "2.3.1"
    app.kubernetes.io/managed-by: Helm
  finalizers:
    null
  name: scheduler-svc-db01
spec:
  crVersion: 2.3.1
  image: percona/percona-postgresql-operator:2.3.1-ppg16-postgres
  imagePullPolicy: Always
  port: 5432
  postgresVersion: 16
  standby:
    enabled: false

  openshift: false
  users:
    - name: test
      databases:
        - testdb
      options: SUPERUSER
      password:
        type: ASCII
      secretName: test-credentials

  pause: false
  unmanaged: false

  instances:
    - name: cluster
      sidecars:
        replicaCertCopy:
          resources:
            limits:
              cpu: 200m
              memory: 128Mi
            requests:
              cpu: 200m
              memory: 128Mi
      replicas: 3
      resources:
        limits:
          cpu: 2
          memory: 4Gi
        requests:
          cpu: 2
          memory: 4Gi
      dataVolumeClaimSpec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi

  proxy:
    pgBouncer:
      image: percona/percona-postgresql-operator:2.3.1-ppg16-pgbouncer
      replicas: 3
      exposeSuperusers: true
      resources:
        requests:
          cpu: 200m
          memory: 128Mi
        limits:
          cpu: 200m
          memory: 128Mi

  pmm:
    enabled: false
    image: percona/pmm-client:2.41.0
    serverHost: monitoring-service
    secret: scheduler-svc-db01-pmm-secret

  backups:
    pgbackrest:
      image: percona/percona-postgresql-operator:2.3.1-ppg16-pgbackrest
      configuration:
        - secret:
            name: scheduler-service-db-backup
      sidecars:
        pgbackrest:
          resources:
            limits:
              cpu: 200m
              memory: 128Mi
            requests:
              cpu: 200m
              memory: 128Mi
        pgbackrestConfig:
          resources:
            limits:
              cpu: 200m
              memory: 128Mi
            requests:
              cpu: 200m
              memory: 128Mi
      jobs:
        priorityClassName: high-priority
        resources:
          limits:
            cpu: 200m
            memory: 128Mi
          requests:
            cpu: 200m
            memory: 128Mi
      manual:
        repoName: repo1
        options:
         - --type=full
      repos:
      - name: repo1
        schedules:
          full: 0 0 * * 6
        volume:
          volumeClaimSpec:
            accessModes:
            - ReadWriteOnce
            resources:
              requests:
                storage: 1Gi

Versions

  1. Kubernetes: 1.28.0
  2. Operator: Percona Pgsql 2.3.4
  3. Database: PerconaPGCluster

Anything else?

No response