From 02eafe2bb5492f82dfa9ca86b738525c57da472e Mon Sep 17 00:00:00 2001 From: Sergio Rua <58211930+digiserg@users.noreply.github.com> Date: Wed, 14 Jun 2023 09:39:53 +0100 Subject: [PATCH] Adds support for node affinity and node selectors (#81) --- README.md | 2 ++ README.md.tpl | 2 ++ templates/statefulset.yaml | 12 ++++++++++++ values.schema.json | 14 ++++++++++++++ values.schema.json.tpl | 14 ++++++++++++++ values.yaml | 4 ++++ 6 files changed, 48 insertions(+) diff --git a/README.md b/README.md index ff977f4..cdc4555 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ Configure your Infinispan cluster by specifying values in the `deploy.*` section | `deploy.svcLabels` | Adds labels to each service that you create.| `{}` | - | | `deploy.resourceLabels` | Adds labels to all Infinispan resources including pods and services. | `{}` | - | | `deploy.tolerations` | Node taints to tolerate | `[]` | - | +| `deploy.nodeSelector` | Defines the nodeSelector policy used by the cluster's StatefulSet | `{}` | - | +| `deploy.nodeAffinity` | Defines the nodeAffinity policy used by the cluster's StatefulSet | `{}` | - | | `deploy.makeDataDirWritable` | Allows write access to the `data` directory for each Infinispan Server node. | false | Setting the value to `true` creates an initContainer that runs `chmod -R` on the `/opt/infinispan/server/data` directory and changes its permissions. | | `deploy.monitoring.enabled` | Enable or disable `ServiceMonitor` functionality. | false | Users must have `monitoring-edit` role assigned by the admin to deploy the Helm chart with `ServiceMonitor` enabled. | | `deploy.nameOverride` | Specifies a name for all Infinispan cluster resources. | Helm Chart release name | Configure a name for the created resources only if you need it to be different to the Helm Chart release name. | diff --git a/README.md.tpl b/README.md.tpl index f9c282c..330cf32 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -40,6 +40,8 @@ Configure your {brandname} cluster by specifying values in the `deploy.*` sectio | `deploy.svcLabels` | Adds labels to each service that you create.| `{}` | - | | `deploy.resourceLabels` | Adds labels to all {brandname} resources including pods and services. | `{}` | - | | `deploy.tolerations` | Node taints to tolerate | `[]` | - | +| `deploy.nodeSelector` | Defines the nodeSelector policy used by the cluster's StatefulSet | `{}` | - | +| `deploy.nodeAffinity` | Defines the nodeAffinity policy used by the cluster's StatefulSet | `{}` | - | | `deploy.makeDataDirWritable` | Allows write access to the `data` directory for each {brandname} Server node. | false | Setting the value to `true` creates an initContainer that runs `chmod -R` on the `/opt/infinispan/server/data` directory and changes its permissions. | | `deploy.monitoring.enabled` | Enable or disable `ServiceMonitor` functionality. | false | Users must have `monitoring-edit` role assigned by the admin to deploy the Helm chart with `ServiceMonitor` enabled. | | `deploy.nameOverride` | Specifies a name for all {brandname} cluster resources. | Helm Chart release name | Configure a name for the created resources only if you need it to be different to the Helm Chart release name. | diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml index b508438..7e7f941 100644 --- a/templates/statefulset.yaml +++ b/templates/statefulset.yaml @@ -27,6 +27,12 @@ spec: clusterName: {{ include "infinispan-helm-charts.name" . }} {{- include "infinispan-helm-charts.podLabels" . | nindent 8 }} spec: + {{- if .Values.deploy.nodeSelector }} + nodeSelector: + {{- with .Values.deploy.nodeSelector }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: @@ -37,6 +43,12 @@ spec: app: infinispan-pod topologyKey: kubernetes.io/hostname weight: 100 + {{- if .Values.deploy.nodeAffinity }} + nodeAffinity: + {{- with .Values.deploy.nodeAffinity }} + {{- toYaml . | nindent 10 }} + {{- end }} + {{- end }} {{if .Values.deploy.makeDataDirWritable }} initContainers: - name: data-chmod-pv diff --git a/values.schema.json b/values.schema.json index a013a65..27b95a8 100644 --- a/values.schema.json +++ b/values.schema.json @@ -166,6 +166,20 @@ "null" ] }, + "nodeSelector": { + "description": "Defines the nodeSelector policy used by the cluster's StatefulSet", + "type": [ + "object", + "null" + ] + }, + "nodeAffinity": { + "description": "Defines the nodeAffinity policy used by the cluster's StatefulSet", + "type": [ + "object", + "null" + ] + }, "expose": { "description": "Controls network access to Infinispan Server endpoints.", "properties": { diff --git a/values.schema.json.tpl b/values.schema.json.tpl index 90e4f1a..6424f00 100644 --- a/values.schema.json.tpl +++ b/values.schema.json.tpl @@ -166,6 +166,20 @@ "null" ] }, + "nodeSelector": { + "description": "Defines the nodeSelector policy used by the cluster's StatefulSet", + "type": [ + "object", + "null" + ] + }, + "nodeAffinity": { + "description": "Defines the nodeAffinity policy used by the cluster's StatefulSet", + "type": [ + "object", + "null" + ] + }, "expose": { "description": "Controls network access to {brandname} Server endpoints.", "properties": { diff --git a/values.yaml b/values.yaml index f259f15..dbe2e19 100644 --- a/values.yaml +++ b/values.yaml @@ -82,6 +82,10 @@ deploy: tolerations: [] + nodeAffinity: {} + + nodeSelector: {} + infinispan: cacheContainer: # [USER] Add cache, template, and counter configuration.