Skip to content

Commit

Permalink
[HELM] Updated HELM charts
Browse files Browse the repository at this point in the history
* common Labels Annotations
* add Version compatibility
* add conditional to annotations
* add conditional to rewriteroule
* add same schema to mqtt ingress
* add ingressClassName
* add liveness and readyness probes
* Updated helm version used for building

---------

Co-authored-by: chris8205 <info@slater.be>
Co-authored-by: Christian Hamel (regio iT) <Christian.Hamel@regioit.de>
  • Loading branch information
3 people authored Sep 24, 2024
1 parent eadd2b6 commit 792a7da
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/helm-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Set up Helm
env:
HELM_VERSION: "v3.4.2"
HELM_VERSION: "v3.16.1"
run: |
wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz -O /tmp/helm.tar.gz
tar xzf /tmp/helm.tar.gz -C /tmp --strip-components=1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/helm-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Set up Helm
env:
HELM_VERSION: "v3.4.2"
HELM_VERSION: "v3.16.1"
run: |
wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz -O /tmp/helm.tar.gz
tar xzf /tmp/helm.tar.gz -C /tmp --strip-components=1
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ FROST-Server.HTTP/keycloak.json
FROST-Server.MQTT/FrostMqtt.properties
logs
Tools/ModelExtractor/examples
*.tgz
.vscode/

2 changes: 2 additions & 0 deletions helm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ git config --global user.name "Workflow Build"
if [[ "${GITHUB_BASE_REF}" == "" ]] && [[ "${GITHUB_REF}" == "refs/tags"* ]]; then
echo "Building release helm chart"
git clone --quiet --branch master https://github.com/FraunhoferIOSB/helm-charts.git
/tmp/helm dependency update ./helm/frost-server
/tmp/helm lint ./helm/frost-server
/tmp/helm package ./helm/frost-server -d ./helm-charts
/tmp/helm repo index --url https://fraunhoferiosb.github.io/helm-charts/ ./helm-charts
fi

echo "Building snapshot helm chart"
git clone --quiet --branch master https://github.com/FraunhoferIOSB/helm-charts-snapshot.git
/tmp/helm dependency update ./helm/frost-server
/tmp/helm lint ./helm/frost-server
/tmp/helm package ./helm/frost-server -d ./helm-charts-snapshot
/tmp/helm repo index --url https://fraunhoferiosb.github.io/helm-charts-snapshot/ ./helm-charts-snapshot
Expand Down
2 changes: 2 additions & 0 deletions helm/frost-server/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
.project
.idea/
*.tmproj


6 changes: 5 additions & 1 deletion helm/frost-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
apiVersion: v2
name: frost-server
version: 2.5.0
appVersion: 2.5.0
Expand All @@ -21,4 +21,8 @@ maintainers:
email: philipp.hertweck@iosb.fraunhofer.de
- name: Hylke van der Schaaf
email: hylke.vanderschaaf@iosb.fraunhofer.de
dependencies:
- name: common
version: 2.22.0
repository: oci://registry-1.docker.io/bitnamicharts

6 changes: 3 additions & 3 deletions helm/frost-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Hereafter the list of available exposed FROST-Server's resources:
FROST-Server's resource | Access URL
--------------------------- | ----------------------------------------------
HTTP - Homepage | {{ include "frost-server.http.serviceRootUrl" . }}
HTTP - SensorThings API | {{ include "frost-server.http.serviceRootUrl" . }}/{{ include "frost-server.http.apiVersion" . }}
HTTP - SensorThings API | {{ include "frost-server.http.serviceRootUrl" . }}{{ include "frost-server.http.apiVersion" . }}
{{- if .Values.frost.mqtt.enabled }}
MQTT - TCP | {{ .Values.frost.http.serviceHost }}:{{ .Values.frost.mqtt.ports.mqtt.nodePort }}
MQTT - Websocket | {{ .Values.frost.http.serviceHost }}:{{ .Values.frost.mqtt.ports.websocket.nodePort }}
MQTT - TCP | {{ include "frost-server.mqtt.serviceEndpoint" . }}
MQTT - Websocket | {{ include "frost-server.mqtt.serviceRootUrl" . }}
{{- end }}

For more information about FROST-Server, please visit https://github.com/FraunhoferIOSB/FROST-Server
108 changes: 102 additions & 6 deletions helm/frost-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,116 @@ Get the HTTP service API version.
v1.0
{{- end -}}

{{/*
Get the HTTP serviceHost.
*/}}
{{- define "frost-server.http.serviceHost" -}}
{{ if not .Values.frost.http.serviceHost | empty }}{{ .Values.frost.http.serviceHost }}{{else}}"frost-server"{{end}}
{{- end -}}

