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.87k stars 584 forks source link

Install Postgres Cluster via Helm from OCI Registry #3641

Open DCAL12 opened 1 year ago

DCAL12 commented 1 year ago

Overview

Allow helm install of PostgresCluster resources via Helm in the same way as PGO operator.

Use Case

As with installing the operator via Helm (see #2231), automation tools require installing PostgresCluster via Helm from a hosted repository. Currently we must build each version from https://github.com/CrunchyData/postgres-operator-examples/tree/main/helm/postgres and push to our own OCI registry.

Desired Behavior

A "postgres-cluster" helm chart is hosted alongside the PGO Helm chart at oci://registry.developers.crunchydata.com/crunchydata/pgo. It can be installed in a similar manner as the operator as documented here, and updated with each release.

Environment

Tell us about your environment:

Please provide the following details:

tony-landreth commented 1 year ago

Hi @DCAL12! Just curious, when you mention that your automation tooling requires installation via Helm from a hosted repository, which tool requires Helm?

DCAL12 commented 1 year ago

I'm currently using ArgoCD, but this is a more general limitation of Helm which requires a packaged chart to run the install command (see here). An alternative would be use a CI pipeline to clone and package the postgres-operator-examples repo and run helm package, but this would preclude the use of gitops tools like ArgoCD which expect the artifact to already be built.

tony-landreth commented 1 year ago

I've captured a story for our backlog about your request. Thanks for sharing the additional details!

ProbstDJakob commented 1 year ago

As a workaround, you could use helm-git or helmfile (which just uses the git plugin under the hood) and reference the repository as follows (for helmfile):

repositories:
  - name: crunchydata
    url: git+https://github.com/CrunchyData/postgres-operator-examples.git@helm?ref=main

releases:
  - name: postgres
    chart: crunchydata/postgrescluster
    values:
      - path/to/your/values.yaml

If the example chart will be published as an official OCI Image, it would be nice, if the databaseInitSQL key does not receive a reference to a existing ConfigMap, but rather a string which will be saved in a ConfigMap maintained by the chart (if the string is not empty). This would provide the benefit that one must not write their own helm chart which only holds the ConfigMap and then reference this by hand in your chart.

zadjadr commented 7 months ago

@tony-landreth Any progress on this? Would make it much easier to get started and remove the need to install plugins in ArgoCD..

Using kustomize for now:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: crunchy-psql-crds
  namespace: argocd
spec:
  project: low-priority
  source:
    repoURL: "https://github.com/CrunchyData/postgres-operator-examples.git"
    path: kustomize/install/default
    targetRevision: HEAD
    kustomize:
      namespace: crunchy-psql-operator
  destination:
    server: "https://kubernetes.default.svc"
    namespace: crunchy-psql-operator
  syncPolicy:
    automated:
      selfHeal: true
    syncOptions:
      - ServerSideApply=true
      - PruneLast=true
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true