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

Helm updates #183

Merged
merged 11 commits into from Jan 18, 2023
2 changes: 1 addition & 1 deletion helm-charts/infisical/Chart.yaml
Expand Up @@ -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
Expand Down
131 changes: 131 additions & 0 deletions helm-charts/infisical/templates/_helpers.tpl
@@ -0,0 +1,131 @@
{{/*
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 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 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 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 -}}

{{/*
Create the mongodb connection string.
*/}}
{{- define "infisical.mongodb.connectionString" -}}
{{- $host := include "infisical.mongodb.fullname" . -}}
{{- $port := 27017 -}}
{{- $user := "root" -}}
{{- $pass := "root" -}}
{{- $connectionString := printf "mongodb://%s:%s@%s:%d/" $user $pass $host $port -}}
{{- if .Values.mongodbConnection.standardConnectionStringFormat -}}
{{- $connectionString = .Values.mongodbConnection.standardConnectionStringFormat -}}
{{- end -}}
{{- if .Values.mongodbConnection.dnsSeedListConnectionFormat -}}
{{- $connectionString = .Values.mongodbConnection.dnsSeedListConnectionFormat -}}
{{- end -}}
{{- printf "%s" $connectionString -}}
{{- end -}}
28 changes: 20 additions & 8 deletions helm-charts/infisical/templates/backend-deployment.yaml
@@ -1,22 +1,26 @@
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 }}
{{- with .Values.backend.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: backend
image: infisical/backend
- 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
Expand All @@ -26,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." }}
Expand All @@ -38,10 +44,16 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: infisical-backend-service
name: {{ include "infisical.backend.fullname" . }}
labels:
{{- include "infisical.backend.labels" . | nindent 4 }}
{{- with .Values.backend.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
app: backend
{{- include "infisical.backend.matchLabels" . | nindent 8 }}
ports:
- protocol: TCP
port: 4000
Expand Down
30 changes: 22 additions & 8 deletions helm-charts/infisical/templates/frontend-deployment.yaml
@@ -1,22 +1,26 @@
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 }}
{{- with .Values.frontend.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: frontend
image: infisical/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 }}
envFrom:
Expand All @@ -39,11 +43,21 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: infisical-frontend-service
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:
app: frontend
{{- include "infisical.frontend.matchLabels" . | nindent 8 }}
ports:
- protocol: TCP
port: 3000 # service
targetPort: 3000 # container port
{{- if eq .Values.frontend.service.type "NodePort" }}
nodePort: {{ .Values.frontend.service.nodePort }}
{{- end }}
4 changes: 2 additions & 2 deletions helm-charts/infisical/templates/ingress.yaml
Expand Up @@ -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 }}
27 changes: 19 additions & 8 deletions helm-charts/infisical/templates/mongodb-deployment.yaml
@@ -1,22 +1,27 @@
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 }}
{{- with .Values.mongodb.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
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:
Expand All @@ -28,10 +33,16 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: mongodb-service
name: {{ include "infisical.mongodb.fullname" . }}
labels:
{{- include "infisical.mongodb.labels" . | nindent 4 }}
{{- with .Values.mongodb.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
app: mongodb
{{- include "infisical.mongodb.matchLabels" . | nindent 8 }}
ports:
- protocol: TCP
port: 27017
Expand Down