diff --git a/charts/orgbook-publisher/Chart.yaml b/charts/orgbook-publisher/Chart.yaml index 2666157..c4ef1d3 100644 --- a/charts/orgbook-publisher/Chart.yaml +++ b/charts/orgbook-publisher/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: orgbook-publisher description: An api server to register and manage credentials. type: application -version: 0.0.1 +version: 0.0.2 appVersion: "0.0.1" dependencies: diff --git a/charts/orgbook-publisher/templates/_helpers.tpl b/charts/orgbook-publisher/templates/_helpers.tpl index 8a8a271..64d8655 100644 --- a/charts/orgbook-publisher/templates/_helpers.tpl +++ b/charts/orgbook-publisher/templates/_helpers.tpl @@ -66,31 +66,10 @@ app.kubernetes.io/name: {{ include "backend.fullname" . }} {{- end -}} - -{{/* -Returns a secret if it already in Kubernetes, otherwise it creates -it randomly. - -Usage: -{{ include "getOrGeneratePass" (dict "Namespace" .Release.Namespace "Kind" "Secret" "Name" (include "vc-authn-oidc.databaseSecretName" .) "Key" "mongodb-root-password" "Length" 32) }} - -*/}} -{{- define "getOrGeneratePass" }} -{{- $len := (default 16 .Length) | int -}} -{{- $obj := (lookup "v1" .Kind .Namespace .Name).data -}} -{{- if $obj }} -{{- index $obj .Key -}} -{{- else if (eq (lower .Kind) "secret") -}} -{{- randAlphaNum $len | b64enc -}} -{{- else -}} -{{- randAlphaNum $len -}} -{{- end -}} -{{- end }} - {{/* Define the name of the database secret to use */}} -{{- define "orgbook-publisher.databaseSecretName" -}} +{{- define "backend.databaseSecretName" -}} {{- if (empty .Values.database.existingSecret) -}} {{- printf "%s-%s" .Release.Name "mongodb" | trunc 63 | trimSuffix "-" }} {{- else -}} @@ -101,7 +80,7 @@ Define the name of the database secret to use {{/* Return true if a database secret should be created */}} -{{- define "orgbook-publisher.database.createSecret" -}} +{{- define "backend.database.createSecret" -}} {{- if not .Values.database.existingSecret -}} {{- true -}} {{- end -}} diff --git a/charts/orgbook-publisher/templates/mongodb/networkpolicy.yaml b/charts/orgbook-publisher/templates/mongodb/networkpolicy.yaml index 23f86ea..2dc8b58 100644 --- a/charts/orgbook-publisher/templates/mongodb/networkpolicy.yaml +++ b/charts/orgbook-publisher/templates/mongodb/networkpolicy.yaml @@ -4,14 +4,14 @@ kind: NetworkPolicy metadata: name: {{ include "global.fullname" . }}-db labels: - {{- include "orgbook-publisher.labels" . | nindent 4 }} + {{- include "backend.labels" . | nindent 4 }} spec: # Allow traffic from the controller to the db, and between db pods ingress: - from: - podSelector: matchLabels: - {{- include "orgbook-publisher.selectorLabels" . | nindent 14 }} + {{- include "backend.selectorLabels" . | nindent 14 }} - podSelector: {{- with .Values.mongodb.commonLabels }} matchLabels: diff --git a/charts/orgbook-publisher/templates/secrets.yaml b/charts/orgbook-publisher/templates/mongodb/secrets.yaml similarity index 81% rename from charts/orgbook-publisher/templates/secrets.yaml rename to charts/orgbook-publisher/templates/mongodb/secrets.yaml index 2f6caab..4c696d9 100644 --- a/charts/orgbook-publisher/templates/secrets.yaml +++ b/charts/orgbook-publisher/templates/mongodb/secrets.yaml @@ -1,5 +1,5 @@ -{{- if (include "orgbook-publisher.database.createSecret" .) -}} -{{ $databaseSecretName := (include "orgbook-publisher.databaseSecretName" .) }} +{{- if (include "backend.database.createSecret" .) -}} +{{ $databaseSecretName := (include "backend.databaseSecretName" .) }} {{ $mongoRootPassword := include "getOrGeneratePass" (dict "Namespace" .Release.Namespace "Kind" "Secret" "Name" $databaseSecretName "Key" "mongodb-root-password" "Length" 32) }} {{ $mongoReplicaSetKey := include "getOrGeneratePass" (dict "Namespace" .Release.Namespace "Kind" "Secret" "Name" $databaseSecretName "Key" "mongodb-replica-set-key" "Length" 32) }} {{ $mongoPasswords := include "getOrGeneratePass" (dict "Namespace" .Release.Namespace "Kind" "Secret" "Name" $databaseSecretName "Key" "mongodb-passwords" "Length" 32) }} @@ -8,7 +8,7 @@ kind: Secret metadata: name: {{ $databaseSecretName }} labels: - {{- include "orgbook-publisher.labels" . | nindent 4 }} + {{- include "backend.labels" . | nindent 4 }} annotations: "helm.sh/resource-policy": keep namespace: {{ .Release.Namespace }} diff --git a/charts/orgbook-publisher/values.yaml b/charts/orgbook-publisher/values.yaml index 4e7c19a..f1fc77d 100644 --- a/charts/orgbook-publisher/values.yaml +++ b/charts/orgbook-publisher/values.yaml @@ -4,6 +4,9 @@ fullnameOverride: "orgbook-publisher" selectorLabels: {} +database: + existingSecret: '' + ingress: tls: false labels: [] @@ -15,20 +18,10 @@ networkPolicy: backend: image: - repository: ghcr.io/OpSecId/orgbook-publisher - tag: 0.0.1 + repository: ghcr.io/bcgov/orgbook-publisher-service + tag: v0.0.1 pullPolicy: IfNotPresent pullSecrets: [] - # host is required when enabling TLS in the ingress - # host: publisher.myapp.example - - environment: - TRACTION_API_URL: "" - TRACTION_API_KEY: "" - TRACTION_TENANT_ID: "" - ORGBOOK_URL: "" - TDW_SERVER_URL: "" - TDW_ENDORSER_MULTIKEY: "" replicaCount: 1