Skip to content

Commit

Permalink
feat!: Upgrade Helm to Mender Server v4.0
Browse files Browse the repository at this point in the history
BREAKING CHANGE: See CHANGELOG.md
Signed-off-by: Alf-Rune Siqveland <[email protected]>
  • Loading branch information
alfrunes committed Sep 16, 2024
1 parent bced4ee commit 1f0449c
Show file tree
Hide file tree
Showing 12 changed files with 500 additions and 356 deletions.
40 changes: 40 additions & 0 deletions mender/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Mender Helm chart

## Version 6.0.0
BREAKING CHANGES:
* New image defaults:
* All overrides in default values have been removed
* Registry default changed:
- `registry.mender.io` if `mender.enterprise`
- `docker.io` otherwise
* Repository default changed:
- `mender-server-enterprise` if `mender.enterprise`
- `mendersoftware` otherwise.
* Default tag updated to follow AppVersion in Chart.yaml
* `username`/`password` is removed to discourage bad security practices
* Use `imagePullSecrets` instead
* Rename options:
* `global.image` -> `default.image`
* `global.image.imagePullPolicy` -> `default.image.pullPolicy`
* `global.mongodb` -> `mender.mongodb`
* `global.nats` -> `mender.nats`
* `global.redis` -> `mender.redis`
* `global.storage` -> `mender.storage.type`
* `global.s3` -> `mender.storage.s3`
* `global.azure` -> `mender.storage.azure`
* `global.url` -> `mender.url`
* Removed options:
- `global.image.username`
- `global.image.password`
- `global.auditlogs`: Replaced by `auditlogs.enabled`
- `global.hosted`
- `global.s3.AWS_TAG_ARTIFACT`
- `global.redis.username`: Replaced by URL (connection string)
- `global.redis.password`: Replaced by URL (connection string)
- `test.enabled`
* MongoDB URL configuration
* Simplified values interface
* Added `mender.mongodb.existingSecretKey` to select an alternative key inside the secret for the connection string value.
* When using mongodb as a dependency, the connection string must be specified.
* NATS URL configuration
* Same logic as for MongoDB URL
* `automigrate` options are disabled by default

## Version 5.10.1
* Fix invalid regexp in default storage proxy rule.

Expand Down
2 changes: 1 addition & 1 deletion mender/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: "3.7.7"
appVersion: "v4.0.0"
description: Mender is a robust and secure way to update all your software and deploy your IoT devices at scale with support for customization
name: mender
version: 5.10.1
Expand Down
73 changes: 73 additions & 0 deletions mender/templates/_container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{- define "mender.container.resources" -}}
{{- if .override.resources }}
{{- .override.resources | toYaml }}
{{- else if .dot.Values.default.resources }}
{{- .dot.Values.default.resources | toYaml }}
{{- end }}
{{- end -}}

{{- define "mender.container.securityContext" -}}
{{- if .override.containerSecurityContext }}
{{- /* NOTE: respect falsy override.containerSecurityContext.enabled */ -}}
{{- if .override.containerSecurityContext.enabled }}
{{- omit .override.containerSecurityContext "enabled" | toYaml }}
{{- else }}
{{- printf "{}" }}
{{- end }}
{{- else if and .dot.Values.default.containerSecurityContext
.dot.Values.default.containerSecurityContext.enabled }}
{{- omit .dot.Values.default.containerSecurityContext "enabled" | toYaml }}
{{- else }}
{{- printf "{}" }}
{{- end }}
{{- end -}}

{{- /* Synopsis
{{ include "mender.container" (dict
"dot" .
"component" "<serviceName>"
"override" .Values.<serviceName>
"readinessPath": "optional|/api/internal/v1/.component/health"
"livenessPath": "optional|/api/internal/v1/.component/alive")
}}
Bolierplate Mender service ContainerSpec
*/ -}}
{{- define "mender.container" -}}
image: {{ include "mender.image" . }}
imagePullPolicy: {{ include "mender.imagePullPolicy" . }}
{{- if .args }}
args: {{ splitList " " .args | toYaml | nindent 2 }}
{{- else if and .override.automigrate }}
args: ["server", "--automigrate"]
{{- else }}
args: ["server"]
{{- end }}
{{- if (not .migration) }}
# Readiness/liveness probes
readinessProbe:
httpGet:
path: {{ coalesce .readinessPath (printf "/api/internal/v1/%s/health" .component) }}
port: 8080
{{- coalesce .override.readinessProbe .dot.Values.default.readinessProbe |
toYaml |
nindent 2 }}
livenessProbe:
httpGet:
path: {{ coalesce .livenessPath (printf "/api/internal/v1/%s/alive" .component) }}
port: 8080
{{- coalesce .override.livenessProbe .dot.Values.default.livenessProbe |
toYaml |
nindent 2 }}
startupProbe:
httpGet:
path: {{ coalesce .livenessPath (printf "/api/internal/v1/%s/alive" .component) }}
port: 8080
{{- coalesce .override.startupProbe .dot.Values.default.startupProbe |
toYaml |
nindent 2 }}
{{- end }}
{{- with include "mender.container.resources" . }}
resources: {{- nindent 2 . }}
{{- end }}
securityContext: {{ include "mender.container.securityContext" . }}
{{- end -}}
93 changes: 92 additions & 1 deletion mender/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Redis connection string
MongoDB URI
*/}}
{{- define "mongodb_uri" }}
{{- if and .Values.mongodb.enabled ( not .Values.global.mongodb.URL ) }}
{{- if and .Values.mongodb.enabled }}
{{- if and (eq .Values.mongodb.architecture "replicaset") .Values.mongodb.externalAccess.enabled (eq .Values.mongodb.externalAccess.service.type "ClusterIP") }}
{{- if and .Values.mongodb.auth.enabled .Values.mongodb.auth.rootPassword }}
{{- printf "mongodb://root:%s@%s-0" .Values.mongodb.auth.rootPassword ( include "mongodb.fullname" .Subcharts.mongodb ) | b64enc | quote -}}
Expand All @@ -113,6 +113,28 @@ MongoDB URI
{{- end }}
{{- end }}

