Skip to content

Commit

Permalink
Helm: don't use subcharts anymore (#617)
Browse files Browse the repository at this point in the history
* refactor: convert subcharts to "normal" files

* ci: update buildChart script
  • Loading branch information
tnotheis authored Apr 24, 2024
1 parent a2ef47c commit e357e67
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 233 deletions.
5 changes: 1 addition & 4 deletions .ci/helm/buildChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ const version = getRequiredEnvVar("VERSION");

await $`helm dependency update helm`;

// replace <<app_version>> with the value of `version` in all Chart.yaml files in helm folder
await $`find helm -name Chart.yaml -exec sed -i -e 's/__app_version__/${version}/g' {} +`;

await $`helm package --version ${version} helm`;
await $`helm package --version ${version} --app-version ${version} helm`;
14 changes: 0 additions & 14 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ type: application
# version is set by the .ci/helm/pushChart.sh script
version: 0.0.0

dependencies:
- name: admincli
version: "*"
repository: file://charts/admincli
- name: adminui
version: "*"
repository: file://charts/adminui
- name: consumerapi
version: "*"
repository: file://charts/consumerapi
- name: eventhandler
version: "*"
repository: file://charts/eventhandler

icon: https://raw.githubusercontent.com/nmshd/nmshd.github.io/main/assets/images/Logo.svg
home: https://enmeshed.eu
sources:
Expand Down
9 changes: 0 additions & 9 deletions helm/charts/admincli/Chart.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions helm/charts/adminui/Chart.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions helm/charts/adminui/templates/hpa.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions helm/charts/consumerapi/Chart.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions helm/charts/consumerapi/templates/backendconfig.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions helm/charts/consumerapi/templates/hpa.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions helm/charts/eventhandler/Chart.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,49 @@ spec:
app: {{ include "global.name" . }}
template:
metadata:
{{- with .Values.podAnnotations }}
{{- with .Values.admincli.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: {{ include "global.name" . }}
spec:
{{- with .Values.podSecurityContext }}
{{- with .Values.admincli.podSecurityContext }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .Values.admincli.podSecurityContext | nindent 8 }}
{{- end }}
{{- with .Values.image.imagePullSecrets }}
{{- with .Values.admincli.image.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ include "global.name" . }}
{{- with .Values.securityContext }}
{{- with .Values.admincli.securityContext }}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
{{- toYaml .Values.admincli.securityContext | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
image: "{{ .Values.image.repository }}:{{- default .Chart.AppVersion .Values.image.tagOverride }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- toYaml .Values.admincli.resources | nindent 12 }}
image: "{{ .Values.admincli.image.repository }}:{{- default .Chart.AppVersion .Values.admincli.image.tagOverride }}"
imagePullPolicy: {{ .Values.admincli.image.pullPolicy }}
env:
- name: Database__Provider
value: {{ .Values.global.configuration.modules.devices.infrastructure.sqlDatabase.provider }}
{{- with .Values.env }}
{{- with .Values.admincli.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
tty: true
command:
- /bin/bash
{{- with .Values.nodeSelector }}
{{- with .Values.admincli.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with .Values.admincli.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with .Values.admincli.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ metadata:
{{- include "global.labels" . | nindent 4 }}
app: {{ include "global.name" . }}
spec:
replicas: {{ .Values.replicas }}
replicas: {{ .Values.adminui.replicas }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: {{ .Values.maxSurge }}
maxUnavailable: {{ .Values.maxUnavailable }}
maxSurge: {{ .Values.adminui.maxSurge }}
maxUnavailable: {{ .Values.adminui.maxUnavailable }}
selector:
matchLabels:
app: {{ include "global.name" . }}
template:
metadata:
annotations:
checksum/config: {{ .Values.global.configuration | toString | sha256sum }}
{{- with .Values.podAnnotations }}
{{- with .Values.adminui.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
Expand All @@ -29,15 +29,15 @@ spec:
{{- with .Values.global.serviceAccount.name}}
serviceAccountName: {{ . }}
{{- end }}
{{- with .Values.podSecurityContext }}
{{- with .Values.adminui.podSecurityContext }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .Values.adminui.podSecurityContext | nindent 8 }}
{{- end }}
{{- with .Values.image.imagePullSecrets }}
{{- with .Values.adminui.image.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- with .Values.adminui.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -47,18 +47,34 @@ spec:
name: configuration
containers:
- name: {{ include "global.name" . }}
{{- with .Values.securityContext }}
{{- with .Values.adminui.securityContext }}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
{{- toYaml .Values.adminui.securityContext | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
image: "{{ .Values.image.repository }}:{{- default .Chart.AppVersion .Values.image.tagOverride }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- toYaml .Values.adminui.resources | nindent 12 }}
image: "{{ .Values.adminui.image.repository }}:{{- default .Chart.AppVersion .Values.adminui.image.tagOverride }}"
imagePullPolicy: {{ .Values.adminui.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: {{ .Values.adminui.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminui.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminui.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.adminui.livenessProbe.failureThreshold }}
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: {{ .Values.adminui.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminui.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminui.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.adminui.readinessProbe.failureThreshold }}
volumeMounts:
- name: settings-override
mountPath: /app/appsettings.override.json
Expand All @@ -78,34 +94,18 @@ spec:
name: rabbitmq-password
key: "VALUE"
{{- end }}
{{- with .Values.env }}
{{- with .Values.adminui.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- with .Values.nodeSelector }}
{{- with .Values.adminui.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with .Values.adminui.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with .Values.adminui.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions helm/templates/adminui/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.adminui.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "global.name" . }}
labels:
{{- include "global.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "global.name" . }}
minReplicas: {{ .Values.adminui.autoscaling.minReplicas }}
maxReplicas: {{ .Values.adminui.autoscaling.maxReplicas }}
metrics:
{{- if .Values.adminui.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.adminui.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.adminui.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.adminui.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
cloud.google.com/backend-config: '{"default": "{{ include "global.name" . }}"}'
{{- end }}
spec:
type: {{ .Values.service.type }}
type: {{ .Values.adminui.service.type }}
ports:
- port: 8080
targetPort: 8080
Expand Down
17 changes: 17 additions & 0 deletions helm/templates/consumerapi/templates/backendconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if eq .Values.global.provider "GoogleCloud" }}
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
labels:
{{- include "global.labels" . | nindent 4 }}
name: {{ include "global.name" . }}
spec:
healthCheck:
checkIntervalSec: {{ .Values.consumerapi.backendConfig.healthCheck.checkIntervalSec }}
timeoutSec: {{ .Values.consumerapi.backendConfig.healthCheck.timeoutSec }}
healthyThreshold: {{ .Values.consumerapi.backendConfig.healthCheck.healthyThreshold }}
unhealthyThreshold: {{ .Values.consumerapi.backendConfig.healthCheck.unhealthyThreshold }}
type: HTTP
requestPath: /health
port: 8080
{{- end }}
Loading

0 comments on commit e357e67

Please sign in to comment.