From be77bafd7755bbf6153d78ceb588f5ad1c40ddb4 Mon Sep 17 00:00:00 2001 From: Feruzjon Muyassarov Date: Fri, 17 Nov 2023 16:49:49 +0200 Subject: [PATCH] helm: introduce affinity to select specific nodes for the DaemonSet Allow users to define custom affinity rules in values.yaml, specifying preferred nodes for plugin DaemonSet Pods. Follows Kubernetes structure for affinity fields. Signed-off-by: Feruzjon Muyassarov --- deployment/helm/balloons/README.md | 4 +++- .../helm/balloons/templates/daemonset.yaml | 7 +++++++ deployment/helm/balloons/values.yaml | 21 +++++++++++++++++++ deployment/helm/memory-qos/README.md | 6 ++++-- .../helm/memory-qos/templates/daemonset.yaml | 7 +++++++ deployment/helm/memory-qos/values.yaml | 21 +++++++++++++++++++ deployment/helm/memtierd/README.md | 6 ++++-- .../helm/memtierd/templates/daemonset.yaml | 7 +++++++ deployment/helm/memtierd/values.yaml | 21 +++++++++++++++++++ deployment/helm/sgx-epc/README.md | 6 ++++-- .../helm/sgx-epc/templates/daemonset.yaml | 7 +++++++ deployment/helm/sgx-epc/values.yaml | 21 +++++++++++++++++++ deployment/helm/topology-aware/README.md | 4 +++- .../topology-aware/templates/daemonset.yaml | 7 +++++++ deployment/helm/topology-aware/values.yaml | 21 +++++++++++++++++++ 15 files changed, 158 insertions(+), 8 deletions(-) diff --git a/deployment/helm/balloons/README.md b/deployment/helm/balloons/README.md index d8e95dce9..850698914 100644 --- a/deployment/helm/balloons/README.md +++ b/deployment/helm/balloons/README.md @@ -98,7 +98,9 @@ customize with their own values, along with the default values. | `hostPort` | 8891 | metrics port to expose on the host | | `config` |
ReservedResources:
cpu: 750m
| plugin configuration data | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | -| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | +| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | | `initImage.tag` | unstable | init container image tag | | `initImage.pullPolicy` | Always | init container image pull policy | | `tolerations` | [] | specify taint toleration key, operator and effect | +| `affinity` | [] | specify node affinity | +| `nodeSelector` | [] | specify node selector labels | diff --git a/deployment/helm/balloons/templates/daemonset.yaml b/deployment/helm/balloons/templates/daemonset.yaml index 7697a328f..4c438ef2e 100644 --- a/deployment/helm/balloons/templates/daemonset.yaml +++ b/deployment/helm/balloons/templates/daemonset.yaml @@ -17,10 +17,17 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} {{- end }} serviceAccount: nri-resource-policy-balloons nodeSelector: kubernetes.io/os: "linux" + {{- with .Values.nodeSelector }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- if .Values.nri.patchRuntimeConfig }} initContainers: - name: patch-runtime diff --git a/deployment/helm/balloons/values.yaml b/deployment/helm/balloons/values.yaml index 2524dbf89..995d1c0ae 100644 --- a/deployment/helm/balloons/values.yaml +++ b/deployment/helm/balloons/values.yaml @@ -37,3 +37,24 @@ tolerations: [] # - key: "node-role.kubernetes.io/control-plane" # operator: "Exists" # effect: "NoSchedule" + +affinity: [] +# +# Example: +# +# affinity: +# nodeAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# nodeSelectorTerms: +# - matchExpressions: +# - key: topology.kubernetes.io/disk +# operator: In +# values: +# - ssd + +nodeSelector: [] +# +# Example: +# +# nodeSelector: +# kubernetes.io/disk: "ssd" diff --git a/deployment/helm/memory-qos/README.md b/deployment/helm/memory-qos/README.md index 38fc2b18a..580cfbe92 100644 --- a/deployment/helm/memory-qos/README.md +++ b/deployment/helm/memory-qos/README.md @@ -90,13 +90,15 @@ customize with their own values, along with the default values. | Name | Default | Description | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | -| `image.name` | [ghcr.io/containers/nri-plugins/nri-memory-qos](https://ghcr.io/containers/nri-plugins/nri-memory-qos) | container image name | +| `image.name` | [ghcr.io/containers/nri-plugins/nri-memory-qos](https://ghcr.io/containers/nri-plugins/nri-memory-qos) | container image name | | `image.tag` | unstable | container image tag | | `image.pullPolicy` | Always | image pull policy | | `resources.cpu` | 10m | cpu resources for the Pod | | `resources.memory` | 100Mi | memory qouta for the | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | -| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | +| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | | `initImage.tag` | unstable | init container image tag | | `initImage.pullPolicy` | Always | init container image pull policy | | `tolerations` | [] | specify taint toleration key, operator and effect | +| `affinity` | [] | specify node affinity | +| `nodeSelector` | [] | specify node selector labels | diff --git a/deployment/helm/memory-qos/templates/daemonset.yaml b/deployment/helm/memory-qos/templates/daemonset.yaml index 414f19ec7..ee68eda34 100644 --- a/deployment/helm/memory-qos/templates/daemonset.yaml +++ b/deployment/helm/memory-qos/templates/daemonset.yaml @@ -17,9 +17,16 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} {{- end }} nodeSelector: kubernetes.io/os: "linux" + {{- with .Values.nodeSelector }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- if .Values.nri.patchRuntimeConfig }} initContainers: - name: patch-runtime diff --git a/deployment/helm/memory-qos/values.yaml b/deployment/helm/memory-qos/values.yaml index b20cb7e95..5d33068bb 100644 --- a/deployment/helm/memory-qos/values.yaml +++ b/deployment/helm/memory-qos/values.yaml @@ -29,3 +29,24 @@ tolerations: [] # - key: "node-role.kubernetes.io/control-plane" # operator: "Exists" # effect: "NoSchedule" + +affinity: [] +# +# Example: +# +# affinity: +# nodeAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# nodeSelectorTerms: +# - matchExpressions: +# - key: topology.kubernetes.io/disk +# operator: In +# values: +# - ssd + +nodeSelector: [] +# +# Example: +# +# nodeSelector: +# kubernetes.io/disk: "ssd" diff --git a/deployment/helm/memtierd/README.md b/deployment/helm/memtierd/README.md index 73ec9569b..e46ae3076 100644 --- a/deployment/helm/memtierd/README.md +++ b/deployment/helm/memtierd/README.md @@ -89,14 +89,16 @@ customize with their own values, along with the default values. | Name | Default | Description | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | -| `image.name` | [ghcr.io/containers/nri-plugins/nri-memtierd](https://ghcr.io/containers/nri-plugins/nri-memtierd) | container image name | +| `image.name` | [ghcr.io/containers/nri-plugins/nri-memtierd](https://ghcr.io/containers/nri-plugins/nri-memtierd) | container image name | | `image.tag` | unstable | container image tag | | `image.pullPolicy` | Always | image pull policy | | `resources.cpu` | 250m | cpu resources for the Pod | | `resources.memory` | 100Mi | memory qouta for the | | `outputDir` | empty string | host directory for memtierd.output files | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | -| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | +| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | | `initImage.tag` | unstable | init container image tag | | `initImage.pullPolicy` | Always | init container image pull policy | | `tolerations` | [] | specify taint toleration key, operator and effect | +| `affinity` | [] | specify node affinity | +| `nodeSelector` | [] | specify node selector labels | diff --git a/deployment/helm/memtierd/templates/daemonset.yaml b/deployment/helm/memtierd/templates/daemonset.yaml index f4b40c26f..6cacdc323 100644 --- a/deployment/helm/memtierd/templates/daemonset.yaml +++ b/deployment/helm/memtierd/templates/daemonset.yaml @@ -17,9 +17,16 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} {{- end }} nodeSelector: kubernetes.io/os: "linux" + {{- with .Values.nodeSelector }} + {{- toYaml . | nindent 8 }} + {{- end }} hostPID: true {{- if .Values.nri.patchRuntimeConfig }} initContainers: diff --git a/deployment/helm/memtierd/values.yaml b/deployment/helm/memtierd/values.yaml index 5ffb7ba2d..f161096d1 100644 --- a/deployment/helm/memtierd/values.yaml +++ b/deployment/helm/memtierd/values.yaml @@ -31,3 +31,24 @@ tolerations: [] # - key: "node-role.kubernetes.io/control-plane" # operator: "Exists" # effect: "NoSchedule" + +affinity: [] +# +# Example: +# +# affinity: +# nodeAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# nodeSelectorTerms: +# - matchExpressions: +# - key: topology.kubernetes.io/disk +# operator: In +# values: +# - ssd + +nodeSelector: [] +# +# Example: +# +# nodeSelector: +# kubernetes.io/disk: "ssd" diff --git a/deployment/helm/sgx-epc/README.md b/deployment/helm/sgx-epc/README.md index a0ad4be21..ab3759506 100644 --- a/deployment/helm/sgx-epc/README.md +++ b/deployment/helm/sgx-epc/README.md @@ -90,13 +90,15 @@ customize with their own values, along with the default values. | Name | Default | Description | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | -| `image.name` | [ghcr.io/containers/nri-plugins/nri-sgx-epc](https://ghcr.io/containers/nri-plugins/nri-sgx-epc) | container image name | +| `image.name` | [ghcr.io/containers/nri-plugins/nri-sgx-epc](https://ghcr.io/containers/nri-plugins/nri-sgx-epc) | container image name | | `image.tag` | unstable | container image tag | | `image.pullPolicy` | Always | image pull policy | | `resources.cpu` | 25m | cpu resources for the Pod | | `resources.memory` | 100Mi | memory qouta for the | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | -| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | +| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | | `initImage.tag` | unstable | init container image tag | | `initImage.pullPolicy` | Always | init container image pull policy | | `tolerations` | [] | specify taint toleration key, operator and effect | +| `affinity` | [] | specify node affinity | +| `nodeSelector` | [] | specify node selector labels | diff --git a/deployment/helm/sgx-epc/templates/daemonset.yaml b/deployment/helm/sgx-epc/templates/daemonset.yaml index 24190d82f..c3e1041a2 100644 --- a/deployment/helm/sgx-epc/templates/daemonset.yaml +++ b/deployment/helm/sgx-epc/templates/daemonset.yaml @@ -19,8 +19,15 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} restartPolicy: Always + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} nodeSelector: kubernetes.io/os: "linux" + {{- with .Values.nodeSelector }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- if .Values.nri.patchRuntimeConfig }} initContainers: - name: patch-runtime diff --git a/deployment/helm/sgx-epc/values.yaml b/deployment/helm/sgx-epc/values.yaml index 7555ded59..e593c951b 100644 --- a/deployment/helm/sgx-epc/values.yaml +++ b/deployment/helm/sgx-epc/values.yaml @@ -29,3 +29,24 @@ tolerations: [] # - key: "node-role.kubernetes.io/control-plane" # operator: "Exists" # effect: "NoSchedule" + +affinity: [] +# +# Example: +# +# affinity: +# nodeAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# nodeSelectorTerms: +# - matchExpressions: +# - key: topology.kubernetes.io/disk +# operator: In +# values: +# - ssd + +nodeSelector: [] +# +# Example: +# +# nodeSelector: +# kubernetes.io/disk: "ssd" diff --git a/deployment/helm/topology-aware/README.md b/deployment/helm/topology-aware/README.md index 7acbfc7be..3997987c0 100644 --- a/deployment/helm/topology-aware/README.md +++ b/deployment/helm/topology-aware/README.md @@ -99,7 +99,9 @@ customize with their own values, along with the default values. | `hostPort` | 8891 | metrics port to expose on the host | | `config` |
ReservedResources:
cpu: 750m
| plugin configuration data | | `nri.patchRuntimeConfig` | false | enable NRI in containerd or CRI-O | -| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | +| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name | | `initImage.tag` | unstable | init container image tag | | `initImage.pullPolicy` | Always | init container image pull policy | | `tolerations` | [] | specify taint toleration key, operator and effect | +| `affinity` | [] | specify node affinity | +| `nodeSelector` | [] | specify node selector labels | diff --git a/deployment/helm/topology-aware/templates/daemonset.yaml b/deployment/helm/topology-aware/templates/daemonset.yaml index da725be13..314cc75a1 100644 --- a/deployment/helm/topology-aware/templates/daemonset.yaml +++ b/deployment/helm/topology-aware/templates/daemonset.yaml @@ -17,10 +17,17 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} {{- end }} serviceAccount: nri-resource-policy-topology-aware nodeSelector: kubernetes.io/os: "linux" + {{- with .Values.nodeSelector }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- if .Values.nri.patchRuntimeConfig }} initContainers: - name: patch-runtime diff --git a/deployment/helm/topology-aware/values.yaml b/deployment/helm/topology-aware/values.yaml index cbd8a764b..60bdb243f 100644 --- a/deployment/helm/topology-aware/values.yaml +++ b/deployment/helm/topology-aware/values.yaml @@ -36,3 +36,24 @@ tolerations: [] # - key: "node-role.kubernetes.io/control-plane" # operator: "Exists" # effect: "NoSchedule" + +affinity: [] +# +# Example: +# +# affinity: +# nodeAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# nodeSelectorTerms: +# - matchExpressions: +# - key: topology.kubernetes.io/disk +# operator: In +# values: +# - ssd + +nodeSelector: [] +# +# Example: +# +# nodeSelector: +# kubernetes.io/disk: "ssd"