{{- define "mender.mongoUrl" -}}
{{- if .Values.mender.mongodb.existingSecret -}}
valueFrom:
secretKeyRef:
name: {{ .Values.mender.mongodb.existingSecret }}
key: "MONGO_URL"
{{- else -}}
value: {{ quote .Values.mender.mongodb.URL }}
{{- end -}}
{{- end -}}

{{- define "mender.natsUrl" -}}
{{- if .Values.mender.nats.existingSecret -}}
valueFrom:
secretKeyRef:
name: {{ .Values.mender.nats.existingSecret }}
key: "NATS_URL"
{{- else -}}
value: {{ quote .Values.mender.nats.URL }}
{{- end -}}
{{- end -}}

{{/*
nats_uri
*/}}
Expand Down Expand Up @@ -233,6 +255,75 @@ spec:
{{- printf "%s-%s" ( include "mender.fullname" .dot ) .component }}
{{- end }}

{{/* Helper for "mender.image" */}}
{{- define "mender.image.registry" }}
{{- if and .override.image .override.image.registry }}
{{- .override.image.registry -}}
{{- else if and .dot.Values.default.image .dot.Values.default.image.registry}}
{{- .dot.Values.default.image.registry -}}
{{- else if .dot.Values.mender.enterprise }}
{{- "registry.mender.io" -}}
{{- else }}
{{- "docker.io" -}}
{{- end }}
{{- end }}

{{/* Helper for "mender.image" */}}
{{- define "mender.image.repository" }}
{{- if and .override.image .override.image.repository }}
{{- .override.image.repository -}}
{{- else if and .dot.Values.default.image .dot.Values.default.image.repository}}
{{- .dot.Values.default.image.repository -}}
{{- else if .dot.Values.mender.enterprise }}
{{- "mender-server-enterprise" -}}
{{- else }}
{{- "mendersoftware" -}}
{{- end }}
{{- end }}

{{/* Helper for "mender.image" */}}
{{- define "mender.image.tag" }}
{{- if and .override.image .override.image.tag }}
{{- .override.image.tag -}}
{{- else if and .dot.Values.default.image .dot.Values.default.image.tag}}
{{- .dot.Values.default.image.tag -}}
{{- else }}
{{- .dot.Chart.AppVersion -}}
{{- end }}
{{- end }}

{{/*
Synopsis:
image: {{ include "mender.image" (dict
"dot" .
"component" "<service>"
"override" .Values.<service> }}
*/}}
{{- define "mender.image" }}
{{- printf "%s/%s/%s:%s"
(include "mender.image.registry" .)
(include "mender.image.repository" .)
.component
(include "mender.image.tag" .) }}
{{- end }}

{{/*
Synopsis:
imagePullPolicy: {{ include "mender.imagePullPolicy" (dict
"dot" .
"component" "<service>"
"override" .Values.<service> }}
*/}}
{{- define "mender.imagePullPolicy" }}
{{- if and .override.image .override.image.pullPolicy }}
{{ .override.image.pullPolicy }}
{{- else if and .dot.Values.default.image .dot.Values.default.image.pullPolicy }}
{{- .dot.Values.default.image.pullPolicy }}
{{- else }}
{{- "IfNotPresent" }}
{{- end }}
{{- end }}

{{- define "mender.resources" -}}
{{- $resources := dict }}
{{- range . }}{{- if . }}
Expand Down
46 changes: 46 additions & 0 deletions mender/templates/_podspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- define "mender.podSecurityContext" -}}
{{- if .override.containerSecurityContext }}
{{- /* NOTE: respect falsy override.containerSecurityContext.enabled */ -}}
{{- if .override.containerSecurityContext.enabled }}
{{- omit .override.containerSecurityContext "enabled" | toYaml }}
{{- else }}
{{- printf "{}" }}
{{- end }}
{{- else if and .dot.Values.default.containerSecurityContext
.dot.Values.default.containerSecurityContext.enabled }}
{{- omit .dot.Values.default.containerSecurityContext "enabled" | toYaml }}
{{- else }}
{{- printf "{}" }}
{{- end }}
{{- end -}}

{{- /* Synopsis:
{{ include "mender.podSpec" (dict
"dot" .
"component" "<serviceName>"
"override" .Values.<serviceName>
}}
Generates shared boilerplate PodSpec
*/ -}}
{{- define "mender.podSpec" -}}
serviceAccountName: {{ include "mender.serviceAccountName" . }}
{{- with (coalesce .override.affinity .dot.Values.default.affinity) }}
affinity: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with (coalesce .override.tolerations .dot.Values.default.tolerations) }}
tolerations: {{ toYaml . | nindent 4 }}
{{- end }}
securityContext: {{ include "mender.podSecurityContext" . | nindent 2}}
{{- with .restartPolicy }}
restartPolicy: {{ quote . }}
{{- end }}
{{- with coalesce .override.imagePullSecrets .dot.Values.default.imagePullSecrets }}
imagePullSecrets: {{- toYaml . | nindent 2 }}
{{- end }}
{{- with (coalesce .override.priorityClassName .dot.Values.default.PriorityClassName) }}
priorityClassName: {{ quote . }}
{{- end }}
{{- with (coalesce .override.nodeSelector .dot.Values.default.nodeSelector) }}
nodeSelector: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
Loading

0 comments on commit 1f0449c

Please sign in to comment.