Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set externalClusters #424

Closed
Ofirfr opened this issue Oct 25, 2024 · 5 comments · Fixed by #475
Closed

Can't set externalClusters #424

Ofirfr opened this issue Oct 25, 2024 · 5 comments · Fixed by #475
Labels
chart( cluster ) Related to the cluster chart

Comments

@Ofirfr
Copy link

Ofirfr commented Oct 25, 2024

Just as title, the helm chart does not support setting externalClusters field, the field can be seen in docs:
https://cloudnative-pg.io/documentation/1.24/database_import/

@itay-grudev
Copy link
Collaborator

itay-grudev commented Oct 25, 2024

The chart is responsible for filling in the externalClusters section based on your recovery configuration. I don't want to expose it.

externalClusters:
- name: pgBaseBackupSource
connectionParameters:
host: {{ .Values.recovery.pgBaseBackup.source.host | quote }}
port: {{ .Values.recovery.pgBaseBackup.source.port | quote }}
user: {{ .Values.recovery.pgBaseBackup.source.username | quote }}
dbname: {{ .Values.recovery.pgBaseBackup.source.database | quote }}
sslmode: {{ .Values.recovery.pgBaseBackup.source.sslMode | quote }}
{{- if .Values.recovery.pgBaseBackup.source.passwordSecret.name }}
password:
name: {{ default (printf "%s-pg-basebackup-password" (include "cluster.fullname" .)) .Values.recovery.pgBaseBackup.source.passwordSecret.name }}
key: {{ .Values.recovery.pgBaseBackup.source.passwordSecret.key }}
{{- end }}
{{- if .Values.recovery.pgBaseBackup.source.sslKeySecret.name }}
sslKey:
name: {{ .Values.recovery.pgBaseBackup.source.sslKeySecret.name }}
key: {{ .Values.recovery.pgBaseBackup.source.sslKeySecret.key }}
{{- end }}
{{- if .Values.recovery.pgBaseBackup.source.sslCertSecret.name }}
sslCert:
name: {{ .Values.recovery.pgBaseBackup.source.sslCertSecret.name }}
key: {{ .Values.recovery.pgBaseBackup.source.sslCertSecret.key }}
{{- end }}
{{- if .Values.recovery.pgBaseBackup.source.sslRootCertSecret.name }}
sslRootCert:
name: {{ .Values.recovery.pgBaseBackup.source.sslRootCertSecret.name }}
key: {{ .Values.recovery.pgBaseBackup.source.sslRootCertSecret.key }}
{{- end }}
{{- else }}
recovery:
{{- with .Values.recovery.pitrTarget.time }}
recoveryTarget:
targetTime: {{ . }}
{{- end }}
{{- if eq .Values.recovery.method "backup" }}
backup:
name: {{ .Values.recovery.backupName }}
{{- else if eq .Values.recovery.method "object_store" }}
source: objectStoreRecoveryCluster
{{- end }}
externalClusters:
- name: objectStoreRecoveryCluster
barmanObjectStore:
serverName: {{ .Values.recovery.clusterName }}
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }}

Import is not yet supported. There is a PR that adds support for it, but I probably won't get around to merging that soon.

If you need import, for now, I would suggest you interact with the operator directly i.e. don't use the chart.

@NiccoloFei NiccoloFei added the chart( cluster ) Related to the cluster chart label Oct 31, 2024
itay-grudev added a commit that referenced this issue Dec 19, 2024
@soorajshetty604
Copy link

But this chart does not contain the externalClusters field for distributed topology configuration, which should have the scope to add multiple cluster details under externalClusters and replica section as well. So that we can have primary and disaster recovery data centres in multiple regions as mentioned in the blog https://www.gabrielebartolini.it/articles/2024/06/making-the-world-my-single-point-of-failure-with-postgresql
As of now we can have standalone cluster and recovery cluster from the primary, but switchover between the two clusters in two regions (distributed topology)is not possible using this helm chart.

externalClusters:
- name: pg16-eu-central
barmanObjectStore:
destinationPath: s3://pg16-eu-central/
# ...
- name: pg16-eu-western
barmanObjectStore:
destinationPath: s3://pg16-eu-western/
# ...
replica:
primary: pg16-eu-central
source: pg16-eu-western

