reactive-tech / kubegres

Kubegres is a Kubernetes operator allowing to deploy one or many clusters of PostgreSql instances and manage databases replication, failover and backup.
https://www.kubegres.io
Apache License 2.0
1.32k stars 74 forks source link

Kustomize throws error when trying to source a Kubegres resource #83

Closed williamkray closed 2 years ago

williamkray commented 2 years ago

I have the following kubegres resource defined for testing (kubegres-cluster.yaml):

apiVersion: kubegres.reactive-tech.io/v1
kind: Kubegres
metadata:
  name: synapse-kubegres
  namespace: default
spec:
  replicas: 1
  image: postgres:13
  database:
     size: 1Gi
  env:
    - name: PGDATA
      value: /var/lib/postgresql/data/pgdata
    - name: POSTGRES_PASSWORD
      valueFrom:
        secretKeyRef:
          name: synapse-db-secrets
          key: postgres-password
     - name: POSTGRES_REPLICATION_PASSWORD
       valueFrom:
          secretKeyRef:
             name: synapse-db-secrets
             key: pgrepl-password
    - name: POSTGRES_USER
      valueFrom:
        secretKeyRef:
          name: synapse-db-secrets
          key: postgres-user
    - name: POSTGRES_DB
      valueFrom:
        secretKeyRef:
          name: synapse-db-secrets
          key: database-name
    - name: POSTGRES_INITDB_ARGS
      value: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"

the resource is included in my base-level kustomization.yaml:

resources:
...
  - kubegres-cluster.yaml

and i reference both the base directory and a patch in my overlay:

resources:
...
  - ../../synapse
  - patch02-synapse-kubegres-cluster.yaml

the patch makes minor changes to volume size and number of cluster nodes. happy to post it if it's deemed relevant.

however, when trying to generate the overlay with kustomize, i receive the following error:

Error: accumulating resources: accumulation err='accumulating resources from '../../synapse': '/home/wreck/git/jmk8s/synapse' must resolve to a file': recursed accumulation of path '/home/wreck/git/jmk8s/synapse': accumulating resources: accumulation err='accumulating resources from 'kubegres-cluster.yaml': yaml: line 11: did not find expected '-' indicator': got file 'kubegres-cluster.yaml', but '/home/wreck/git/jmk8s/synapse/kubegres-cluster.yaml' must be a directory to be a root

line 11 appears to be the part where i start defining env vars in the kubegres-cluster.yaml file, and attempting to manipulate this file changes the output of the error but never to anything that seems to work. i'm wondering if the custom resource is structured in such a way that kustomize isn't able to parse it correctly? or perhaps i'm doing something wrong. I've tried to follow the yaml structure in the examples as closely as i can.

i appreciate any help!

williamkray commented 2 years ago

never mind, it was just a dumb spacing issue. i apparently can't yaml.