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

Default requests/limits for containers in PostgresCluster CR

Open jeremych1000 opened this issue 4 months ago • 2 comments

Hello! I want to ask if there is a way to specify requests and limits by default for all containers. I'm struggling to define all resources/limits in my postgrescluster CR.

We have Kyverno blocking any pods/containers that do not have requests/limits defined. This is a hard requirement and includes all containers incl. init containers from pods, jobs, etc.

Searching .resources on https://access.crunchydata.com/documentation/postgres-operator/latest/references/crd/5.5.x/postgrescluster gives me 42 results - there is no way I define 42 requests/limits in my CR!!!

I've added requests/limits to the following already:

  • postgrescluster.spec.instances[index].resources
  • postgrescluster.spec.backups.pgbackrest.jobs.resources
  • postgrescluster.spec.backups.pgbackrest.repoHost.resources
  • postgrescluster.spec.backups.pgbackrest.restore.resources
  • postgrescluster.spec.proxy.pgBouncer.resources

However in ArgoCD the pods still refuse to come up. If I look at the stateful set there are 4 containers!

Where are these defined in the CR? I don't define every single container in my postgrescluster.spec.instances, so I assume they must be generated - why don't they take the resources definition from the parent?

Container 1 - database - this has requests defined Container 2 - replication-cert-copy - BLANK requests Container 3 - pgbackrest - BLANK requests Container 4 - pgbackrest-config - BLANK requests

Init container 1 - postgres-startup - this has requests defined Init container 2 - nss-wrapper-init - this has requests defined

Environment

Please provide the following details:

  • Platform: Kubernetes
  • Platform Version: v1.28.6
  • PGO Image Tag: crunchy-postgres:ubi8-16.2-0, crunchy-pgbackrest:ubi8-2.49-0
  • Postgres Version: 16

Redacted CR

apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
  name: `<redacted>`
spec:
  postgresVersion: 16
  instances:
    - name: `<redacted>`
      replicas: {{ .Values.postgres.replicas }}
      resources:
        {{- toYaml .Values.postgres.resources | nindent 8 }}
<...>
 
  backups:
    pgbackrest:
      jobs:
        resources:
          {{- toYaml .Values.postgres.backups.resources | nindent 10 }}
      repoHost:
        resources:
          {{- toYaml .Values.postgres.backups.resources | nindent 10 }}
      restore:
        enabled: false # change to true when enabling restores
        repoName: repo1 # references the pgbackrest repo defined below
        resources:
          {{- toYaml .Values.postgres.backups.resources | nindent 10 }}
      repos:
      - name: repo1
        volume:
          volumeClaimSpec:
            {{- .Values.postgres.backups.volumeClaimSpec | toYaml | nindent 12 }}

  proxy:
    pgBouncer:
      replicas: {{ .Values.postgres.proxy.replicas }}
      resources:
        {{- toYaml .Values.postgres.proxy.resources | nindent 8 }}
<...>

jeremych1000 avatar Apr 22 '24 16:04 jeremych1000