Skip to content

Commit

Permalink
feat: ✨ add cloud-pi-native console helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-tobi committed Apr 26, 2024
1 parent 730331a commit 1777f19
Show file tree
Hide file tree
Showing 23 changed files with 1,486 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/dso-console/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/dso-console/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 12.7.3
- name: keycloak
repository: https://charts.bitnami.com/bitnami
version: 19.3.0
digest: sha256:e4c52d75d9aad57182d8876c545a179fd8c34a6bbcb11307473720517d7e22cf
generated: "2024-04-09T02:31:51.291603+02:00"
25 changes: 25 additions & 0 deletions charts/dso-console/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v2
name: cpn-console
description: A Helm chart to deploy Cloud Pi Native Console
type: application
version: 1.0.0
appVersion: 8.1.1
keywords: []
home: https://cloud-pi-native.fr
sources:
- https://github.com/cloud-pi-native/console
dependencies:
- name: postgresql
version: 12.7.3
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: keycloak
version: 19.3.0
repository: https://charts.bitnami.com/bitnami
condition: keycloak.enabled
deprecated: false
annotations: {}
maintainers:
- name: Thibault Colin
email: [email protected]
url: https://this-is-tobi.com
201 changes: 201 additions & 0 deletions charts/dso-console/README.md

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions charts/dso-console/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cpnConsole.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cpnConsole.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "cpnConsole.server.serviceAccountName" -}}
{{- if .Values.server.serviceAccount.create }}
{{- default (include "cpnConsole.name" .) .Values.server.serviceAccount.name }}
{{- else }}
{{- default "cpn-server" .Values.server.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create image pull secret
*/}}
{{- define "cpnConsole.imagePullSecret" }}
{{- with .Values.imageCredentials }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- end }}

{{/*
Create container environment variables from configmap
*/}}
{{- define "cpnConsole.env" -}}
{{ range $key, $val := .env }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}

{{/*
Create container environment variables from secret
*/}}
{{- define "cpnConsole.secret" -}}
{{ range $key, $val := .secrets }}
{{ $key }}: {{ $val | b64enc | quote }}
{{- end }}
{{- end }}

{{/*
Define a file checksum to trigger rollout on configmap of secret change
*/}}
{{- define "checksum" -}}
{{- $ := index . 0 }}
{{- $path := index . 1 }}
{{- $resourceType := include (print $.Template.BasePath $path) $ | fromYaml -}}
{{- if $resourceType -}}
checksum/{{ $resourceType.metadata.name }}: {{ $resourceType.data | toYaml | sha256sum }}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "cpnConsole.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "cpnConsole.client.labels" -}}
helm.sh/chart: {{ include "cpnConsole.chart" . }}
{{ include "cpnConsole.client.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{- define "cpnConsole.server.labels" -}}
helm.sh/chart: {{ include "cpnConsole.chart" . }}
{{ include "cpnConsole.server.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "cpnConsole.client.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cpnConsole.name" . }}-client
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "cpnConsole.server.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cpnConsole.name" . }}-server
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/dso-console/templates/client/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "cpnConsole.fullname" . }}-client
labels: {{- include "cpnConsole.client.labels" . | nindent 4 }}
data:
SERVER_HOST: {{ include "cpnConsole.fullname" . }}-server
SERVER_PORT: {{ .Values.server.service.port | quote }}
KEYCLOAK_PROTOCOL: {{ .Values.global.keycloak.protocol }}
KEYCLOAK_DOMAIN: {{ .Values.global.keycloak.domain }}
KEYCLOAK_REALM: {{ .Values.global.keycloak.realm }}
KEYCLOAK_REDIRECT_URI: {{ .Values.global.keycloak.redirectUri }}
KEYCLOAK_CLIENT_ID: {{ .Values.global.keycloak.clientIds.frontend }}
{{- if .Values.global.env -}}
{{- include "cpnConsole.env" .Values.global | indent 2 }}
{{- end -}}
{{- if .Values.client.env -}}
{{- include "cpnConsole.env" .Values.client | indent 2 }}
{{- end -}}
138 changes: 138 additions & 0 deletions charts/dso-console/templates/client/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cpnConsole.fullname" . }}-client
labels:
{{- include "cpnConsole.client.labels" . | nindent 4 }}
spec:
{{- if not .Values.client.autoscaling.enabled }}
replicas: {{ .Values.client.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "cpnConsole.client.selectorLabels" . | nindent 6 }}
strategy:
type: {{ .Values.client.strategy.type }}
template:
metadata:
annotations:
{{- include "checksum" (list $ "/client/configmap.yaml") | nindent 8 }}
{{- include "checksum" (list $ "/client/secret.yaml") | nindent 8 }}
{{- with .Values.client.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "cpnConsole.client.selectorLabels" . | nindent 8 }}
{{- with .Values.client.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if and .Values.imageCredentials.username .Values.imageCredentials.password }}
imagePullSecrets:
- name: {{ include "cpnConsole.name" . }}-pullsecret
{{- end }}
securityContext:
{{- toYaml .Values.client.podSecurityContext | nindent 8 }}
{{- if .Values.client.initContainers }}
initContainers:
{{- toYaml .Values.client.initContainers | nindent 8 }}
{{- end }}
containers:
- name: client
securityContext:
{{- toYaml .Values.client.container.securityContext | nindent 12 }}
image: "{{ .Values.client.image.repository }}:{{ .Values.client.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.client.image.pullPolicy }}
{{- if .Values.client.container.command }}
command:
{{- range .Values.client.container.command }}
- {{ . | quote }}
{{- end }}
{{- end }}
{{- if .Values.client.container.args }}
args:
{{- range .Values.client.container.args }}
- {{ . | quote }}
{{- end }}
{{- end }}
ports:
- containerPort: {{ .Values.client.container.port }}
protocol: TCP
envFrom:
- configMapRef:
name: {{ include "cpnConsole.fullname" . }}-client
{{- if or .Values.global.secrets .Values.client.secrets }}
- secretRef:
name: {{ include "cpnConsole.fullname" . }}-client
{{- end }}
{{- if .Values.client.startupProbe.enabled }}
startupProbe:
httpGet:
path: {{ .Values.client.healthcheckPath }}
port: {{ .Values.client.container.port }}
initialDelaySeconds: {{ .Values.client.startupProbe.initialDelaySeconds }}
successThreshold: {{ .Values.client.startupProbe.successThreshold }}
failureThreshold: {{ .Values.client.startupProbe.failureThreshold }}
periodSeconds: {{ .Values.client.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.client.startupProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.client.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.client.healthcheckPath }}
port: {{ .Values.client.container.port }}
initialDelaySeconds: {{ .Values.client.readinessProbe.initialDelaySeconds }}
successThreshold: {{ .Values.client.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.client.readinessProbe.failureThreshold }}
periodSeconds: {{ .Values.client.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.client.readinessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.client.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.client.healthcheckPath }}
port: {{ .Values.client.container.port }}
initialDelaySeconds: {{ .Values.client.livenessProbe.initialDelaySeconds }}
successThreshold: {{ .Values.client.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.client.livenessProbe.failureThreshold }}
periodSeconds: {{ .Values.client.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.client.livenessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.client.hostAliases }}
hostAliases:
{{- toYaml .Values.client.hostAliases | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.client.resources | nindent 10 }}
volumeMounts:
{{- range $volumeMount := .Values.client.extraVolumeMounts }}
- name: {{ $volumeMount.name }}
mountPath: {{ $volumeMount.mountPath }}
{{- end }}
{{- if .Values.client.extraContainers }}
{{- toYaml .Values.client.extraContainers | nindent 8 }}
{{- end }}
{{- with .Values.client.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.client.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.client.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- range $volume := .Values.client.extraVolumes }}
- name: {{ $volume.name }}
{{- if eq $volume.type "hostPath" }}
hostPath:
path: {{ $volume.path }}
{{- end }}
{{- if eq $volume.type "configMap" }}
configMap:
name: {{ $volume.name }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/dso-console/templates/client/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.client.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "cpnConsole.fullname" . }}-client
labels:
{{- include "cpnConsole.client.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "cpnConsole.fullname" . }}-client
minReplicas: {{ .Values.client.autoscaling.minReplicas }}
maxReplicas: {{ .Values.client.autoscaling.maxReplicas }}
metrics:
{{- if .Values.client.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.client.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.client.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.client.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/dso-console/templates/client/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if or .Values.global.secrets .Values.client.secrets }}
kind: Secret
apiVersion: v1
metadata:
name: {{ include "cpnConsole.fullname" . }}-client
labels: {{- include "cpnConsole.client.labels" . | nindent 4 }}
data:
{{- if .Values.global.secrets -}}
{{- include "cpnConsole.secret" .Values.global | indent 2 }}
{{- end -}}
{{- if .Values.client.secrets -}}
{{- include "cpnConsole.secret" .Values.client | indent 2 }}
{{- end -}}
{{- end -}}
14 changes: 14 additions & 0 deletions charts/dso-console/templates/client/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "cpnConsole.fullname" . }}-client
labels:
{{- include "cpnConsole.client.labels" . | nindent 4 }}
spec:
type: {{ .Values.client.service.type }}
ports:
- port: {{ .Values.client.service.port }}
targetPort: {{ .Values.client.container.port }}
protocol: TCP
selector:
{{- include "cpnConsole.client.selectorLabels" . | nindent 4 }}
Loading

0 comments on commit 1777f19

Please sign in to comment.