Skip to content

Commit

Permalink
Merge pull request #4 from OpSecId/fix-chart-template
Browse files Browse the repository at this point in the history
fix charts
  • Loading branch information
esune authored Nov 26, 2024
2 parents 69df98f + adbe23f commit 377643f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 41 deletions.
2 changes: 1 addition & 1 deletion charts/orgbook-publisher/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
25 changes: 2 additions & 23 deletions charts/orgbook-publisher/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand All @@ -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 -}}
Expand Down
4 changes: 2 additions & 2 deletions charts/orgbook-publisher/templates/mongodb/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }}
Expand All @@ -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 }}
Expand Down
17 changes: 5 additions & 12 deletions charts/orgbook-publisher/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ fullnameOverride: "orgbook-publisher"

selectorLabels: {}

database:
existingSecret: ''

ingress:
tls: false
labels: []
Expand All @@ -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

Expand Down

0 comments on commit 377643f

Please sign in to comment.