From a30e15a0d7389b03fc671ee36a4e3c58e3f10deb Mon Sep 17 00:00:00 2001 From: Mathias Maes Date: Fri, 8 Sep 2023 14:27:20 +0200 Subject: [PATCH] [#496] Allow affinity to be configured Signed-off-by: Mathias Maes --- charts/hono/Chart.yaml | 2 +- charts/hono/README.md | 4 ++++ charts/hono/templates/_helpers.tpl | 14 +++++++++++++ .../templates/artemis/artemis-deployment.yaml | 1 + .../dispatch-router-deployment.yaml | 1 + .../example-data-grid/statefulset.yaml | 1 + .../hono-adapter-amqp-deployment.yaml | 1 + .../hono-adapter-coap-deployment.yaml | 1 + .../hono-adapter-http-deployment.yaml | 1 + .../hono-adapter-lora-deployment.yaml | 1 + .../hono-adapter-mqtt-deployment.yaml | 1 + .../hono-service-auth-deployment.yaml | 1 + ...ono-service-command-router-deployment.yaml | 1 + ...no-service-device-registry-deployment.yaml | 1 + ...no-service-device-registry-deployment.yaml | 1 + .../templates/jaeger/jaeger-deployment.yaml | 1 + charts/hono/values.yaml | 21 +++++++++++++++++++ 17 files changed, 53 insertions(+), 1 deletion(-) diff --git a/charts/hono/Chart.yaml b/charts/hono/Chart.yaml index 9fd0150e..67038019 100755 --- a/charts/hono/Chart.yaml +++ b/charts/hono/Chart.yaml @@ -15,7 +15,7 @@ name: hono description: | Eclipse Hono™ provides remote service interfaces for connecting large numbers of IoT devices to a back end and interacting with them in a uniform way regardless of the device communication protocol. -version: 2.5.0 +version: 2.5.1 # Version of Hono being deployed by the chart appVersion: 2.4.0 keywords: diff --git a/charts/hono/README.md b/charts/hono/README.md index 3169d2df..e5e90278 100644 --- a/charts/hono/README.md +++ b/charts/hono/README.md @@ -102,6 +102,10 @@ helm uninstall eclipse-hono -n hono The command removes all the Kubernetes components associated with the chart and deletes the release. ## Release Notes + +### 2.5.1 + +* Allow configuring pod affinities. ### 2.5.0 * Allow customizing the pod/service names irrespective of .Release.Name. diff --git a/charts/hono/templates/_helpers.tpl b/charts/hono/templates/_helpers.tpl index dad02139..3d1d39ad 100644 --- a/charts/hono/templates/_helpers.tpl +++ b/charts/hono/templates/_helpers.tpl @@ -178,6 +178,20 @@ The scope passed in is expected to be a dict with keys {{- end }} {{- end }} +{{/* +Add affinity rules for Hono component pods. +The scope passed in is expected to be a dict with keys +- (mandatory) "componentConfig": the component's configuration properties from the values.yaml file +*/}} +{{- define "hono.pod.affinity" -}} +{{- if .componentConfig.pod.affinity }} +{{- with .componentConfig.pod.affinity }} +affinity: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end }} +{{- end }} + {{/* Add annotations for Hono component deployments. The scope passed in is expected to be a dict with keys diff --git a/charts/hono/templates/artemis/artemis-deployment.yaml b/charts/hono/templates/artemis/artemis-deployment.yaml index 11790165..f1f2b536 100644 --- a/charts/hono/templates/artemis/artemis-deployment.yaml +++ b/charts/hono/templates/artemis/artemis-deployment.yaml @@ -86,4 +86,5 @@ spec: {{- include "hono.container.volumeMounts" $args | indent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/dispatch-router/dispatch-router-deployment.yaml b/charts/hono/templates/dispatch-router/dispatch-router-deployment.yaml index 6780c701..8c2d2654 100644 --- a/charts/hono/templates/dispatch-router/dispatch-router-deployment.yaml +++ b/charts/hono/templates/dispatch-router/dispatch-router-deployment.yaml @@ -69,4 +69,5 @@ spec: {{- include "hono.container.volumeMounts" ( dict "name" $args.name "componentConfig" $args.componentConfig ) | indent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/example-data-grid/statefulset.yaml b/charts/hono/templates/example-data-grid/statefulset.yaml index 37757441..5e697027 100644 --- a/charts/hono/templates/example-data-grid/statefulset.yaml +++ b/charts/hono/templates/example-data-grid/statefulset.yaml @@ -75,4 +75,5 @@ spec: - name: conf configMap: name: {{ printf "%s-%s-conf" (include "hono.fullname" .) $args.name }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/hono-adapter-amqp/hono-adapter-amqp-deployment.yaml b/charts/hono/templates/hono-adapter-amqp/hono-adapter-amqp-deployment.yaml index 0a17931a..a7826b31 100644 --- a/charts/hono/templates/hono-adapter-amqp/hono-adapter-amqp-deployment.yaml +++ b/charts/hono/templates/hono-adapter-amqp/hono-adapter-amqp-deployment.yaml @@ -73,4 +73,5 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/hono-adapter-coap/hono-adapter-coap-deployment.yaml b/charts/hono/templates/hono-adapter-coap/hono-adapter-coap-deployment.yaml index affba2e7..50912d04 100644 --- a/charts/hono/templates/hono-adapter-coap/hono-adapter-coap-deployment.yaml +++ b/charts/hono/templates/hono-adapter-coap/hono-adapter-coap-deployment.yaml @@ -73,4 +73,5 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/hono-adapter-http/hono-adapter-http-deployment.yaml b/charts/hono/templates/hono-adapter-http/hono-adapter-http-deployment.yaml index 3085820b..e506a7e0 100644 --- a/charts/hono/templates/hono-adapter-http/hono-adapter-http-deployment.yaml +++ b/charts/hono/templates/hono-adapter-http/hono-adapter-http-deployment.yaml @@ -73,4 +73,5 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/hono-adapter-lora/hono-adapter-lora-deployment.yaml b/charts/hono/templates/hono-adapter-lora/hono-adapter-lora-deployment.yaml index 18904e82..500394de 100644 --- a/charts/hono/templates/hono-adapter-lora/hono-adapter-lora-deployment.yaml +++ b/charts/hono/templates/hono-adapter-lora/hono-adapter-lora-deployment.yaml @@ -73,4 +73,5 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/hono-adapter-mqtt/hono-adapter-mqtt-deployment.yaml b/charts/hono/templates/hono-adapter-mqtt/hono-adapter-mqtt-deployment.yaml index 8e3574c1..fc94cce0 100644 --- a/charts/hono/templates/hono-adapter-mqtt/hono-adapter-mqtt-deployment.yaml +++ b/charts/hono/templates/hono-adapter-mqtt/hono-adapter-mqtt-deployment.yaml @@ -73,4 +73,5 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/hono-service-auth/hono-service-auth-deployment.yaml b/charts/hono/templates/hono-service-auth/hono-service-auth-deployment.yaml index 34be1f47..879f22ae 100644 --- a/charts/hono/templates/hono-service-auth/hono-service-auth-deployment.yaml +++ b/charts/hono/templates/hono-service-auth/hono-service-auth-deployment.yaml @@ -71,3 +71,4 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" $args | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} diff --git a/charts/hono/templates/hono-service-command-router/hono-service-command-router-deployment.yaml b/charts/hono/templates/hono-service-command-router/hono-service-command-router-deployment.yaml index 06f71c10..53d447c1 100644 --- a/charts/hono/templates/hono-service-command-router/hono-service-command-router-deployment.yaml +++ b/charts/hono/templates/hono-service-command-router/hono-service-command-router-deployment.yaml @@ -73,3 +73,4 @@ spec: volumes: {{- include "hono.pod.volumes" $args | indent 6 }} serviceAccountName: {{ printf "%s-%s" ( include "hono.fullname" . ) $args.name | quote }} + {{- include "hono.pod.affinity" $args | nindent 6 }} diff --git a/charts/hono/templates/hono-service-device-registry-jdbc/hono-service-device-registry-deployment.yaml b/charts/hono/templates/hono-service-device-registry-jdbc/hono-service-device-registry-deployment.yaml index 1aac1051..a79f2334 100644 --- a/charts/hono/templates/hono-service-device-registry-jdbc/hono-service-device-registry-deployment.yaml +++ b/charts/hono/templates/hono-service-device-registry-jdbc/hono-service-device-registry-deployment.yaml @@ -79,4 +79,5 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" ( dict "dot" $args.dot "name" $args.name "componentConfig" .Values.deviceRegistryExample ) | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/hono-service-device-registry-mongodb/hono-service-device-registry-deployment.yaml b/charts/hono/templates/hono-service-device-registry-mongodb/hono-service-device-registry-deployment.yaml index 8763dedd..e52ca2f4 100644 --- a/charts/hono/templates/hono-service-device-registry-mongodb/hono-service-device-registry-deployment.yaml +++ b/charts/hono/templates/hono-service-device-registry-mongodb/hono-service-device-registry-deployment.yaml @@ -79,4 +79,5 @@ spec: {{- include "hono.component.healthChecks" $args | nindent 8 }} volumes: {{- include "hono.pod.volumes" ( dict "dot" $args.dot "name" $args.name "componentConfig" .Values.deviceRegistryExample ) | indent 6 }} + {{- include "hono.pod.affinity" $args | nindent 6 }} {{- end }} diff --git a/charts/hono/templates/jaeger/jaeger-deployment.yaml b/charts/hono/templates/jaeger/jaeger-deployment.yaml index d0ab0227..90b6491e 100644 --- a/charts/hono/templates/jaeger/jaeger-deployment.yaml +++ b/charts/hono/templates/jaeger/jaeger-deployment.yaml @@ -36,6 +36,7 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} + {{- include "hono.pod.affinity" $args | nindent 6 }} containers: - name: jaeger image: {{ .Values.jaegerBackendExample.allInOneImage }} diff --git a/charts/hono/values.yaml b/charts/hono/values.yaml index 001b623a..5760a829 100755 --- a/charts/hono/values.yaml +++ b/charts/hono/values.yaml @@ -298,6 +298,7 @@ adapters: pod: labels: {} annotations: {} + affinity: {} # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. @@ -425,6 +426,7 @@ adapters: pod: labels: {} annotations: {} + affinity: {} # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. @@ -550,6 +552,7 @@ adapters: pod: labels: {} annotations: {} + affinity: {} # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. @@ -677,6 +680,7 @@ adapters: pod: labels: {} annotations: {} + affinity: {} # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. @@ -803,6 +807,7 @@ adapters: pod: labels: {} annotations: {} + affinity: {} # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. @@ -926,6 +931,7 @@ authServer: pod: labels: {} annotations: {} + affinity: {} # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. @@ -1188,6 +1194,7 @@ deviceRegistryExample: pod: labels: {} annotations: {} + affinity: {} # The configMap to get additional environment variables from for this device registry. envConfigMap: @@ -1271,6 +1278,7 @@ deviceRegistryExample: pod: labels: {} annotations: {} + affinity: {} # jdbcBasedDeviceRegistry contains configuration properties specific to the # jdbc based device registry. @@ -1331,6 +1339,7 @@ deviceRegistryExample: pod: labels: {} annotations: {} + affinity: {} registry: jdbc: @@ -1484,6 +1493,7 @@ commandRouterService: pod: labels: {} annotations: {} + affinity: {} # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. @@ -1846,6 +1856,9 @@ amqpMessagingNetworkExample: periodSeconds: 5 initialDelaySeconds: 20 + pod: + affinity: {} + svc: annotations: {} loadBalancerIP: @@ -1942,6 +1955,9 @@ amqpMessagingNetworkExample: cpu: "1" memory: "600Mi" + pod: + affinity: {} + # extraVolumes contains additional kubernetes Volume definitions representing volumes # that can mounted into the container's file system. # The syntax is defined in https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#volume-v1-core @@ -2012,6 +2028,10 @@ dataGridExample: limits: cpu: "1" memory: "200Mi" + + pod: + affinity: {} + # authUsername contains the name of the user that is authorized to connect to the example data grid. authUsername: "hono" # authPassword contains the secret of the user that is authorized to connect to the example data grid @@ -2062,6 +2082,7 @@ jaegerBackendExample: pod: labels: {} annotations: {} + affinity: {} # env contains environment variables to set for the Jaeger all-in-one container. # The default variables configure the container to keep up to 100000 traces in memory.