{{/*
Get the HTTP service root URL.
*/}}
{{- define "frost-server.http.serviceRootUrl" -}}
{{ .Values.frost.http.serviceProtocol }}://{{ .Values.frost.http.serviceHost }}{{ if .Values.frost.http.servicePort }}:{{ .Values.frost.http.servicePort }}{{ else if not .Values.frost.http.ingress.enabled }}:{{ .Values.frost.http.ports.http.nodePort }}{{ end }}{{ if .Values.frost.http.urlSubPath }}/{{ .Values.frost.http.urlSubPath }}{{ end }}
{{ .Values.frost.http.serviceProtocol }}://{{ .Values.frost.http.serviceHost }}{{ if .Values.frost.http.servicePort }}:{{ .Values.frost.http.servicePort }}{{ else if not .Values.frost.http.ingress.enabled }}:{{ .Values.frost.http.ports.http.nodePort }}{{ end }}{{ template "frost-server.http.serviceSubPath" . }}
{{- end -}}

{{/*
Get the HTTP service SubPath
*/}}
{{- define "frost-server.http.serviceSubPath" -}}
{{- if not .Values.frost.http.urlSubPath | empty -}}
{{- printf "/%s/" .Values.frost.http.urlSubPath | replace "//" "/" -}}
{{- else -}}
{{- printf "/" -}}
{{- end -}}
{{- end -}}

{{/*
Get the MQTT serviceHost.
*/}}
{{- define "frost-server.mqtt.serviceHost" -}}
{{ if not .Values.frost.mqtt.serviceHost | empty }}{{ .Values.frost.mqtt.serviceHost }}{{else}}{{ .Values.frost.http.serviceHost }}{{end}}
{{- end -}}

{{/*
Get the MQTT service root URL.
*/}}
{{- define "frost-server.mqtt.serviceRootUrl" -}}
{{ .Values.frost.mqtt.serviceProtocol }}://{{ template "frost-server.mqtt.serviceHost" . }}{{ if .Values.frost.mqtt.servicePort }}:{{ .Values.frost.mqtt.servicePort }}{{ else if not .Values.frost.mqtt.ingress.enabled }}:{{ .Values.frost.mqtt.ports.mqtt.nodePort }}{{ end }}{{ if .Values.frost.mqtt.ingress.enabled }}{{ template "frost-server.mqtt.websockPath" . }}{{ end }}
{{- end -}}

{{/*
Get the MQTT Websock-Path.
*/}}
{{- define "frost-server.mqtt.websockPath" -}}
{{- if not .Values.frost.mqtt.urlSubPath | empty -}}
{{- printf "/%s/" .Values.frost.mqtt.urlSubPath | replace "//" "/" -}}
{{- else -}}
{{- printf "/mqtt/" -}}
{{- end -}}
{{- end -}}

{{/*
Get the MQTT TCP service EndPoint
*/}}
{{- define "frost-server.mqtt.serviceEndpoint" -}}
{{- if and .Values.frost.http.serviceHost .Values.frost.mqtt.ports.mqtt.nodePort -}}
{{- printf "%s:%s" .Values.frost.http.serviceHost .Values.frost.mqtt.ports.mqtt.nodePort -}}
{{- else -}}
{{- printf "NOT CONFIGURED -- please set frost.mqtt.ports.mqtt.nodePort in values.yaml" -}}
{{- end -}}
{{- end -}}

{{/*
Get the default agic rewriteAnnotations for ingress.
*/}}
{{- define "frost-server.ingress.rewriteAnnotation" -}}
{{- $myannotations := dict -}}
{{- if eq .scope.ingress.ingressProvider "agic" -}} {{/* Set annotations for ingress of type azure agic */}}
{{- if .scope.ingress.tls.enabled -}}
{{- $_ := set $myannotations "appgw.ingress.kubernetes.io/ssl-redirect" "true" -}}
{{- end -}}
{{- if eq .type "http" -}}
{{- $_ := set $myannotations "appgw.ingress.kubernetes.io/backend-path-prefix" "/FROST-Server/" -}}
{{/* put here default annotations for http-service */}}
{{- else if eq .type "mqtt" -}}
{{/* put here default annotations for mqtt-service */}}
{{- end -}}
{{- else if eq .scope.ingress.ingressProvider "traefik" -}} {{/* Set annotations for ingress of type traefik */}}
{{- if .scope.ingress.tls.enabled -}}
{{- $_ := set $myannotations "traefik.ingress.kubernetes.io/router.tls" "true" -}}
{{- end -}}
{{- if eq .type "http" -}}
{{/* put here default annotations for http-service */}}
{{- else if eq .type "mqtt" -}}
{{/* put here default annotations for mqtt-service */}}
{{- end -}}
{{- else if eq .scope.ingress.ingressProvider "nginx" -}} {{/* Set annotations for ingress of type kubernetes.nginx */}}
{{- if .scope.ingress.tls.enabled -}}
{{- $_ := set $myannotations "nginx.ingress.kubernetes.io/ssl-redirect" "true" -}}
{{- end -}}
{{- if eq .type "http" -}}
{{- $_ := set $myannotations "nginx.ingress.kubernetes.io/rewrite-target" "/FROST-Server/$1" -}}
{{/* put here default annotations for http-service */}}
{{- else if eq .type "mqtt" -}}
{{- $_ := set $myannotations "nginx.mqtt.hamel.test" "true" -}}
{{/* put here default annotations for mqtt-service */}}
{{- end -}}
{{- end -}}
{{- $myannotations | toYaml -}}
{{- end -}}


