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

Support existing secret for external DB #1783

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions templates/core/core-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ data:
httpport = {{ ternary "8443" "8080" .Values.internalTLS.enabled }}
PORT: "{{ ternary "8443" "8080" .Values.internalTLS.enabled }}"
DATABASE_TYPE: "postgresql"
{{- if not .Values.database.external.existingSecret.enabled }}
POSTGRESQL_HOST: "{{ template "harbor.database.host" . }}"
POSTGRESQL_PORT: "{{ template "harbor.database.port" . }}"
POSTGRESQL_USERNAME: "{{ template "harbor.database.username" . }}"
POSTGRESQL_DATABASE: "{{ template "harbor.database.coreDatabase" . }}"
{{- end }}
POSTGRESQL_SSLMODE: "{{ template "harbor.database.sslmode" . }}"
POSTGRESQL_MAX_IDLE_CONNS: "{{ .Values.database.maxIdleConns }}"
POSTGRESQL_MAX_OPEN_CONNS: "{{ .Values.database.maxOpenConns }}"
Expand Down
34 changes: 31 additions & 3 deletions templates/core/core-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,40 @@ spec:
- name: INTERNAL_TLS_TRUST_CA_PATH
value: /etc/harbor/ssl/core/ca.crt
{{- end }}
{{- if .Values.database.external.existingSecret }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_HOST
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.host }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_PORT
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.port }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.username }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret }}
key: password
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.password }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.coreDatabase }}
{{- end }}
{{- if .Values.registry.credentials.existingSecret }}
- name: REGISTRY_CREDENTIAL_PASSWORD
Expand Down
40 changes: 34 additions & 6 deletions templates/core/core-pre-upgrade-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,41 @@ spec:
name: "{{ template "harbor.core" . }}"
- secretRef:
name: "{{ template "harbor.core" . }}"
{{- if .Values.database.external.existingSecret }}
env:
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret }}
key: password
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_HOST
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.host }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_PORT
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.port }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.username }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.password }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.coreDatabase }}
{{- end }}
{{- if not (empty .Values.containerSecurityContext) }}
securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 10 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/core/core-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data:
{{- if not .Values.existingSecretAdminPassword }}
HARBOR_ADMIN_PASSWORD: {{ .Values.harborAdminPassword | b64enc | quote }}
{{- end }}
{{- if not .Values.database.external.existingSecret }}
{{- if not .Values.database.external.existingSecret.enabled }}
POSTGRESQL_PASSWORD: {{ template "harbor.database.encryptedPassword" . }}
{{- end }}
{{- if not .Values.registry.credentials.existingSecret }}
Expand Down
2 changes: 2 additions & 0 deletions templates/exporter/exporter-cm-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ data:
HARBOR_SERVICE_SCHEME: "{{ template "harbor.component.scheme" . }}"
HARBOR_SERVICE_HOST: "{{ template "harbor.core" . }}"
HARBOR_SERVICE_PORT: "{{ template "harbor.core.servicePort" . }}"
{{- if not .Values.database.external.existingSecret.enabled }}
HARBOR_DATABASE_HOST: "{{ template "harbor.database.host" . }}"
HARBOR_DATABASE_PORT: "{{ template "harbor.database.port" . }}"
HARBOR_DATABASE_USERNAME: "{{ template "harbor.database.username" . }}"
HARBOR_DATABASE_DBNAME: "{{ template "harbor.database.coreDatabase" . }}"
{{- end }}
HARBOR_DATABASE_SSLMODE: "{{ template "harbor.database.sslmode" . }}"
HARBOR_DATABASE_MAX_IDLE_CONNS: "{{ .Values.database.maxIdleConns }}"
HARBOR_DATABASE_MAX_OPEN_CONNS: "{{ .Values.database.maxOpenConns }}"
Expand Down
34 changes: 31 additions & 3 deletions templates/exporter/exporter-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,40 @@ spec:
- secretRef:
name: "{{ template "harbor.exporter" . }}"
env:
{{- if .Values.database.external.existingSecret }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: HARBOR_DATABASE_HOST
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.host }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: HARBOR_DATABASE_PORT
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.port }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: HARBOR_DATABASE_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.username }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: HARBOR_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret }}
key: password
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.password }}
{{- end }}
{{- if .Values.database.external.existingSecret.enabled }}
- name: HARBOR_DATABASE_DBNAME
valueFrom:
secretKeyRef:
name: {{ .Values.database.external.existingSecret.name }}
key: {{ .Values.database.external.existingSecret.keys.coreDatabase }}
{{- end }}
{{- if .Values.existingSecretAdminPassword }}
- name: HARBOR_ADMIN_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion templates/exporter/exporter-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
{{- if not .Values.existingSecretAdminPassword }}
HARBOR_ADMIN_PASSWORD: {{ .Values.harborAdminPassword | b64enc | quote }}
{{- end }}
{{- if not .Values.database.external.existingSecret }}
{{- if not .Values.database.external.existingSecret.enabled }}
HARBOR_DATABASE_PASSWORD: {{ template "harbor.database.encryptedPassword" . }}
{{- end }}
{{- end }}
12 changes: 10 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,16 @@ database:
username: "user"
password: "password"
coreDatabase: "registry"
# if using existing secret, the key must be "password"
existingSecret: ""
# Use an external secret and provide key mappings
existingSecret:
enabled: false
name: "my-external-secret-name"
keys:
host: host
port: port
username: username
password: password
coreDatabase: dbName
# "disable" - No SSL
# "require" - Always SSL (skip verification)
# "verify-ca" - Always SSL (verify that the certificate presented by the
Expand Down