Merge pull request #8006 from Rakshith-R/feature/options-toleration-affinity
ceph: add support for adding rbd and cephfs tolerations and affinities separately
This commit is contained in:
6 files changed
+186
-56
No files matched your search
@@ -113,8 +113,16 @@ The following tables lists the configurable parameters of the rook-operator char
|
||||
| `csi.enableCSIHostNetwork` | Enable Host Networking for Ceph CSI nodeplugins. | `false` |
|
||||
| `csi.provisionerTolerations` | Array of tolerations in YAML format which will be added to CSI provisioner deployment. | <none> |
|
||||
| `csi.provisionerNodeAffinity` | The node labels for affinity of the CSI provisioner deployment (***) | <none> |
|
||||
| `csi.pluginTolerations` | Array of tolerations in YAML format which will be added to Ceph CSI plugin DaemonSet | <none> |
|
||||
| `csi.pluginNodeAffinity` | The node labels for affinity of the Ceph CSI plugin DaemonSet (***) | <none> |
|
||||
| `csi.pluginTolerations` | Array of tolerations in YAML format which will be added to CephCSI plugin DaemonSet | <none> |
|
||||
| `csi.pluginNodeAffinity` | The node labels for affinity of the CephCSI plugin DaemonSet (***) | <none> |
|
||||
| `csi.rbdProvisionerTolerations` | Array of tolerations in YAML format which will be added to CephCSI RBD provisioner deployment. | <none> |
|
||||
| `csi.rbdProvisionerNodeAffinity` | The node labels for affinity of the CephCSI RBD provisioner deployment (***) | <none> |
|
||||
| `csi.rbdPluginTolerations` | Array of tolerations in YAML format which will be added to CephCSI RBD plugin DaemonSet | <none> |
|
||||
| `csi.rbdPluginNodeAffinity` | The node labels for affinity of the CephCSI RBD plugin DaemonSet (***) | <none> |
|
||||
| `csi.cephFSProvisionerTolerations` | Array of tolerations in YAML format which will be added to CephCSI CephFS provisioner deployment. | <none> |
|
||||
| `csi.cephFSProvisionerNodeAffinity`| The node labels for affinity of the CephCSI CephFS provisioner deployment (***) | <none> |
|
||||
| `csi.cephFSPluginTolerations` | Array of tolerations in YAML format which will be added to CephCSI CephFS plugin DaemonSet | <none> |
|
||||
| `csi.cephFSPluginNodeAffinity` | The node labels for affinity of the CephCSI CephFS plugin DaemonSet (***) | <none> |
|
||||
| `csi.csiRBDProvisionerResource` | CEPH CSI RBD provisioner resource requirement list. | <none> |
|
||||
| `csi.csiRBDPluginResource` | CEPH CSI RBD plugin resource requirement list. | <none> |
|
||||
| `csi.csiCephFSProvisionerResource` | CEPH CSI CephFS provisioner resource requirement list. | <none> |
|
||||
|
||||
@@ -202,6 +202,22 @@ spec:
|
||||
- name: CSI_PROVISIONER_NODE_AFFINITY
|
||||
value: {{ .Values.csi.provisionerNodeAffinity }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.rbdProvisionerTolerations }}
|
||||
- name: CSI_RBD_PROVISIONER_TOLERATIONS
|
||||
value: {{ toYaml .Values.csi.rbdProvisionerTolerations | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.rbdProvisionerNodeAffinity }}
|
||||
- name: CSI_RBD_PROVISIONER_NODE_AFFINITY
|
||||
value: {{ .Values.csi.rbdProvisionerNodeAffinity }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.cephFSProvisionerTolerations }}
|
||||
- name: CSI_CEPHFS_PROVISIONER_TOLERATIONS
|
||||
value: {{ toYaml .Values.csi.cephFSProvisionerTolerations | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.cephFSProvisionerNodeAffinity }}
|
||||
- name: CSI_CEPHFS_PROVISIONER_NODE_AFFINITY
|
||||
value: {{ .Values.csi.cephFSProvisionerNodeAffinity }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.allowUnsupportedVersion }}
|
||||
- name: ROOK_CSI_ALLOW_UNSUPPORTED_VERSION
|
||||
value: {{ .Values.csi.allowUnsupportedVersion | quote }}
|
||||
@@ -214,6 +230,22 @@ spec:
|
||||
- name: CSI_PLUGIN_NODE_AFFINITY
|
||||
value: {{ .Values.csi.pluginNodeAffinity }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.rbdPluginTolerations }}
|
||||
- name: CSI_RBD_PLUGIN_TOLERATIONS
|
||||
value: {{ toYaml .Values.csi.rbdPluginTolerations | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.rbdPluginNodeAffinity }}
|
||||
- name: CSI_RBD_PLUGIN_NODE_AFFINITY
|
||||
value: {{ .Values.csi.rbdPluginNodeAffinity }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.cephFSPluginTolerations }}
|
||||
- name: CSI_CEPHFS_PLUGIN_TOLERATIONS
|
||||
value: {{ toYaml .Values.csi.cephFSPluginTolerations | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.cephFSPluginNodeAffinity }}
|
||||
- name: CSI_CEPHFS_PLUGIN_NODE_AFFINITY
|
||||
value: {{ .Values.csi.cephFSPluginNodeAffinity }}
|
||||
{{- end }}
|
||||
{{- if .Values.csi.cephfsGrpcMetricsPort }}
|
||||
- name: CSI_CEPHFS_GRPC_METRICS_PORT
|
||||
value: {{ .Values.csi.cephfsGrpcMetricsPort | quote }}
|
||||
|
||||
@@ -176,9 +176,10 @@ data:
|
||||
# Labels to add to the CSI RBD Deployments and DaemonSets Pods.
|
||||
# ROOK_CSI_RBD_POD_LABELS: "key1=value1,key2=value2"
|
||||
|
||||
# (Optional) Ceph Provisioner NodeAffinity.
|
||||
# (Optional) CephCSI provisioner NodeAffinity(applied to both CephFS and RBD provisioner).
|
||||
# CSI_PROVISIONER_NODE_AFFINITY: "role=storage-node; storage=rook, ceph"
|
||||
# (Optional) CEPH CSI provisioner tolerations list. Put here list of taints you want to tolerate in YAML format.
|
||||
# (Optional) CephCSI provisioner tolerations list(applied to both CephFS and RBD provisioner).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI provisioner would be best to start on the same nodes as other ceph daemons.
|
||||
# CSI_PROVISIONER_TOLERATIONS: |
|
||||
# - effect: NoSchedule
|
||||
@@ -187,9 +188,10 @@ data:
|
||||
# - effect: NoExecute
|
||||
# key: node-role.kubernetes.io/etcd
|
||||
# operator: Exists
|
||||
# (Optional) Ceph CSI plugin NodeAffinity.
|
||||
# (Optional) CephCSI plugin NodeAffinity(applied to both CephFS and RBD plugin).
|
||||
# CSI_PLUGIN_NODE_AFFINITY: "role=storage-node; storage=rook, ceph"
|
||||
# (Optional) CEPH CSI plugin tolerations list. Put here list of taints you want to tolerate in YAML format.
|
||||
# (Optional) CephCSI plugin tolerations list(applied to both CephFS and RBD plugin).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI plugins need to be started on all the nodes where the clients need to mount the storage.
|
||||
# CSI_PLUGIN_TOLERATIONS: |
|
||||
# - effect: NoSchedule
|
||||
@@ -199,6 +201,40 @@ data:
|
||||
# key: node-role.kubernetes.io/etcd
|
||||
# operator: Exists
|
||||
|
||||
# (Optional) CephCSI RBD provisioner NodeAffinity(if specified, overrides CSI_PROVISIONER_NODE_AFFINITY).
|
||||
# CSI_RBD_PROVISIONER_NODE_AFFINITY: "role=rbd-node"
|
||||
# (Optional) CephCSI RBD provisioner tolerations list(if specified, overrides CSI_PROVISIONER_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI provisioner would be best to start on the same nodes as other ceph daemons.
|
||||
# CSI_RBD_PROVISIONER_TOLERATIONS: |
|
||||
# - key: node.rook.io/rbd
|
||||
# operator: Exists
|
||||
# (Optional) CephCSI RBD plugin NodeAffinity(if specified, overrides CSI_PLUGIN_NODE_AFFINITY).
|
||||
# CSI_RBD_PLUGIN_NODE_AFFINITY: "role=rbd-node"
|
||||
# (Optional) CephCSI RBD plugin tolerations list(if specified, overrides CSI_PLUGIN_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI plugins need to be started on all the nodes where the clients need to mount the storage.
|
||||
# CSI_RBD_PLUGIN_TOLERATIONS: |
|
||||
# - key: node.rook.io/rbd
|
||||
# operator: Exists
|
||||
|
||||
# (Optional) CephCSI CephFS provisioner NodeAffinity(if specified, overrides CSI_PROVISIONER_NODE_AFFINITY).
|
||||
# CSI_CEPHFS_PROVISIONER_NODE_AFFINITY: "role=cephfs-node"
|
||||
# (Optional) CephCSI CephFS provisioner tolerations list(if specified, overrides CSI_PROVISIONER_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI provisioner would be best to start on the same nodes as other ceph daemons.
|
||||
# CSI_CEPHFS_PROVISIONER_TOLERATIONS: |
|
||||
# - key: node.rook.io/cephfs
|
||||
# operator: Exists
|
||||
# (Optional) CephCSI CephFS plugin NodeAffinity(if specified, overrides CSI_PLUGIN_NODE_AFFINITY).
|
||||
# CSI_CEPHFS_PLUGIN_NODE_AFFINITY: "role=cephfs-node"
|
||||
# (Optional) CephCSI CephFS plugin tolerations list(if specified, overrides CSI_PLUGIN_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI plugins need to be started on all the nodes where the clients need to mount the storage.
|
||||
# CSI_CEPHFS_PLUGIN_TOLERATIONS: |
|
||||
# - key: node.rook.io/cephfs
|
||||
# operator: Exists
|
||||
|
||||
# (Optional) CEPH CSI RBD provisioner resource requirement list, Put here list of resource
|
||||
# requests and limits you want to apply for provisioner pod
|
||||
# CSI_RBD_PROVISIONER_RESOURCE: |
|
||||
|
||||
@@ -100,9 +100,10 @@ data:
|
||||
# Labels to add to the CSI RBD Deployments and DaemonSets Pods.
|
||||
# ROOK_CSI_RBD_POD_LABELS: "key1=value1,key2=value2"
|
||||
|
||||
# (Optional) Ceph Provisioner NodeAffinity.
|
||||
# (Optional) CephCSI provisioner NodeAffinity(applied to both CephFS and RBD provisioner).
|
||||
# CSI_PROVISIONER_NODE_AFFINITY: "role=storage-node; storage=rook, ceph"
|
||||
# (Optional) CEPH CSI provisioner tolerations list. Put here list of taints you want to tolerate in YAML format.
|
||||
# (Optional) CephCSI provisioner tolerations list(applied to both CephFS and RBD provisioner).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI provisioner would be best to start on the same nodes as other ceph daemons.
|
||||
# CSI_PROVISIONER_TOLERATIONS: |
|
||||
# - effect: NoSchedule
|
||||
@@ -111,9 +112,10 @@ data:
|
||||
# - effect: NoExecute
|
||||
# key: node-role.kubernetes.io/etcd
|
||||
# operator: Exists
|
||||
# (Optional) Ceph CSI plugin NodeAffinity.
|
||||
# (Optional) CephCSI plugin NodeAffinity(applied to both CephFS and RBD plugin).
|
||||
# CSI_PLUGIN_NODE_AFFINITY: "role=storage-node; storage=rook, ceph"
|
||||
# (Optional) CEPH CSI plugin tolerations list. Put here list of taints you want to tolerate in YAML format.
|
||||
# (Optional) CephCSI plugin tolerations list(applied to both CephFS and RBD plugin).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI plugins need to be started on all the nodes where the clients need to mount the storage.
|
||||
# CSI_PLUGIN_TOLERATIONS: |
|
||||
# - effect: NoSchedule
|
||||
@@ -123,6 +125,40 @@ data:
|
||||
# key: node-role.kubernetes.io/etcd
|
||||
# operator: Exists
|
||||
|
||||
# (Optional) CephCSI RBD provisioner NodeAffinity(if specified, overrides CSI_PROVISIONER_NODE_AFFINITY).
|
||||
# CSI_RBD_PROVISIONER_NODE_AFFINITY: "role=rbd-node"
|
||||
# (Optional) CephCSI RBD provisioner tolerations list(if specified, overrides CSI_PROVISIONER_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI provisioner would be best to start on the same nodes as other ceph daemons.
|
||||
# CSI_RBD_PROVISIONER_TOLERATIONS: |
|
||||
# - key: node.rook.io/rbd
|
||||
# operator: Exists
|
||||
# (Optional) CephCSI RBD plugin NodeAffinity(if specified, overrides CSI_PLUGIN_NODE_AFFINITY).
|
||||
# CSI_RBD_PLUGIN_NODE_AFFINITY: "role=rbd-node"
|
||||
# (Optional) CephCSI RBD plugin tolerations list(if specified, overrides CSI_PLUGIN_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI plugins need to be started on all the nodes where the clients need to mount the storage.
|
||||
# CSI_RBD_PLUGIN_TOLERATIONS: |
|
||||
# - key: node.rook.io/rbd
|
||||
# operator: Exists
|
||||
|
||||
# (Optional) CephCSI CephFS provisioner NodeAffinity(if specified, overrides CSI_PROVISIONER_NODE_AFFINITY).
|
||||
# CSI_CEPHFS_PROVISIONER_NODE_AFFINITY: "role=cephfs-node"
|
||||
# (Optional) CephCSI CephFS provisioner tolerations list(if specified, overrides CSI_PROVISIONER_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI provisioner would be best to start on the same nodes as other ceph daemons.
|
||||
# CSI_CEPHFS_PROVISIONER_TOLERATIONS: |
|
||||
# - key: node.rook.io/cephfs
|
||||
# operator: Exists
|
||||
# (Optional) CephCSI CephFS plugin NodeAffinity(if specified, overrides CSI_PLUGIN_NODE_AFFINITY).
|
||||
# CSI_CEPHFS_PLUGIN_NODE_AFFINITY: "role=cephfs-node"
|
||||
# (Optional) CephCSI CephFS plugin tolerations list(if specified, overrides CSI_PLUGIN_TOLERATIONS).
|
||||
# Put here list of taints you want to tolerate in YAML format.
|
||||
# CSI plugins need to be started on all the nodes where the clients need to mount the storage.
|
||||
# CSI_CEPHFS_PLUGIN_TOLERATIONS: |
|
||||
# - key: node.rook.io/cephfs
|
||||
# operator: Exists
|
||||
|
||||
# (Optional) CEPH CSI RBD provisioner resource requirement list, Put here list of resource
|
||||
# requests and limits you want to apply for provisioner pod
|
||||
# CSI_RBD_PROVISIONER_RESOURCE: |
|
||||
|
||||
@@ -122,12 +122,24 @@ const (
|
||||
kubeMinVerForBlockRestore = "16"
|
||||
kubeMinVerForSnapshot = "17"
|
||||
|
||||
// toleration and node affinity
|
||||
// common tolerations and node affinity
|
||||
provisionerTolerationsEnv = "CSI_PROVISIONER_TOLERATIONS"
|
||||
provisionerNodeAffinityEnv = "CSI_PROVISIONER_NODE_AFFINITY"
|
||||
pluginTolerationsEnv = "CSI_PLUGIN_TOLERATIONS"
|
||||
pluginNodeAffinityEnv = "CSI_PLUGIN_NODE_AFFINITY"
|
||||
|
||||
// CephFS tolerations and node affinity
|
||||
cephFSProvisionerTolerationsEnv = "CSI_CEPHFS_PROVISIONER_TOLERATIONS"
|
||||
cephFSProvisionerNodeAffinityEnv = "CSI_CEPHFS_PROVISIONER_NODE_AFFINITY"
|
||||
cephFSPluginTolerationsEnv = "CSI_CEPHFS_PLUGIN_TOLERATIONS"
|
||||
cephFSPluginNodeAffinityEnv = "CSI_CEPHFS_PLUGIN_NODE_AFFINITY"
|
||||
|
||||
// RBD tolerations and node affinity
|
||||
rbdProvisionerTolerationsEnv = "CSI_RBD_PROVISIONER_TOLERATIONS"
|
||||
rbdProvisionerNodeAffinityEnv = "CSI_RBD_PROVISIONER_NODE_AFFINITY"
|
||||
rbdPluginTolerationsEnv = "CSI_RBD_PLUGIN_TOLERATIONS"
|
||||
rbdPluginNodeAffinityEnv = "CSI_RBD_PLUGIN_NODE_AFFINITY"
|
||||
|
||||
// compute resource for CSI pods
|
||||
rbdProvisionerResource = "CSI_RBD_PROVISIONER_RESOURCE"
|
||||
rbdPluginResource = "CSI_RBD_PLUGIN_RESOURCE"
|
||||
@@ -418,14 +430,19 @@ func startDrivers(clientset kubernetes.Interface, rookclientset rookclient.Inter
|
||||
logger.Info("successfully started CSI CephFS driver")
|
||||
}
|
||||
|
||||
// get provisioner toleration and node affinity
|
||||
provisionerTolerations := getToleration(clientset, true)
|
||||
provisionerNodeAffinity := getNodeAffinity(clientset, true)
|
||||
// get plugin toleration and node affinity
|
||||
pluginTolerations := getToleration(clientset, false)
|
||||
pluginNodeAffinity := getNodeAffinity(clientset, false)
|
||||
// get common provisioner tolerations and node affinity
|
||||
provisionerTolerations := getToleration(clientset, provisionerTolerationsEnv, []corev1.Toleration{})
|
||||
provisionerNodeAffinity := getNodeAffinity(clientset, provisionerNodeAffinityEnv, &corev1.NodeAffinity{})
|
||||
// get common plugin tolerations and node affinity
|
||||
pluginTolerations := getToleration(clientset, pluginTolerationsEnv, []corev1.Toleration{})
|
||||
pluginNodeAffinity := getNodeAffinity(clientset, pluginNodeAffinityEnv, &corev1.NodeAffinity{})
|
||||
|
||||
if rbdPlugin != nil {
|
||||
applyToPodSpec(&rbdPlugin.Spec.Template.Spec, pluginNodeAffinity, pluginTolerations)
|
||||
// get RBD plugin tolerations and node affinity, defaults to common tolerations and node affinity if not specified
|
||||
rbdPluginTolerations := getToleration(clientset, rbdPluginTolerationsEnv, pluginTolerations)
|
||||
rbdPluginNodeAffinity := getNodeAffinity(clientset, rbdPluginNodeAffinityEnv, pluginNodeAffinity)
|
||||
// apply RBD plugin tolerations and node affinity
|
||||
applyToPodSpec(&rbdPlugin.Spec.Template.Spec, rbdPluginNodeAffinity, rbdPluginTolerations)
|
||||
// apply resource request and limit to rbdplugin containers
|
||||
applyResourcesToContainers(clientset, rbdPluginResource, &rbdPlugin.Spec.Template.Spec)
|
||||
err = ownerInfo.SetControllerReference(rbdPlugin)
|
||||
@@ -447,7 +464,11 @@ func startDrivers(clientset kubernetes.Interface, rookclientset rookclient.Inter
|
||||
}
|
||||
|
||||
if rbdProvisionerDeployment != nil {
|
||||
applyToPodSpec(&rbdProvisionerDeployment.Spec.Template.Spec, provisionerNodeAffinity, provisionerTolerations)
|
||||
// get RBD provisioner tolerations and node affinity, defaults to common tolerations and node affinity if not specified
|
||||
rbdProvisionerTolerations := getToleration(clientset, rbdProvisionerTolerationsEnv, provisionerTolerations)
|
||||
rbdProvisionerNodeAffinity := getNodeAffinity(clientset, rbdProvisionerNodeAffinityEnv, provisionerNodeAffinity)
|
||||
// apply RBD provisioner tolerations and node affinity
|
||||
applyToPodSpec(&rbdProvisionerDeployment.Spec.Template.Spec, rbdProvisionerNodeAffinity, rbdProvisionerTolerations)
|
||||
// apply resource request and limit to rbd provisioner containers
|
||||
applyResourcesToContainers(clientset, rbdProvisionerResource, &rbdProvisionerDeployment.Spec.Template.Spec)
|
||||
err = ownerInfo.SetControllerReference(rbdProvisionerDeployment)
|
||||
@@ -484,7 +505,11 @@ func startDrivers(clientset kubernetes.Interface, rookclientset rookclient.Inter
|
||||
}
|
||||
|
||||
if cephfsPlugin != nil {
|
||||
applyToPodSpec(&cephfsPlugin.Spec.Template.Spec, pluginNodeAffinity, pluginTolerations)
|
||||
// get CephFS plugin tolerations and node affinity, defaults to common tolerations and node affinity if not specified
|
||||
cephFSPluginTolerations := getToleration(clientset, cephFSPluginTolerationsEnv, pluginTolerations)
|
||||
cephFSPluginNodeAffinity := getNodeAffinity(clientset, cephFSPluginNodeAffinityEnv, pluginNodeAffinity)
|
||||
// apply CephFS plugin tolerations and node affinity
|
||||
applyToPodSpec(&cephfsPlugin.Spec.Template.Spec, cephFSPluginNodeAffinity, cephFSPluginTolerations)
|
||||
// apply resource request and limit to cephfs plugin containers
|
||||
applyResourcesToContainers(clientset, cephFSPluginResource, &cephfsPlugin.Spec.Template.Spec)
|
||||
err = ownerInfo.SetControllerReference(cephfsPlugin)
|
||||
@@ -506,7 +531,11 @@ func startDrivers(clientset kubernetes.Interface, rookclientset rookclient.Inter
|
||||
}
|
||||
|
||||
if cephfsProvisionerDeployment != nil {
|
||||
applyToPodSpec(&cephfsProvisionerDeployment.Spec.Template.Spec, provisionerNodeAffinity, provisionerTolerations)
|
||||
// get CephFS provisioner tolerations and node affinity, defaults to common tolerations and node affinity if not specified
|
||||
cephFSProvisionerTolerations := getToleration(clientset, cephFSProvisionerTolerationsEnv, provisionerTolerations)
|
||||
cephFSProvisionerNodeAffinity := getNodeAffinity(clientset, cephFSProvisionerNodeAffinityEnv, provisionerNodeAffinity)
|
||||
// apply CephFS provisioner tolerations and node affinity
|
||||
applyToPodSpec(&cephfsProvisionerDeployment.Spec.Template.Spec, cephFSProvisionerNodeAffinity, cephFSProvisionerTolerations)
|
||||
// get resource details for cephfs provisioner
|
||||
// apply resource request and limit to cephfs provisioner containers
|
||||
applyResourcesToContainers(clientset, cephFSProvisionerResource, &cephfsProvisionerDeployment.Spec.Template.Spec)
|
||||
@@ -733,7 +762,7 @@ func validateCSIVersion(clientset kubernetes.Interface, namespace, rookImage, se
|
||||
job.Spec.Template.Spec.ServiceAccountName = serviceAccountName
|
||||
|
||||
// Apply csi provisioner toleration for csi version check job
|
||||
job.Spec.Template.Spec.Tolerations = getToleration(clientset, true)
|
||||
job.Spec.Template.Spec.Tolerations = getToleration(clientset, provisionerTolerationsEnv, []corev1.Toleration{})
|
||||
stdout, _, retcode, err := versionReporter.Run(timeout)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to complete ceph CSI version job")
|
||||
|
||||
@@ -140,25 +140,20 @@ func getComputeResource(clientset kubernetes.Interface, key string) []k8sutil.Co
|
||||
return resource
|
||||
}
|
||||
|
||||
func getToleration(clientset kubernetes.Interface, provisioner bool) []corev1.Toleration {
|
||||
// Add toleration if any
|
||||
tolerations := []corev1.Toleration{}
|
||||
var err error
|
||||
tolerationsRaw := ""
|
||||
if provisioner {
|
||||
tolerationsRaw, err = k8sutil.GetOperatorSetting(clientset, controller.OperatorSettingConfigMapName, provisionerTolerationsEnv, "")
|
||||
} else {
|
||||
tolerationsRaw, err = k8sutil.GetOperatorSetting(clientset, controller.OperatorSettingConfigMapName, pluginTolerationsEnv, "")
|
||||
}
|
||||
func getToleration(clientset kubernetes.Interface, tolerationsName string, defaultTolerations []corev1.Toleration) []corev1.Toleration {
|
||||
// Add toleration if any, otherwise return defaultTolerations
|
||||
tolerationsRaw, err := k8sutil.GetOperatorSetting(clientset, controller.OperatorSettingConfigMapName, tolerationsName, "")
|
||||
if err != nil {
|
||||
// tolerationsRaw is empty
|
||||
logger.Warningf("tolerations will not be applied. %v", err)
|
||||
return tolerations
|
||||
logger.Warningf("failed to read %q. %v", tolerationsName, err)
|
||||
return defaultTolerations
|
||||
}
|
||||
tolerations, err = k8sutil.YamlToTolerations(tolerationsRaw)
|
||||
if tolerationsRaw == "" {
|
||||
return defaultTolerations
|
||||
}
|
||||
tolerations, err := k8sutil.YamlToTolerations(tolerationsRaw)
|
||||
if err != nil {
|
||||
logger.Warningf("failed to parse %q. %v", tolerationsRaw, err)
|
||||
return tolerations
|
||||
logger.Warningf("failed to parse %q for %q. %v", tolerationsRaw, tolerationsName, err)
|
||||
return defaultTolerations
|
||||
}
|
||||
for i := range tolerations {
|
||||
if tolerations[i].Key == "" {
|
||||
@@ -172,26 +167,20 @@ func getToleration(clientset kubernetes.Interface, provisioner bool) []corev1.To
|
||||
return tolerations
|
||||
}
|
||||
|
||||
func getNodeAffinity(clientset kubernetes.Interface, provisioner bool) *corev1.NodeAffinity {
|
||||
// Add NodeAffinity if any
|
||||
nodeAffinity := ""
|
||||
v1NodeAffinity := &corev1.NodeAffinity{}
|
||||
var err error
|
||||
if provisioner {
|
||||
nodeAffinity, err = k8sutil.GetOperatorSetting(clientset, controller.OperatorSettingConfigMapName, provisionerNodeAffinityEnv, "")
|
||||
} else {
|
||||
nodeAffinity, err = k8sutil.GetOperatorSetting(clientset, controller.OperatorSettingConfigMapName, pluginNodeAffinityEnv, "")
|
||||
}
|
||||
func getNodeAffinity(clientset kubernetes.Interface, nodeAffinityName string, defaultNodeAffinity *corev1.NodeAffinity) *corev1.NodeAffinity {
|
||||
// Add NodeAffinity if any, otherwise return defaultNodeAffinity
|
||||
nodeAffinity, err := k8sutil.GetOperatorSetting(clientset, controller.OperatorSettingConfigMapName, nodeAffinityName, "")
|
||||
if err != nil {
|
||||
logger.Warningf("node affinity will not be applied. %v", err)
|
||||
// nodeAffinity will be empty by default in case of error
|
||||
return v1NodeAffinity
|
||||
logger.Warningf("failed to read %q. %v", nodeAffinityName, err)
|
||||
return defaultNodeAffinity
|
||||
}
|
||||
if nodeAffinity != "" {
|
||||
v1NodeAffinity, err = k8sutil.GenerateNodeAffinity(nodeAffinity)
|
||||
if err != nil {
|
||||
logger.Warningf("failed to parse %q. %v", nodeAffinity, err)
|
||||
}
|
||||
if nodeAffinity == "" {
|
||||
return defaultNodeAffinity
|
||||
}
|
||||
v1NodeAffinity, err := k8sutil.GenerateNodeAffinity(nodeAffinity)
|
||||
if err != nil {
|
||||
logger.Warningf("failed to parse %q for %q. %v", nodeAffinity, nodeAffinityName, err)
|
||||
return defaultNodeAffinity
|
||||
}
|
||||
return v1NodeAffinity
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user