|
| 1 | +{{/* |
| 2 | +Object store credentials for CNPG barman-cloud ObjectStore resources. |
| 3 | +
|
| 4 | +Outputs the appropriate credentials block based on the configured storage type. |
| 5 | +Intended to be called with `{{- include "grafana.cnpg.objectStoreCredentials" . | nindent 4 }}`. |
| 6 | +
|
| 7 | +Credential paths: |
| 8 | +
|
| 9 | + S3 with explicit keys: |
| 10 | + Condition: objectStorage.type == "s3" AND s3.accessKeyId AND s3.secretAccessKey are set |
| 11 | + Use case: customers providing their own S3 bucket with static credentials |
| 12 | + Source: the <cluster-name>-access-keys Secret (rendered by access-keys-secret.yaml) |
| 13 | +
|
| 14 | + S3 with IRSA: |
| 15 | + Condition: objectStorage.type == "s3", no explicit keys |
| 16 | + Use case: AWS/CAPA clusters with an IAM role configured for the CNPG service account |
| 17 | + Source: pod's IAM role via IRSA (no secret needed) |
| 18 | +
|
| 19 | + Azure with Crossplane: |
| 20 | + Condition: objectStorage.type == "azure" AND crossplane.azure.enabled == true |
| 21 | + Use case: CAPZ clusters where Crossplane provisions the storage account |
| 22 | + Source: connection string from the Crossplane-generated secret |
| 23 | + (key: attribute.primary_blob_connection_string) |
| 24 | +
|
| 25 | + Azure manual: |
| 26 | + Condition: objectStorage.type == "azure", Crossplane not enabled |
| 27 | + Use case: non-Crossplane Azure installs with an existing storage account |
| 28 | + Source: azureCredentials passthrough from objectStorage.azure.credentials |
| 29 | +*/}} |
| 30 | +{{- define "grafana.cnpg.objectStoreCredentials" -}} |
| 31 | +{{- if eq .Values.postgresqlCluster.objectStorage.type "s3" }} |
| 32 | +{{- if and .Values.postgresqlCluster.objectStorage.s3.accessKeyId .Values.postgresqlCluster.objectStorage.s3.secretAccessKey }} |
| 33 | +endpointURL: {{ .Values.postgresqlCluster.objectStorage.s3.endpointURL }} |
| 34 | +s3Credentials: |
| 35 | + region: {{ .Values.postgresqlCluster.objectStorage.s3.region }} |
| 36 | + accessKeyId: |
| 37 | + name: {{ .Values.postgresqlCluster.name }}-access-keys |
| 38 | + key: ACCESS_KEY_ID |
| 39 | + secretAccessKey: |
| 40 | + name: {{ .Values.postgresqlCluster.name }}-access-keys |
| 41 | + key: SECRET_ACCESS_KEY |
| 42 | +{{- else }} |
| 43 | +s3Credentials: |
| 44 | + inheritFromIAMRole: true |
| 45 | +{{- end }} |
| 46 | +{{- else if eq .Values.postgresqlCluster.objectStorage.type "azure" }} |
| 47 | +{{- if .Values.postgresqlCluster.crossplane.azure.enabled }} |
| 48 | +azureCredentials: |
| 49 | + connectionString: |
| 50 | + name: {{ .Values.postgresqlCluster.crossplane.azure.container.name }} |
| 51 | + key: attribute.primary_blob_connection_string |
| 52 | +{{- else }} |
| 53 | +{{- with .Values.postgresqlCluster.objectStorage.azure.credentials }} |
| 54 | +azureCredentials: |
| 55 | + {{- toYaml . | nindent 2 }} |
| 56 | +{{- end }} |
| 57 | +{{- end }} |
| 58 | +{{- else }} |
| 59 | +{{- fail "Unsupported object storage type. Supported types are 's3' and 'azure'." }} |
| 60 | +{{- end }} |
| 61 | +{{- end -}} |
0 commit comments