Skip to content

Commit

Permalink
feat: set correct naming for harbor schema values
Browse files Browse the repository at this point in the history
  • Loading branch information
Cas Lubbers committed Apr 16, 2024
1 parent 59c1ba8 commit 592a152
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 92 deletions.
6 changes: 4 additions & 2 deletions helmfile.d/helmfile-04.databases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ bases:
{{- $v := .Values }}
{{- $a := $v.apps }}
{{- $h := $a.harbor }}
{{- $hdb := $v.databases.harbor }}
{{- $kdb := $v.databases.keycloak }}
{{- $k := $a.keycloak }}

releases:
- name: harbor-otomi-db
installed: {{ and ($h | get "enabled") (or (eq $v.databases.harbor.type "external") $v.databases.harbor.importHarborDb) }}
installed: {{ and ($h | get "enabled") (or $hdb.useOtomiDB $hdb.imported) }}
namespace: harbor
labels:
pkg: harbor
<<: *otomiDb
- name: keycloak-otomi-db
installed: {{ or $v.databases.keycloak.useOtomiDB $v.databases.keycloak.imported }}
installed: {{ or $kdb.useOtomiDB $kdb.imported }}
namespace: keycloak
labels:
pkg: keycloak
Expand Down
5 changes: 3 additions & 2 deletions helmfile.d/snippets/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,13 @@ environments:
cpu: 50m
memory: 256Mi
harbor:
type: external
useOtomiDB: true
imported: false
size: '5Gi'
replicas: 2
name: harbor-otomi-db
user: harbor
coreDatabase: registry
importHarborDb: false
platformBackups:
database:
harbor:
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/env/databases/harbor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
databases:
harbor:
type: internal
importHarborDb: true
useOtomiDB: true
imported: true
9 changes: 8 additions & 1 deletion values-changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ changes:
- version: 21
deletions:
- 'apps.harbor.databasePassword'
- 'apps.harbor.database.type'
additions:
- databases.harbor.useOtomiDB: true
- databases.harbor.replicas: 2
relocations:
- 'apps.harbor.database': 'databases.harbor'
- 'apps.harbor.database.size': 'databases.harbor.size'
- 'apps.harbor.database.name': 'databases.harbor.name'
- 'apps.harbor.database.user': 'databases.harbor.user'
- 'apps.harbor.database.importHarborDb': 'databases.harbor.imported'
- 'apps.harbor.resources.database': 'databases.harbor.resources'
22 changes: 11 additions & 11 deletions values-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4087,23 +4087,23 @@ properties:
harbor:
title: Harbor
properties:
useOtomiDB:
type: boolean
default: false
size:
type: string
type:
type: string
description: Internal is a database provided by the community chart. The external is database provided by the cloudnative-pg.
enum:
- internal
- external
resources:
$ref: '#/definitions/resources'
replicas:
type: integer
default: 2
imported:
type: boolean
name:
type: string
user:
type: string
importHarborDb:
description: Indicate if an existing database should be importend. (Once set to true you must not change it back)
type: boolean
resources:
$ref: '#/definitions/resources'

teamConfig:
additionalProperties: false
patternProperties:
Expand Down
23 changes: 12 additions & 11 deletions values/harbor/harbor-otomi-db.gotmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{{- $v := .Values }}
{{- $h := $v.databases.harbor }}
{{- $hdb := $v.databases.harbor }}
{{- $cnpg := $v.apps.cnpg }}
{{- $sp := $cnpg.storage }}
{{- $b := $v.platformBackups.database.harbor }}

name: {{ $h.name }}
name: {{ $hdb.name }}
storage:
size: {{ $h.size }}
size: {{ $hdb.size }}
instances: {{ $hdb.replicas }}

{{- if $b.enabled }}
backup:
Expand All @@ -31,24 +32,24 @@ backup:
{{- end }}


{{- if $h.importHarborDb }}
{{- if $hdb.imported }}
clusterSpec:
bootstrap:
initdb:
database: {{ $h.coreDatabase }}
owner: {{ $h.user }}
database: {{ $hdb.coreDatabase }}
owner: {{ $hdb.user }}
import:
type: microservice
databases:
- {{ $h.coreDatabase }}
- {{ $hdb.coreDatabase }}
source:
externalCluster: harbor-database
externalClusters:
- name: harbor-database
connectionParameters:
host: harbor-database.harbor.svc.cluster.local
user: postgres
dbname: {{ $h.coreDatabase }}
dbname: {{ $hdb.coreDatabase }}
sslmode: disable
password:
name: harbor-database
Expand All @@ -57,15 +58,15 @@ clusterSpec:
clusterSpec:
bootstrap:
initdb:
database: {{ $h.coreDatabase }}
owner: {{ $h.user }}
database: {{ $hdb.coreDatabase }}
owner: {{ $hdb.user }}
localeCollate: 'en_US.UTF-8'
localeCType: 'en_US.UTF-8'
{{- end }}


resources:
{{- with $h | get "resources" nil }}
{{- with $hdb | get "resources" nil }}
{{- toYaml . | nindent 6 }}
{{- else }}
limits:
Expand Down
39 changes: 2 additions & 37 deletions values/harbor/harbor.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,49 +65,14 @@ core:
xsrfKey: {{ $h | get "core.xsrfKey" nil }}

database:
type: {{ $db.type }}
{{- if eq $db.type "internal" }}
internal:
priorityClassName: otomi-critical
image:
tag: {{ $tag }}
initContainer:
migrator:
resources:
limits:
cpu: 100m
memory: 512Mi
requests:
cpu: 50m
memory: 256Mi
permissions:
resources:
limits:
cpu: 100m
memory: 512Mi
requests:
cpu: 50m
memory: 256Mi
resources:
{{- with $db | get "resources" nil }}
{{- toYaml . | nindent 6 }}
{{- else }}
limits:
cpu: 100m
memory: 512Mi
requests:
cpu: 50m
memory: 256Mi
{{- end }}
{{- else }}
type: external
external:
# erase default password value from the Harbor Helm chart
password: null
coreDatbase: {{ $db.coreDatabase }}
coreDatabase: {{ $db.coreDatabase }}
username: {{ $db.user }}
host: {{ $databaseHost }}
existingSecret: {{ $databaseExistingSecret }}
{{- end }}
podAnnotations:
# this exception allows the chmod fix to pass, which needs root access:
policy.otomi.io/ignore.data-migrator: psp-allowed-users
Expand Down
26 changes: 0 additions & 26 deletions values/jobs/harbor-backup.gotmpl

This file was deleted.

0 comments on commit 592a152

Please sign in to comment.