The chart is responsible for filling in the externalClusters section based on your recovery configuration. I don't want to expose it.

charts/charts/cluster/templates/_bootstrap.tpl

Lines 43 to 90 in 3c5dd5d

externalClusters:

  • name: pgBaseBackupSource
    connectionParameters:
    host: {{ .Values.recovery.pgBaseBackup.source.host | quote }}
    port: {{ .Values.recovery.pgBaseBackup.source.port | quote }}
    user: {{ .Values.recovery.pgBaseBackup.source.username | quote }}
    dbname: {{ .Values.recovery.pgBaseBackup.source.database | quote }}
    sslmode: {{ .Values.recovery.pgBaseBackup.source.sslMode | quote }}
    {{- if .Values.recovery.pgBaseBackup.source.passwordSecret.name }}
    password:
    name: {{ default (printf "%s-pg-basebackup-password" (include "cluster.fullname" .)) .Values.recovery.pgBaseBackup.source.passwordSecret.name }}
    key: {{ .Values.recovery.pgBaseBackup.source.passwordSecret.key }}
    {{- end }}
    {{- if .Values.recovery.pgBaseBackup.source.sslKeySecret.name }}
    sslKey:
    name: {{ .Values.recovery.pgBaseBackup.source.sslKeySecret.name }}
    key: {{ .Values.recovery.pgBaseBackup.source.sslKeySecret.key }}
    {{- end }}
    {{- if .Values.recovery.pgBaseBackup.source.sslCertSecret.name }}
    sslCert:
    name: {{ .Values.recovery.pgBaseBackup.source.sslCertSecret.name }}
    key: {{ .Values.recovery.pgBaseBackup.source.sslCertSecret.key }}
    {{- end }}
    {{- if .Values.recovery.pgBaseBackup.source.sslRootCertSecret.name }}
    sslRootCert:
    name: {{ .Values.recovery.pgBaseBackup.source.sslRootCertSecret.name }}
    key: {{ .Values.recovery.pgBaseBackup.source.sslRootCertSecret.key }}
    {{- end }}

{{- else }}
recovery:
{{- with .Values.recovery.pitrTarget.time }}
recoveryTarget:
targetTime: {{ . }}
{{- end }}
{{- if eq .Values.recovery.method "backup" }}
backup:
name: {{ .Values.recovery.backupName }}
{{- else if eq .Values.recovery.method "object_store" }}
source: objectStoreRecoveryCluster
{{- end }}

externalClusters:

  • name: objectStoreRecoveryCluster
    barmanObjectStore:
    serverName: {{ .Values.recovery.clusterName }}
    {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
    {{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }}
    Import is not yet supported. There is a PR that adds support for it, but I probably won't get around to merging that soon.

If you need import, for now, I would suggest you interact with the operator directly i.e. don't use the chart.

@itay-grudev
Copy link
Collaborator

The chart is supposed to serve as a level of abstraction over the the CNPG CRDs. But I'm accepting PRs for adding replica cluster support to the chart.

It's been on my radar but I am a bit low on time to add it. That being said if someone is willing to add that I'll work with them to assist and prioritize that PR.

@soorajshetty604
Copy link

soorajshetty604 commented Jan 30, 2025

The chart is supposed to serve as a level of abstraction over the the CNPG CRDs. But I'm accepting PRs for adding replica cluster support to the chart.

It's been on my radar but I am a bit low on time to add it. That being said if someone is willing to add that I'll work with them to assist and prioritize that PR.

Yes, Thanks. I’m interested in contributing to the Helm chart by adding support for replica clusters (distributed topology) . I’d love to collaborate on this and get your guidance on the approach.

Could you provide any initial pointers on how you envision this being implemented?

@itay-grudev
Copy link
Collaborator

@soorajshetty604 It's designed to work with mode=replica.

mode: standalone

To follow the chart configuration method you'll want to add a global section for replica configuration.

Here is a link to the CNPG documentation on Replica Clusters.

I am on the CloudNativePG Slack if you have any further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chart( cluster ) Related to the cluster chart
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants