Skip to content

Commit

Permalink
first helm try of helmfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmi151 committed Feb 7, 2025
1 parent 5a77dfa commit e473ee1
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 0 deletions.
24 changes: 24 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: maelstro
description: A Helm chart for deploying maelstro-backend and maelstro-frontend

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.0.0

# 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
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.0"
3 changes: 3 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# maelstro helm chart deployement

TODO
5 changes: 5 additions & 0 deletions helm/helmfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
releases:
- name: maelstro
chart: ./
values:
- values.yaml
26 changes: 26 additions & 0 deletions helm/templates/_bootstrap-maelstro-configuration.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- define "maelstro.bootstrap_maelstro_configuration" -}}
- name: bootstrap-maelstro-configuration
image: bitnami/git
command:
- /bin/sh
- -c
- {{- if .Values.datadir.git.ssh_secret }}
mkdir -p /root/.ssh ;
cp /ssh-secret/ssh-privatekey /root/.ssh/id_rsa ;
chmod 0600 /root/.ssh/id_rsa ;
{{- end }}
rm -Rf /etc/georchestra ;
git clone --depth 1 --single-branch {{ .Values.datadir.git.url }} -b {{ .Values.datadir.git.ref }} /etc/georchestra ;
{{- if .Values.datadir.git.ssh_secret }}
env:
- name: GIT_SSH_COMMAND
value: ssh -o "IdentitiesOnly=yes" -o "StrictHostKeyChecking no"
{{- end }}
volumeMounts:
- mountPath: /etc/georchestra
name: maelstro-configuration
{{- if .Values.datadir.git.ssh_secret }}
- mountPath: /ssh-secret
name: ssh-secret
{{- end }}
{{- end -}}
62 changes: 62 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "helm-maelstro.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- 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 "helm-maelstro.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 }}

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "helm-maelstro.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "helm-maelstro.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
81 changes: 81 additions & 0 deletions helm/templates/maelstro-backend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "helm-maelstro.fullname" . }}-maelstro-backend-deployment
labels:
{{- include "helm-maelstro.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.maelstro_backend.replicaCount }}
selector:
matchLabels:
{{- include "helm-maelstro.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.maelstro_backend.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "helm-maelstro.selectorLabels" . | nindent 8 }}
org.geonetwork.service/name: {{ include "helm-maelstro.fullname" . }}-maelstro-deployment
spec:
{{- if .Values.datadir.git.url }}
initContainers:
{{- include "maelstro.bootstrap_maelstro_configuration" $ | nindent 6 }}
{{- end }}
{{- with .Values.maelstro_backend.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.maelstro_backend.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.maelstro_backend.securityContext | nindent 12 }}
image: "{{ .Values.maelstro_backend.image.repository }}:{{ .Values.maelstro_backend.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.maelstro_backend.image.pullPolicy }}
ports:
- name: http
containerPort: 8000
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: 8000
readinessProbe:
httpGet:
path: /health
port: 8000
resources:
{{- toYaml .Values.maelstro_backend.resources | nindent 12 }}
env:
- name: MAELSTRO_CONFIG
value: "/etc/georchestra/maelstro/config.yaml"
{{- with .Values.maelstro_backend.extra_environment }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: georchestra-datadir
mountPath: /etc/georchestra
volumes:
- name: georchestra-datadir
emptyDir: {}
{{- if .Values.datadir.git.ssh_secret }}
- name: ssh-secret
secret:
secretName: {{ .Values.datadir.git.ssh_secret }}
defaultMode: 0400
{{- end }}
{{- with .Values.maelstro_backend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.maelstro_backend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.maelstro_backend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
15 changes: 15 additions & 0 deletions helm/templates/maelstro-backend-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "helm-maelstro.fullname" . }}-maelstro_backend-svc
labels:
{{- include "helm-maelstro.labels" . | nindent 4 }}
spec:
type: {{ .Values.maelstro_backend.service.type }}
ports:
- port: {{ .Values.maelstro_backend.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
org.maelstro.service/name: {{ include "helm-maelstro.fullname" . }}-maelstro-backend-deployment
81 changes: 81 additions & 0 deletions helm/templates/maelstro-frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "helm-maelstro.fullname" . }}-maelstro-frontend-deployment
labels:
{{- include "helm-maelstro.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.maelstro_frontend.replicaCount }}
selector:
matchLabels:
{{- include "helm-maelstro.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.maelstro_frontend.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "helm-maelstro.selectorLabels" . | nindent 8 }}
org.geonetwork.service/name: {{ include "helm-maelstro.fullname" . }}-maelstro-deployment
spec:
{{- if .Values.datadir.git.url }}
initContainers:
{{- include "maelstro.bootstrap_maelstro_configuration" $ | nindent 6 }}
{{- end }}
{{- with .Values.maelstro_frontend.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.maelstro_frontend.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.maelstro_frontend.securityContext | nindent 12 }}
image: "{{ .Values.maelstro_frontend.image.repository }}:{{ .Values.maelstro_frontend.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.maelstro_frontend.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /maelstro/
port: 8080
readinessProbe:
httpGet:
path: /maelstro/
port: 8080
resources:
{{- toYaml .Values.maelstro_frontend.resources | nindent 12 }}
env:
- name: CUSTOM_SCRIPTS_DIRECTORY
value: "/etc/georchestra/maelstro/scripts"
{{- with .Values.maelstro_frontend.extra_environment }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: georchestra-datadir
mountPath: /etc/georchestra
volumes:
- name: georchestra-datadir
emptyDir: {}
{{- if .Values.datadir.git.ssh_secret }}
- name: ssh-secret
secret:
secretName: {{ .Values.datadir.git.ssh_secret }}
defaultMode: 0400
{{- end }}
{{- with .Values.maelstro_frontend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.maelstro_frontend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.maelstro_frontend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
15 changes: 15 additions & 0 deletions helm/templates/maelstro-frontend-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "helm-maelstro.fullname" . }}-maelstro_frontend-svc
labels:
{{- include "helm-maelstro.labels" . | nindent 4 }}
spec:
type: {{ .Values.maelstro_frontend.service.type }}
ports:
- port: {{ .Values.maelstro_frontend.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
org.maelstro.service/name: {{ include "helm-maelstro.fullname" . }}-maelstro-frontend-deployment
46 changes: 46 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
maelstro_frontend:
enabled: true
replicaCount: 1
image:
repository: test
tolerations: []
affinity: {}
extra_environment: []
service:
type: ClusterIP
port: 8080
annotations: {}
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
maelstro_backend:
enabled: true
replicaCount: 1
image:
repository: test
tolerations: []
affinity: {}
extra_environment: []
service:
type: ClusterIP
port: 8000
annotations: {}
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

datadir:
volume:
- name: georchestra-datadir
emptyDir: {}
git:
url: https://github.com/georchestra/datadir.git
ref: docker-master

0 comments on commit e473ee1

Please sign in to comment.