generated from giantswarm/template-app
-
Notifications
You must be signed in to change notification settings - Fork 3
Improve CNPG templating #428
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| {{/* | ||
| Object store credentials for CNPG barman-cloud ObjectStore resources. | ||
|
|
||
| Outputs the appropriate credentials block based on the configured storage type. | ||
| Intended to be called with `{{- include "grafana.cnpg.objectStoreCredentials" . | nindent 4 }}`. | ||
|
|
||
| Credential paths: | ||
|
|
||
| S3 with explicit keys: | ||
| Condition: objectStorage.type == "s3" AND s3.accessKeyId AND s3.secretAccessKey are set | ||
| Use case: customers providing their own S3 bucket with static credentials | ||
| Source: the <cluster-name>-access-keys Secret (rendered by access-keys-secret.yaml) | ||
|
|
||
| S3 with IRSA: | ||
| Condition: objectStorage.type == "s3", no explicit keys | ||
| Use case: AWS/CAPA clusters with an IAM role configured for the CNPG service account | ||
| Source: pod's IAM role via IRSA (no secret needed) | ||
|
|
||
| Azure with Crossplane: | ||
| Condition: objectStorage.type == "azure" AND crossplane.azure.enabled == true | ||
| Use case: CAPZ clusters where Crossplane provisions the storage account | ||
| Source: connection string from the Crossplane-generated secret | ||
| (key: attribute.primary_blob_connection_string) | ||
|
|
||
| Azure manual: | ||
| Condition: objectStorage.type == "azure", Crossplane not enabled | ||
| Use case: non-Crossplane Azure installs with an existing storage account | ||
| Source: azureCredentials passthrough from objectStorage.azure.credentials | ||
| */}} | ||
| {{- define "grafana.cnpg.objectStoreCredentials" -}} | ||
| {{- if eq .Values.postgresqlCluster.objectStorage.type "s3" }} | ||
| {{- if and .Values.postgresqlCluster.objectStorage.s3.accessKeyId .Values.postgresqlCluster.objectStorage.s3.secretAccessKey }} | ||
| endpointURL: {{ .Values.postgresqlCluster.objectStorage.s3.endpointURL }} | ||
| s3Credentials: | ||
| region: {{ .Values.postgresqlCluster.objectStorage.s3.region }} | ||
| accessKeyId: | ||
| name: {{ .Values.postgresqlCluster.name }}-access-keys | ||
| key: ACCESS_KEY_ID | ||
| secretAccessKey: | ||
| name: {{ .Values.postgresqlCluster.name }}-access-keys | ||
| key: SECRET_ACCESS_KEY | ||
| {{- else }} | ||
| s3Credentials: | ||
| inheritFromIAMRole: true | ||
| {{- end }} | ||
| {{- else if eq .Values.postgresqlCluster.objectStorage.type "azure" }} | ||
| {{- if .Values.postgresqlCluster.crossplane.azure.enabled }} | ||
| azureCredentials: | ||
| connectionString: | ||
| name: {{ .Values.postgresqlCluster.crossplane.azure.container.name }} | ||
| key: attribute.primary_blob_connection_string | ||
| {{- else }} | ||
| {{- with .Values.postgresqlCluster.objectStorage.azure.credentials }} | ||
| azureCredentials: | ||
| {{- toYaml . | nindent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- else }} | ||
| {{- fail "Unsupported object storage type. Supported types are 's3' and 'azure'." }} | ||
| {{- end }} | ||
| {{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| {{- if and .Values.postgresqlCluster.enabled .Values.postgresqlCluster.backup.enabled }} | ||
| --- | ||
| apiVersion: barmancloud.cnpg.io/v1 | ||
| kind: ObjectStore | ||
| metadata: | ||
| labels: | ||
| {{- include "grafana.labels" . | nindent 4 }} | ||
| observability.giantswarm.io/tenant: giantswarm | ||
| name: {{ .Values.postgresqlCluster.name }}-objectstore-backup | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| configuration: | ||
| destinationPath: {{ .Values.postgresqlCluster.backup.destinationPath | quote }} | ||
| {{- include "grafana.cnpg.objectStoreCredentials" . | nindent 4 }} | ||
| wal: | ||
| compression: gzip | ||
| retentionPolicy: {{ .Values.postgresqlCluster.backup.retentionPolicy | quote }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| {{- if and .Values.postgresqlCluster.enabled .Values.postgresqlCluster.recovery.enabled }} | ||
| --- | ||
| apiVersion: barmancloud.cnpg.io/v1 | ||
| kind: ObjectStore | ||
| metadata: | ||
| labels: | ||
| {{- include "grafana.labels" . | nindent 4 }} | ||
| observability.giantswarm.io/tenant: giantswarm | ||
| name: {{ .Values.postgresqlCluster.name }}-objectstore-recovery | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| configuration: | ||
| destinationPath: {{ .Values.postgresqlCluster.recovery.destinationPath | quote }} | ||
| {{- include "grafana.cnpg.objectStoreCredentials" . | nindent 4 }} | ||
| wal: | ||
| compression: gzip | ||
| {{- end }} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic in pseudocode currently looks like this:
Could we have a similar structure for s3 and azure?
Meaning, either we have 2-level tests
or we keep it all 1-level:
...but we do the same for all providers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably can yes