cloudnative-pg / cloudnative-pg/charts

Feature Request: Add extraObjects support to the cluster Helm chart

Open
#850 3 comments 4 reactions 0 assignees View on GitHub
chart( cluster )
Dominant language
Go Template
Stars
621
Forks
265
Avg merge
7d 12h
Merged PRs (30d)
7

Description

# Feature Request: Add `extraObjects` support to the cluster Helm chart

## Problem

When deploying a CNPG cluster via the `cluster` Helm chart, related resources like ConfigMaps, NetworkPolicies, PrometheusRules, Secrets/ExternalSecret and so on must be managed outside the Helm release. Either via a wrapper chart, Kustomize overlays, or separate manifests.

## Proposed solution

Add an `extraObjects` value (list, default `[]`) rendered as additional manifests, passed through `tpl` for templating support.

**`values.yaml`:**
```yaml
# -- Extra Kubernetes manifests to deploy alongside the cluster.
# Each entry is passed through `tpl`, so Helm templating is supported.
extraObjects: []
# - apiVersion: v1
# kind: ConfigMap
# metadata:
# name: "{{ include \"cluster.fullname\" . }}-grafana-dashboard"
# labels:
# grafana_dashboard: "1"
# data:
# cnpg-dashboard.json: |-
# { ... }
# - |
# apiVersion: v1
# kind: Secret
# type: Opaque
# metadata:
# name: cnpg-cluster-secret
# data:
# { ... }
```

**`templates/extra-manifests.yaml`:**
```yaml
{{- /* Normalize extraObjects to a list, easier to loop over */ -}}
{{- $extraObjects := .Values.extraObjects | default (list) -}}

{{- if kindIs "map" $extraObjects -}}
{{- $extraObjects = values $extraObjects -}}
{{- end -}}

{{- range $extraObjects }}
---
{{- if kindIs "map" . }}
{{- tpl (toYaml .) $ | nindent 0 }}
{{- else if kindIs "string" . }}
{{- tpl . $ | nindent 0 }}
{{- end }}
{{- end }}
```

## Prior art

This is a well-established pattern: **Loki** ([[values.yaml](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml)](https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml)), **Traefik** ([[#595](https://github.com/traefik/traefik-helm-chart/issues/595)](https://github.com/traefik/traefik-helm-chart/issues/595)), **cert-manager** ([[#5900](https://github.com/cert-manager/cert-manager/issues/5900)](https://github.com/cert-manager/cert-manager/issues/5900)), **Bitnami** (`extraDeploy`), **Flux2**, and many others. There's even an open discussion to make this a first-class Helm feature: [[helm/helm#12653](https://github.com/helm/helm/issues/12653)](https://github.com/helm/helm/issues/12653).

## Implementation effort

One new template file, one new default value. Non-breaking, minimal change.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.