{{/*
Get the DB secret.
*/}}
{{- define "frost-server.db.secret" -}}
{{- if .Values.frost.db.existingSecret -}}
{{ .Values.frost.db.existingSecret }}
{{- else -}}
{{ include "frost-server.fullName" . }}
{{- end -}}
{{- if .Values.frost.db.existingSecret -}}
{{- .Values.frost.db.existingSecret -}}
{{- else -}}
{{ include "frost-server.fullName" . }}
{{- end -}}
{{- end -}}


16 changes: 16 additions & 0 deletions helm/frost-server/templates/bus-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,20 @@ spec:
ports:
- name: mqtt
containerPort: 1883
livenessProbe:
tcpSocket:
port: mqtt
initialDelaySeconds: 120
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
readinessProbe:
tcpSocket:
port: mqtt
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
{{- end -}}
22 changes: 22 additions & 0 deletions helm/frost-server/templates/db-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,28 @@ spec:
ports:
- name: postgresql
containerPort: 5432
livenessProbe:
exec:
command:
- /bin/sh
- -c
- exec pg_isready -h 127.0.0.1 -p 5432
initialDelaySeconds: 120
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
readinessProbe:
exec:
command:
- /bin/sh
- -c
- exec pg_isready -h 127.0.0.1 -p 5432
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
{{- if or (.Values.frost.db.persistence.enabled) (.Values.frost.db.persistence.hostPath) }}
volumeMounts:
- name: {{ $fullName }}
Expand Down
17 changes: 17 additions & 0 deletions helm/frost-server/templates/http-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ spec:
ports:
- name: tomcat
containerPort: 8080
livenessProbe:
tcpSocket:
port: tomcat
initialDelaySeconds: 120
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
readinessProbe:
httpGet:
path: /FROST-Server/
port: tomcat
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
resources:
{{- toYaml .Values.frost.http.resources | nindent 12 }}
env:
Expand Down
33 changes: 23 additions & 10 deletions helm/frost-server/templates/http-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
{{- if .Values.frost.http.ingress.enabled -}}
{{- $tier := "http" -}}
{{- $fullName := include "frost-server.fullName" (merge (dict "tier" $tier) .) -}}
{{- $defaultRewriteAnnotations := include "frost-server.ingress.rewriteAnnotation" (dict "scope" .Values.frost.http "type" "http") -}}
{{- if and .Values.frost.http.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.frost.http.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.frost.http.ingress.annotations "kubernetes.io/ingress.class" .Values.frost.http.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
annotations:
{{ .Values.frost.http.ingress.rewriteAnnotation}}: {{ .Values.frost.http.ingress.rewriteTarget}}
{{- if .Values.frost.http.ingress.annotations }}
{{- toYaml .Values.frost.http.ingress.annotations | nindent 4 }}
{{ end }}
namespace: {{ .Release.Namespace }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.frost.http.ingress.annotations $defaultRewriteAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ include "frost-server.chart" . }}
app: {{ include "frost-server.name" . }}
component: {{ $tier }}
spec:
{{- if and .Values.frost.http.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.frost.http.ingress.className }}
{{- end }}
{{- if .Values.frost.http.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.frost.http.serviceHost }}
- hosts:
- {{ include "frost-server.http.serviceHost" . }}
{{- if .Values.frost.http.ingress.tls.secretName }}
secretName: {{ .Values.frost.http.ingress.tls.secretName }}
{{- end -}}
{{- end }}
rules:
- host: {{ .Values.frost.http.serviceHost }}
- host: {{ include "frost-server.http.serviceHost" . }}
http:
paths:
- path: {{ .Values.frost.http.ingress.path }}
- path: {{ template "frost-server.http.serviceSubPath" . }}
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
number: 80
number: {{ .Values.frost.http.ports.http.servicePort }}
{{- end -}}
18 changes: 17 additions & 1 deletion helm/frost-server/templates/mqtt-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,26 @@ spec:
containerPort: 1883
- name: websocket
containerPort: 9876
livenessProbe:
tcpSocket:
port: mqtt
initialDelaySeconds: 120
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
readinessProbe:
tcpSocket:
port: mqtt
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
env:
# Internal properties
- name: serviceRootUrl
value: {{ include "frost-server.http.serviceRootUrl" . | quote }}
value: {{ include "frost-server.mqtt.serviceRootUrl" . | quote }}
- name: alwaysOrderbyId
value: "{{ .Values.frost.alwaysOrderbyId }}"
- name: logSensitiveData
Expand Down
Loading

0 comments on commit 792a7da

Please sign in to comment.