From 47a34c4b36e17bebffe802dde01ec4eb95b3edfd Mon Sep 17 00:00:00 2001 From: Phan Le Date: Tue, 13 Apr 2021 15:50:25 -0700 Subject: [PATCH] Allow user to set node selector for system managed components, manager, UI, driver deployer This feature allow user to deploy Longhorn only on a specific set of nodes Longhorn #2199 Signed-off-by: Phan Le --- chart/questions.yml | 20 -------------------- chart/templates/daemonset-sa.yaml | 4 ++++ chart/templates/default-setting.yaml | 1 + chart/templates/deployment-driver.yaml | 4 ++++ chart/templates/deployment-ui.yaml | 4 ++++ chart/templates/postupgrade-job.yaml | 4 ++++ chart/templates/uninstall-job.yaml | 4 ++++ chart/values.yaml | 20 ++++++++++++++++++-- 8 files changed, 39 insertions(+), 22 deletions(-) diff --git a/chart/questions.yml b/chart/questions.yml index 1d81e27..d1b8a40 100644 --- a/chart/questions.yml +++ b/chart/questions.yml @@ -304,26 +304,6 @@ The available modes are: type: int min: 0 default: 300 - - variable: defaultSettings.taintToleration - label: Kubernetes Taint Toleration - description: "To dedicate nodes to store Longhorn replicas and reject other general workloads, set tolerations for Longhorn and add taints for the storage nodes. -All Longhorn volumes should be detached before modifying toleration settings. -We recommend setting tolerations during Longhorn deployment because the Longhorn system cannot be operated during the update. -Multiple tolerations can be set here, and these tolerations are separated by semicolon. For example: -* `key1=value1:NoSchedule; key2:NoExecute` -* `:` this toleration tolerates everything because an empty key with operator `Exists` matches all keys, values and effects -* `key1=value1:` this toleration has empty effect. It matches all effects with key `key1` -Because `kubernetes.io` is used as the key of all Kubernetes default tolerations, it should not be used in the toleration settings. -WARNING: DO NOT CHANGE THIS SETTING WITH ATTACHED VOLUMES!" - group: "Longhorn Default Settings" - type: string - default: "" - - variable: defaultSettings.priorityClass - label: Priority Class - description: "The name of the Priority Class to set on the Longhorn workloads. This can help prevent Longhorn workloads from being evicted under Node Pressure. WARNING: DO NOT CHANGE THIS SETTING WITH ATTACHED VOLUMES." - group: "Longhorn Default Settings" - type: string - default: "" - variable: defaultSettings.autoSalvage label: Automatic salvage description: "If enabled, volumes will be automatically salvaged when all the replicas become faulty e.g. due to network disconnection. Longhorn will try to figure out which replica(s) are usable, then use them for the volume. By default true." diff --git a/chart/templates/daemonset-sa.yaml b/chart/templates/daemonset-sa.yaml index b4f2111..636a4c0 100644 --- a/chart/templates/daemonset-sa.yaml +++ b/chart/templates/daemonset-sa.yaml @@ -96,6 +96,10 @@ spec: tolerations: {{ toYaml .Values.longhornManager.tolerations | indent 6 }} {{- end }} + {{- if .Values.longhornManager.nodeSelector }} + nodeSelector: +{{ toYaml .Values.longhornManager.nodeSelector | indent 8 }} + {{- end }} updateStrategy: rollingUpdate: maxUnavailable: "100%" diff --git a/chart/templates/default-setting.yaml b/chart/templates/default-setting.yaml index 3b022f3..e1f0c7a 100644 --- a/chart/templates/default-setting.yaml +++ b/chart/templates/default-setting.yaml @@ -21,6 +21,7 @@ data: default-longhorn-static-storage-class: {{ .Values.defaultSettings.defaultLonghornStaticStorageClass }} backupstore-poll-interval: {{ .Values.defaultSettings.backupstorePollInterval }} taint-toleration: {{ .Values.defaultSettings.taintToleration }} + system-managed-components-node-selector: {{ .Values.defaultSettings.systemManagedComponentsNodeSelector }} priority-class: {{ .Values.defaultSettings.priorityClass }} auto-salvage: {{ .Values.defaultSettings.autoSalvage }} auto-delete-pod-when-volume-detached-unexpectedly: {{ .Values.defaultSettings.autoDeletePodWhenVolumeDetachedUnexpectedly }} diff --git a/chart/templates/deployment-driver.yaml b/chart/templates/deployment-driver.yaml index 65c5b3b..fb0390a 100644 --- a/chart/templates/deployment-driver.yaml +++ b/chart/templates/deployment-driver.yaml @@ -94,6 +94,10 @@ spec: {{- if .Values.longhornDriver.tolerations }} tolerations: {{ toYaml .Values.longhornDriver.tolerations | indent 6 }} + {{- end }} + {{- if .Values.longhornDriver.nodeSelector }} + nodeSelector: +{{ toYaml .Values.longhornDriver.nodeSelector | indent 8 }} {{- end }} serviceAccountName: longhorn-service-account securityContext: diff --git a/chart/templates/deployment-ui.yaml b/chart/templates/deployment-ui.yaml index cf14352..e46a842 100644 --- a/chart/templates/deployment-ui.yaml +++ b/chart/templates/deployment-ui.yaml @@ -38,6 +38,10 @@ spec: tolerations: {{ toYaml .Values.longhornManager.tolerations | indent 6 }} {{- end }} + {{- if .Values.longhornUI.nodeSelector }} + nodeSelector: +{{ toYaml .Values.longhornManager.nodeSelector | indent 8 }} + {{- end }} --- kind: Service apiVersion: v1 diff --git a/chart/templates/postupgrade-job.yaml b/chart/templates/postupgrade-job.yaml index 2f37580..4af75e2 100644 --- a/chart/templates/postupgrade-job.yaml +++ b/chart/templates/postupgrade-job.yaml @@ -42,3 +42,7 @@ spec: tolerations: {{ toYaml .Values.longhornManager.tolerations | indent 6 }} {{- end }} + {{- if .Values.longhornManager.nodeSelector }} + nodeSelector: +{{ toYaml .Values.longhornManager.nodeSelector | indent 8 }} + {{- end }} diff --git a/chart/templates/uninstall-job.yaml b/chart/templates/uninstall-job.yaml index 5153008..5f21b10 100644 --- a/chart/templates/uninstall-job.yaml +++ b/chart/templates/uninstall-job.yaml @@ -43,3 +43,7 @@ spec: tolerations: {{ toYaml .Values.longhornManager.tolerations | indent 6 }} {{- end }} + {{- if .Values.longhornManager.nodeSelector }} + nodeSelector: +{{ toYaml .Values.longhornManager.nodeSelector | indent 8 }} + {{- end }} diff --git a/chart/values.yaml b/chart/values.yaml index e29c281..7e0c416 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -82,6 +82,7 @@ defaultSettings: defaultLonghornStaticStorageClass: ~ backupstorePollInterval: ~ taintToleration: ~ + systemManagedComponentsNodeSelector: ~ priorityClass: ~ autoSalvage: ~ autoDeletePodWhenVolumeDetachedUnexpectedly: ~ @@ -116,26 +117,41 @@ longhornManager: # operator: "Equal" # value: "value" # effect: "NoSchedule" + nodeSelector: {} + ## If you want to set node selector for Longhorn Manager DaemonSet, delete the `{}` in the line above + ## and uncomment this example block + # label-key1: "label-value1" + # label-key2: "label-value2" longhornDriver: priorityClass: ~ tolerations: [] - ## If you want to set tolerations for Longhorn Manager DaemonSet, delete the `[]` in the line above + ## If you want to set tolerations for Longhorn Driver Deployer Deployment, delete the `[]` in the line above ## and uncomment this example block # - key: "key" # operator: "Equal" # value: "value" # effect: "NoSchedule" + nodeSelector: {} + ## If you want to set node selector for Longhorn Driver Deployer Deployment, delete the `{}` in the line above + ## and uncomment this example block + # label-key1: "label-value1" + # label-key2: "label-value2" longhornUI: priorityClass: ~ tolerations: [] - ## If you want to set tolerations for Longhorn Manager DaemonSet, delete the `[]` in the line above + ## If you want to set tolerations for Longhorn UI Deployment, delete the `[]` in the line above ## and uncomment this example block # - key: "key" # operator: "Equal" # value: "value" # effect: "NoSchedule" + nodeSelector: {} + ## If you want to set node selector for Longhorn UI Deployment, delete the `{}` in the line above + ## and uncomment this example block + # label-key1: "label-value1" + # label-key2: "label-value2" resources: {} # We usually recommend not to specify default resources and to leave this as a conscious