Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

rook ceph: Add CSI plugin affinity & toleration attribute #892

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configuration-reference/components/rook.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Example:
| `discover_toleration_key` | Toleration key for the rook discover pods. | - | string | false |
| `discover_toleration_effect` | Toleration effect for the rook discover pods. Needs to be specified if `discover_toleration_key` is set. | - | string | false |
| `enable_monitoring` | Enable Monitoring for the Rook sub-systems. Make sure that the Prometheus Operator is installed. | false | bool | false |
| `csi_plugin_node_selector` | A map with specific labels to install Rook CSI plugins on a group of nodes. | - | map(string) | false |
| `csi_plugin_toleration` | Tolerations that the Rook CSI plugin installation pods will tolerate. | - | list(object({key = string, effect = string, operator = string, value = string, toleration_seconds = string })) | false |


## Applying
Expand Down
20 changes: 15 additions & 5 deletions pkg/components/rook/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ type component struct {
RookNodeAffinity string
Tolerations []util.Toleration `hcl:"toleration,block"`
TolerationsRaw string
AgentTolerationKey string `hcl:"agent_toleration_key,optional"`
AgentTolerationEffect string `hcl:"agent_toleration_effect,optional"`
DiscoverTolerationKey string `hcl:"discover_toleration_key,optional"`
DiscoverTolerationEffect string `hcl:"discover_toleration_effect,optional"`
EnableMonitoring bool `hcl:"enable_monitoring,optional"`
AgentTolerationKey string `hcl:"agent_toleration_key,optional"`
AgentTolerationEffect string `hcl:"agent_toleration_effect,optional"`
DiscoverTolerationKey string `hcl:"discover_toleration_key,optional"`
DiscoverTolerationEffect string `hcl:"discover_toleration_effect,optional"`
EnableMonitoring bool `hcl:"enable_monitoring,optional"`
CSIPluginNodeSelector util.NodeSelector `hcl:"csi_plugin_node_selector,optional"`
CSIPluginNodeAffinity string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not CSIPluginNodeSelectorRaw?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By tacit convention *Raw has been for those that can simply be converted from it's hcl (json) form to the yaml and provided as it is. But *NodeAffinity is a rook's format of specifying the selector like this: key1=value1; key2=value2;.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would still be fine as Raw is sort of template-ready format, but I'm fine with it as it is 👍

CSIPluginTolerations []util.Toleration `hcl:"csi_plugin_toleration,block"`
CSIPluginTolerationsRaw string
}

func newComponent() *component {
Expand Down Expand Up @@ -71,12 +75,18 @@ func (c *component) RenderManifests() (map[string]string, error) {
return nil, fmt.Errorf("rendering tolerations failed: %w", err)
}

c.CSIPluginTolerationsRaw, err = util.RenderTolerations(c.CSIPluginTolerations)
if err != nil {
return nil, fmt.Errorf("rendering CSI tolerations failed: %w", err)
}

c.NodeSelectorRaw, err = c.NodeSelector.Render()
if err != nil {
return nil, fmt.Errorf("rendering node selector failed: %w", err)
}

c.RookNodeAffinity = convertNodeSelector(c.NodeSelector)
c.CSIPluginNodeAffinity = convertNodeSelector(c.CSIPluginNodeSelector)

values, err := template.Render(chartValuesTmpl, c)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/components/rook/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ csi:
provisionerNodeAffinity: {{ .RookNodeAffinity }}
{{- end }}

{{- if .Tolerations }}
pluginTolerations: {{ .TolerationsRaw }}
{{- if .CSIPluginTolerations }}
pluginTolerations: {{ .CSIPluginTolerationsRaw }}
{{- end }}
{{- if .NodeSelector }}
pluginNodeAffinity: {{ .RookNodeAffinity }}
{{- if .CSIPluginNodeSelector }}
pluginNodeAffinity: {{ .CSIPluginNodeAffinity }}
{{- end }}

agent:
Expand Down