From bef857a7dc7b58042caa21486ae7d23bc7fd8f5d Mon Sep 17 00:00:00 2001 From: jon4hz Date: Wed, 28 Dec 2022 15:02:52 +0100 Subject: [PATCH 01/11] fix: allow image overrides --- helm-charts/infisical/templates/backend-deployment.yaml | 2 +- helm-charts/infisical/templates/frontend-deployment.yaml | 2 +- helm-charts/infisical/values.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helm-charts/infisical/templates/backend-deployment.yaml b/helm-charts/infisical/templates/backend-deployment.yaml index 437995e586..f3d8a2ed47 100644 --- a/helm-charts/infisical/templates/backend-deployment.yaml +++ b/helm-charts/infisical/templates/backend-deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: backend - image: infisical/backend + image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.backend.image.pullPolicy }} ports: - containerPort: 4000 diff --git a/helm-charts/infisical/templates/frontend-deployment.yaml b/helm-charts/infisical/templates/frontend-deployment.yaml index 14be955062..da9b4d828f 100644 --- a/helm-charts/infisical/templates/frontend-deployment.yaml +++ b/helm-charts/infisical/templates/frontend-deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: frontend - image: infisical/frontend + image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.frontend.image.pullPolicy }} {{- if .Values.frontend.kubeSecretRef }} envFrom: diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index 743c1e25b9..0633c21270 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -6,7 +6,7 @@ frontend: replicaCount: 1 image: - repository: + repository: infisical/frontend pullPolicy: IfNotPresent tag: "latest" # kubeSecretRef: some-kube-secret-name @@ -15,7 +15,7 @@ frontend: backend: replicaCount: 1 image: - repository: + repository: infisical/backend pullPolicy: IfNotPresent tag: "latest" # kubeSecretRef: some-kube-secret-name From 21439761c3cc5555fa8017c63bf385a91123e24d Mon Sep 17 00:00:00 2001 From: jon4hz Date: Wed, 28 Dec 2022 15:16:36 +0100 Subject: [PATCH 02/11] fix: allow frontend service type overrides --- helm-charts/infisical/templates/frontend-deployment.yaml | 1 + helm-charts/infisical/values.yaml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/helm-charts/infisical/templates/frontend-deployment.yaml b/helm-charts/infisical/templates/frontend-deployment.yaml index da9b4d828f..99d94f9b98 100644 --- a/helm-charts/infisical/templates/frontend-deployment.yaml +++ b/helm-charts/infisical/templates/frontend-deployment.yaml @@ -41,6 +41,7 @@ kind: Service metadata: name: infisical-frontend-service spec: + type: {{ .Values.frontend.service.type }} selector: app: frontend ports: diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index 0633c21270..ba4457d50c 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -10,7 +10,8 @@ frontend: pullPolicy: IfNotPresent tag: "latest" # kubeSecretRef: some-kube-secret-name - + service: + type: ClusterIP backend: replicaCount: 1 From da5800c268c09b6d09558d55041474ac692719f3 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Wed, 28 Dec 2022 15:25:47 +0100 Subject: [PATCH 03/11] fix: allow setting of nodeport --- helm-charts/infisical/templates/frontend-deployment.yaml | 3 +++ helm-charts/infisical/values.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/helm-charts/infisical/templates/frontend-deployment.yaml b/helm-charts/infisical/templates/frontend-deployment.yaml index 99d94f9b98..c276ed8a50 100644 --- a/helm-charts/infisical/templates/frontend-deployment.yaml +++ b/helm-charts/infisical/templates/frontend-deployment.yaml @@ -48,3 +48,6 @@ spec: - protocol: TCP port: 3000 # service targetPort: 3000 # container port + {{- if eq .Values.frontend.service.type "NodePort" }} + nodePort: {{ .Values.frontend.service.nodePort }} + {{- end }} \ No newline at end of file diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index ba4457d50c..8aa70ea81a 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -11,7 +11,10 @@ frontend: tag: "latest" # kubeSecretRef: some-kube-secret-name service: + # type of the frontend service type: ClusterIP + # define the nodePort if service type is NodePort + # nodePort: backend: replicaCount: 1 From 4880cd84dc83fe217e640d3bb4fe1df95f7a1e53 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Wed, 28 Dec 2022 15:42:47 +0100 Subject: [PATCH 04/11] refactor: naming, labels and selectors --- helm-charts/infisical/templates/_helpers.tpl | 114 ++++++++++++++++++ .../templates/backend-deployment.yaml | 18 +-- .../templates/frontend-deployment.yaml | 16 +-- helm-charts/infisical/templates/ingress.yaml | 4 +- .../templates/mongodb-deployment.yaml | 19 +-- helm-charts/infisical/values.yaml | 11 ++ 6 files changed, 157 insertions(+), 25 deletions(-) create mode 100644 helm-charts/infisical/templates/_helpers.tpl diff --git a/helm-charts/infisical/templates/_helpers.tpl b/helm-charts/infisical/templates/_helpers.tpl new file mode 100644 index 0000000000..d05f2d0471 --- /dev/null +++ b/helm-charts/infisical/templates/_helpers.tpl @@ -0,0 +1,114 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "infisical.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "infisical.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create unified labels for infisical components +*/}} +{{- define "infisical.common.matchLabels" -}} +app: {{ template "infisical.name" . }} +release: {{ .Release.Name }} +{{- end -}} + +{{- define "infisical.common.metaLabels" -}} +chart: {{ template "infisical.chart" . }} +heritage: {{ .Release.Service }} +{{- end -}} + +{{- define "infisical.common.labels" -}} +{{ include "infisical.common.matchLabels" . }} +{{ include "infisical.common.metaLabels" . }} +{{- end -}} + + +{{- define "infisical.backend.labels" -}} +{{ include "infisical.backend.matchLabels" . }} +{{ include "infisical.common.metaLabels" . }} +{{- end -}} + +{{- define "infisical.backend.matchLabels" -}} +component: {{ .Values.backend.name | quote }} +{{ include "infisical.common.matchLabels" . }} +{{- end -}} + +{{- define "infisical.frontend.labels" -}} +{{ include "infisical.frontend.matchLabels" . }} +{{ include "infisical.common.metaLabels" . }} +{{- end -}} + +{{- define "infisical.frontend.matchLabels" -}} +component: {{ .Values.frontend.name | quote }} +{{ include "infisical.common.matchLabels" . }} +{{- end -}} + +{{- define "infisical.mongodb.labels" -}} +{{ include "infisical.mongodb.matchLabels" . }} +{{ include "infisical.common.metaLabels" . }} +{{- end -}} + +{{- define "infisical.mongodb.matchLabels" -}} +component: {{ .Values.mongodb.name | quote }} +{{ include "infisical.common.matchLabels" . }} +{{- end -}} + +{{/* +Create a fully qualified backend proxy name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "infisical.backend.fullname" -}} +{{- if .Values.backend.fullnameOverride -}} +{{- .Values.backend.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- printf "%s-%s" .Release.Name .Values.backend.name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s-%s" .Release.Name $name .Values.backend.name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create a fully qualified frontend manager name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "infisical.frontend.fullname" -}} +{{- if .Values.frontend.fullnameOverride -}} +{{- .Values.frontend.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- printf "%s-%s" .Release.Name .Values.frontend.name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s-%s" .Release.Name $name .Values.frontend.name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create a fully qualified mongodb collector name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "infisical.mongodb.fullname" -}} +{{- if .Values.mongodb.fullnameOverride -}} +{{- .Values.mongodb.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- printf "%s-%s" .Release.Name .Values.mongodb.name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s-%s" .Release.Name $name .Values.mongodb.name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + diff --git a/helm-charts/infisical/templates/backend-deployment.yaml b/helm-charts/infisical/templates/backend-deployment.yaml index f3d8a2ed47..b42facae6d 100644 --- a/helm-charts/infisical/templates/backend-deployment.yaml +++ b/helm-charts/infisical/templates/backend-deployment.yaml @@ -1,22 +1,22 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ .Release.Name }}-backend-deployment + name: {{ include "infisical.backend.fullname" . }} labels: - app: backend + {{- include "infisical.backend.labels" . | nindent 4 }} spec: replicas: {{ .Values.backend.replicaCount }} selector: matchLabels: - app: backend + {{- include "infisical.backend.matchLabels" . | nindent 6 }} template: metadata: labels: - app: backend + {{- include "infisical.backend.matchLabels" . | nindent 8 }} spec: containers: - - name: backend - image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}" + - name: {{ template "infisical.name" . }}-{{ .Values.backend.name }} + image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.backend.image.pullPolicy }} ports: - containerPort: 4000 @@ -38,10 +38,12 @@ spec: apiVersion: v1 kind: Service metadata: - name: infisical-backend-service + name: {{ include "infisical.backend.fullname" . }} + labels: + {{- include "infisical.backend.labels" . | nindent 4 }} spec: selector: - app: backend + {{- include "infisical.backend.matchLabels" . | nindent 8 }} ports: - protocol: TCP port: 4000 diff --git a/helm-charts/infisical/templates/frontend-deployment.yaml b/helm-charts/infisical/templates/frontend-deployment.yaml index c276ed8a50..fef312cbb1 100644 --- a/helm-charts/infisical/templates/frontend-deployment.yaml +++ b/helm-charts/infisical/templates/frontend-deployment.yaml @@ -1,21 +1,21 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ .Release.Name }}-frontend-deployment + name: {{ include "infisical.frontend.fullname" . }} labels: - app: frontend + {{- include "infisical.frontend.labels" . | nindent 4 }} spec: replicas: {{ .Values.frontend.replicaCount }} selector: matchLabels: - app: frontend + {{- include "infisical.frontend.matchLabels" . | nindent 6 }} template: metadata: labels: - app: frontend + {{- include "infisical.frontend.matchLabels" . | nindent 8 }} spec: containers: - - name: frontend + - name: {{ template "infisical.name" . }}-{{ .Values.frontend.name }} image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.frontend.image.pullPolicy }} {{- if .Values.frontend.kubeSecretRef }} @@ -39,11 +39,13 @@ spec: apiVersion: v1 kind: Service metadata: - name: infisical-frontend-service + name: {{ include "infisical.frontend.fullname" . }} + labels: + {{- include "infisical.frontend.labels" . | nindent 4 }} spec: type: {{ .Values.frontend.service.type }} selector: - app: frontend + {{- include "infisical.frontend.matchLabels" . | nindent 8 }} ports: - protocol: TCP port: 3000 # service diff --git a/helm-charts/infisical/templates/ingress.yaml b/helm-charts/infisical/templates/ingress.yaml index a987627f4b..cf9952ea3d 100644 --- a/helm-charts/infisical/templates/ingress.yaml +++ b/helm-charts/infisical/templates/ingress.yaml @@ -26,14 +26,14 @@ spec: pathType: {{ .Values.ingress.frontend.pathType }} backend: service: - name: infisical-frontend-service + name: {{ include "infisical.frontend.fullname" . }} port: number: 3000 - path: {{ .Values.ingress.backend.path }} pathType: {{ .Values.ingress.backend.pathType }} backend: service: - name: infisical-backend-service + name: {{ include "infisical.backend.fullname" . }} port: number: 4000 {{ end }} \ No newline at end of file diff --git a/helm-charts/infisical/templates/mongodb-deployment.yaml b/helm-charts/infisical/templates/mongodb-deployment.yaml index 90b755ad3e..64fe08acc4 100644 --- a/helm-charts/infisical/templates/mongodb-deployment.yaml +++ b/helm-charts/infisical/templates/mongodb-deployment.yaml @@ -1,22 +1,23 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: mongodb-deployment + name: {{ include "infisical.mongodb.fullname" . }} labels: - app: mongodb + {{- include "infisical.mongodb.labels" . | nindent 4 }} spec: replicas: 1 # Cannot be scaled. To scale, you must set up Stateful Set selector: matchLabels: - app: mongodb + {{- include "infisical.mongodb.matchLabels" . | nindent 6 }} template: metadata: labels: - app: mongodb + {{- include "infisical.mongodb.matchLabels" . | nindent 8 }} spec: containers: - - name: mongodb - image: mongo + - name: {{ template "infisical.name" . }}-{{ .Values.mongodb.name }} + image: "{{ .Values.mongodb.image.repository }}:{{ .Values.mongodb.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.mongodb.image.pullPolicy }} ports: - containerPort: 27017 env: @@ -28,10 +29,12 @@ spec: apiVersion: v1 kind: Service metadata: - name: mongodb-service + name: {{ include "infisical.mongodb.fullname" . }} + labels: + {{- include "infisical.mongodb.labels" . | nindent 4 }} spec: selector: - app: mongodb + {{- include "infisical.mongodb.matchLabels" . | nindent 8 }} ports: - protocol: TCP port: 27017 diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index 8aa70ea81a..7ed70b8628 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -3,7 +3,10 @@ # PLEASE REPLACE VALUES/EDIT AS REQUIRED ##### +nameOverride: "" + frontend: + name: frontend replicaCount: 1 image: repository: infisical/frontend @@ -17,6 +20,7 @@ frontend: # nodePort: backend: + name: backend replicaCount: 1 image: repository: infisical/backend @@ -24,6 +28,13 @@ backend: tag: "latest" # kubeSecretRef: some-kube-secret-name +mongodb: + name: mongodb + image: + repository: mongo + pullPolicy: IfNotPresent + tag: "latest" + ingress: enabled: true annotations: From d683e385ae6397c8de931ea9a42d697abf5bb013 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Wed, 28 Dec 2022 16:36:33 +0100 Subject: [PATCH 05/11] fix: add support for custom annotations --- helm-charts/infisical/templates/backend-deployment.yaml | 8 ++++++++ helm-charts/infisical/templates/frontend-deployment.yaml | 8 ++++++++ helm-charts/infisical/templates/mongodb-deployment.yaml | 8 ++++++++ helm-charts/infisical/values.yaml | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/helm-charts/infisical/templates/backend-deployment.yaml b/helm-charts/infisical/templates/backend-deployment.yaml index b42facae6d..01e216092e 100644 --- a/helm-charts/infisical/templates/backend-deployment.yaml +++ b/helm-charts/infisical/templates/backend-deployment.yaml @@ -13,6 +13,10 @@ spec: metadata: labels: {{- include "infisical.backend.matchLabels" . | nindent 8 }} + {{- with .Values.backend.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} spec: containers: - name: {{ template "infisical.name" . }}-{{ .Values.backend.name }} @@ -41,6 +45,10 @@ metadata: name: {{ include "infisical.backend.fullname" . }} labels: {{- include "infisical.backend.labels" . | nindent 4 }} + {{- with .Values.backend.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: selector: {{- include "infisical.backend.matchLabels" . | nindent 8 }} diff --git a/helm-charts/infisical/templates/frontend-deployment.yaml b/helm-charts/infisical/templates/frontend-deployment.yaml index fef312cbb1..de64905957 100644 --- a/helm-charts/infisical/templates/frontend-deployment.yaml +++ b/helm-charts/infisical/templates/frontend-deployment.yaml @@ -13,6 +13,10 @@ spec: metadata: labels: {{- include "infisical.frontend.matchLabels" . | nindent 8 }} + {{- with .Values.frontend.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} spec: containers: - name: {{ template "infisical.name" . }}-{{ .Values.frontend.name }} @@ -42,6 +46,10 @@ metadata: name: {{ include "infisical.frontend.fullname" . }} labels: {{- include "infisical.frontend.labels" . | nindent 4 }} + {{- with .Values.frontend.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: type: {{ .Values.frontend.service.type }} selector: diff --git a/helm-charts/infisical/templates/mongodb-deployment.yaml b/helm-charts/infisical/templates/mongodb-deployment.yaml index 64fe08acc4..c9a4b13a81 100644 --- a/helm-charts/infisical/templates/mongodb-deployment.yaml +++ b/helm-charts/infisical/templates/mongodb-deployment.yaml @@ -13,6 +13,10 @@ spec: metadata: labels: {{- include "infisical.mongodb.matchLabels" . | nindent 8 }} + {{- with .Values.mongodb.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} spec: containers: - name: {{ template "infisical.name" . }}-{{ .Values.mongodb.name }} @@ -32,6 +36,10 @@ metadata: name: {{ include "infisical.mongodb.fullname" . }} labels: {{- include "infisical.mongodb.labels" . | nindent 4 }} + {{- with .Values.mongodb.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: selector: {{- include "infisical.mongodb.matchLabels" . | nindent 8 }} diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index 7ed70b8628..584ec78605 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -7,6 +7,7 @@ nameOverride: "" frontend: name: frontend + podAnnotations: {} replicaCount: 1 image: repository: infisical/frontend @@ -18,22 +19,29 @@ frontend: type: ClusterIP # define the nodePort if service type is NodePort # nodePort: + annotations: {} backend: name: backend + podAnnotations: {} replicaCount: 1 image: repository: infisical/backend pullPolicy: IfNotPresent tag: "latest" # kubeSecretRef: some-kube-secret-name + service: + annotations: {} mongodb: name: mongodb + podAnnotations: {} image: repository: mongo pullPolicy: IfNotPresent tag: "latest" + service: + annotations: {} ingress: enabled: true From 53502e22f4be45412b693e2a838db8c83e7d86a5 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Thu, 29 Dec 2022 01:35:11 +0100 Subject: [PATCH 06/11] fix: comments --- helm-charts/infisical/templates/_helpers.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helm-charts/infisical/templates/_helpers.tpl b/helm-charts/infisical/templates/_helpers.tpl index d05f2d0471..8012f636a6 100644 --- a/helm-charts/infisical/templates/_helpers.tpl +++ b/helm-charts/infisical/templates/_helpers.tpl @@ -62,7 +62,7 @@ component: {{ .Values.mongodb.name | quote }} {{- end -}} {{/* -Create a fully qualified backend proxy name. +Create a fully qualified backend name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} {{- define "infisical.backend.fullname" -}} @@ -79,7 +79,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- end -}} {{/* -Create a fully qualified frontend manager name. +Create a fully qualified frontend name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} {{- define "infisical.frontend.fullname" -}} @@ -96,7 +96,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- end -}} {{/* -Create a fully qualified mongodb collector name. +Create a fully qualified mongodb name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} {{- define "infisical.mongodb.fullname" -}} From c23b291f250a3f0d9671872c5ae826e42e4848ac Mon Sep 17 00:00:00 2001 From: jon4hz Date: Sat, 14 Jan 2023 19:48:07 +0100 Subject: [PATCH 07/11] fix: mongodb connection --- helm-charts/infisical/templates/_helpers.tpl | 24 +++++++++++++++++++ .../templates/backend-deployment.yaml | 2 ++ helm-charts/infisical/values.yaml | 13 ++++++---- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/helm-charts/infisical/templates/_helpers.tpl b/helm-charts/infisical/templates/_helpers.tpl index 8012f636a6..2f2bf2a3ab 100644 --- a/helm-charts/infisical/templates/_helpers.tpl +++ b/helm-charts/infisical/templates/_helpers.tpl @@ -112,3 +112,27 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- end -}} {{- end -}} +{{/* +Create the mongodb connection string. +*/}} +{{- define "infisical.mongodb.connectionString" -}} +{{- $host := include "infisical.mongodb.fullname" . -}} +{{- $port := 27017 -}} +{{- $user := "root" -}} +{{- $pass := "root" -}} +{{- if .Values.mongodbConnection -}} +{{- if .Values.mongodbConnection.host -}} +{{- $host = .Values.mongodbConnection.host -}} +{{- end -}} +{{- if .Values.mongodbConnection.port -}} +{{- $port = .Values.mongodbConnection.port -}} +{{- end -}} +{{- if .Values.mongodbConnection.username -}} +{{- $user = .Values.mongodbConnection.username -}} +{{- end -}} +{{- if .Values.mongodbConnection.password -}} +{{- $pass = .Values.mongodbConnection.password -}} +{{- end -}} +{{- end -}} +{{- printf "mongodb://%s:%s@%s:%d/" $user $pass $host $port -}} +{{- end -}} diff --git a/helm-charts/infisical/templates/backend-deployment.yaml b/helm-charts/infisical/templates/backend-deployment.yaml index 01e216092e..7e4b922a25 100644 --- a/helm-charts/infisical/templates/backend-deployment.yaml +++ b/helm-charts/infisical/templates/backend-deployment.yaml @@ -30,6 +30,8 @@ spec: name: {{ .Values.backend.kubeSecretRef }} {{- end }} env: + - name: MONGO_URL + value: {{ include "infisical.mongodb.connectionString" . | quote }} {{- range $key, $value := .Values.backendEnvironmentVariables }} {{- if $value | quote | eq "MUST_REPLACE" }} {{ fail "Environment variables are not set. Please set all environment variables to continue." }} diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index 584ec78605..e51f081d3d 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -43,6 +43,14 @@ mongodb: service: annotations: {} + +# Recommended to replace with Mongo Cloud URI as the DB instance in the cluster does not have persistence yet +mongodbConnection: {} + # host: mymongodb.com # defaults to the internal mongo service + # port: 27017 + # username: root + # password: root + ingress: enabled: true annotations: @@ -56,6 +64,7 @@ ingress: pathType: Prefix tls: [] + ## Complete Ingress example # ingress: # enabled: true @@ -94,8 +103,4 @@ backendEnvironmentVariables: SMTP_USERNAME: MUST_REPLACE SMTP_PASSWORD: MUST_REPLACE - # Recommended to replace with Mongo Cloud URI as the DB instance in the cluster does not have persistence yet - MONGO_URL: mongodb://root:root@mongodb-service:27017/ - # frontendEnvironmentVariables: - \ No newline at end of file From fd2966610c163a9929eca121c8699322de9d45fa Mon Sep 17 00:00:00 2001 From: jon4hz Date: Sat, 14 Jan 2023 19:58:08 +0100 Subject: [PATCH 08/11] fix: typo --- helm-charts/infisical/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index e51f081d3d..0425065d22 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -1,5 +1,5 @@ ##### -# INFISICAL K8 DEFAULT VALUES FIL +# INFISICAL K8 DEFAULT VALUES FILE # PLEASE REPLACE VALUES/EDIT AS REQUIRED ##### From 375412b45d0b66cf82f6907dd26e76cd46758b8c Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 17 Jan 2023 22:34:19 -0800 Subject: [PATCH 09/11] Allow mongo connection string based on type --- helm-charts/infisical/templates/_helpers.tpl | 19 ++++++------------- helm-charts/infisical/values.yaml | 15 +++++++-------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/helm-charts/infisical/templates/_helpers.tpl b/helm-charts/infisical/templates/_helpers.tpl index 2f2bf2a3ab..32bc9b02bf 100644 --- a/helm-charts/infisical/templates/_helpers.tpl +++ b/helm-charts/infisical/templates/_helpers.tpl @@ -120,19 +120,12 @@ Create the mongodb connection string. {{- $port := 27017 -}} {{- $user := "root" -}} {{- $pass := "root" -}} -{{- if .Values.mongodbConnection -}} -{{- if .Values.mongodbConnection.host -}} -{{- $host = .Values.mongodbConnection.host -}} +{{- $connectionString := printf "mongodb://%s:%s@%s:%d/" $user $pass $host $port -}} +{{- if .Values.mongodbConnection.standardConnectionStringFormat -}} +{{- $connectionString = .Values.mongodbConnection.standardConnectionStringFormat -}} {{- end -}} -{{- if .Values.mongodbConnection.port -}} -{{- $port = .Values.mongodbConnection.port -}} +{{- if .Values.mongodbConnection.dnsSeedListConnectionFormat -}} +{{- $connectionString = .Values.mongodbConnection.dnsSeedListConnectionFormat -}} {{- end -}} -{{- if .Values.mongodbConnection.username -}} -{{- $user = .Values.mongodbConnection.username -}} -{{- end -}} -{{- if .Values.mongodbConnection.password -}} -{{- $pass = .Values.mongodbConnection.password -}} -{{- end -}} -{{- end -}} -{{- printf "mongodb://%s:%s@%s:%d/" $user $pass $host $port -}} +{{- printf "%s" $connectionString -}} {{- end -}} diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index 0425065d22..13df7b966a 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -43,19 +43,18 @@ mongodb: service: annotations: {} - -# Recommended to replace with Mongo Cloud URI as the DB instance in the cluster does not have persistence yet +# By default the backend will be connected to a Mongo instance in the cluster. +# However, it is recommended to add a Mongo Cloud connection string as the DB instance in the cluster does not have persistence yet. +# Learn about connection string type here https://www.mongodb.com/docs/manual/reference/connection-string/ mongodbConnection: {} - # host: mymongodb.com # defaults to the internal mongo service - # port: 27017 - # username: root - # password: root +# standardConnectionStringFormat: <> +# dnsSeedListConnectionFormat: <> ingress: enabled: true annotations: kubernetes.io/ingress.class: "nginx" - hostName: example.com + hostName: example.com # replace with your domain frontend: path: / pathType: Prefix @@ -98,7 +97,7 @@ backendEnvironmentVariables: # Mail/SMTP # Required to send emails - SMTP_HOST: MUST_REPLACE + SMTP_HOST: MUST_REPLACE SMTP_NAME: MUST_REPLACE SMTP_USERNAME: MUST_REPLACE SMTP_PASSWORD: MUST_REPLACE From 6ac8e057b07c102efd708c6af08f3ab25ae87060 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 17 Jan 2023 22:38:56 -0800 Subject: [PATCH 10/11] set frontend env to empty {} --- helm-charts/infisical/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-charts/infisical/values.yaml b/helm-charts/infisical/values.yaml index 13df7b966a..7661be0647 100644 --- a/helm-charts/infisical/values.yaml +++ b/helm-charts/infisical/values.yaml @@ -102,4 +102,4 @@ backendEnvironmentVariables: SMTP_USERNAME: MUST_REPLACE SMTP_PASSWORD: MUST_REPLACE -# frontendEnvironmentVariables: +frontendEnvironmentVariables: {} From 15698c50363785f3037e37e7bb62db3cf01e5c1e Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 17 Jan 2023 22:44:34 -0800 Subject: [PATCH 11/11] Increase chart version --- helm-charts/infisical/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-charts/infisical/Chart.yaml b/helm-charts/infisical/Chart.yaml index 3b56dcfc29..e5656d128f 100644 --- a/helm-charts/infisical/Chart.yaml +++ b/helm-charts/infisical/Chart.yaml @@ -7,7 +7,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.6 +version: 0.1.7 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to