Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Plugin Config Daemon node selector #484

Merged
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
7 changes: 4 additions & 3 deletions bindata/manifests/plugins/sriov-device-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ spec:
spec:
hostNetwork: true
nodeSelector:
kubernetes.io/os: linux
node-role.kubernetes.io/worker:
{{- range $key, $value := .NodeSelectorField }}
{{ $key }}: {{ $value }}
{{- end }}
tolerations:
- operator: Exists
serviceAccountName: sriov-device-plugin
Expand Down Expand Up @@ -70,7 +71,7 @@ spec:
hostPath:
path: /var/lib/kubelet/
- name: config-volume
configMap:
configMap:
name: device-plugin-config
- name: device-info
hostPath:
Expand Down
5 changes: 5 additions & 0 deletions controllers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ func formatJSON(str string) (string, error) {
}
return prettyJSON.String(), nil
}

func GetDefaultNodeSelector() map[string]string {
return map[string]string{"node-role.kubernetes.io/worker": "",
"kubernetes.io/os": "linux"}
}
1 change: 1 addition & 0 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Cont
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX")
data.Data["ImagePullSecrets"] = GetImagePullSecrets()
data.Data["NodeSelectorField"] = GetDefaultNodeSelector()
zeeke marked this conversation as resolved.
Show resolved Hide resolved

objs, err := renderDsForCR(constants.PluginPath, &data)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ func (r *SriovOperatorConfigReconciler) syncPluginDaemonSet(ctx context.Context,

names := []string{"sriov-cni", "sriov-device-plugin"}

if len(dc.Spec.ConfigDaemonNodeSelector) == 0 {
return nil
}
for _, name := range names {
err := r.Client.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, ds)
if err != nil {
Expand All @@ -166,7 +163,11 @@ func (r *SriovOperatorConfigReconciler) syncPluginDaemonSet(ctx context.Context,
logger.Error(err, "Couldn't get daemonset", "name", name)
return err
}
ds.Spec.Template.Spec.NodeSelector = dc.Spec.ConfigDaemonNodeSelector
if len(dc.Spec.ConfigDaemonNodeSelector) == 0 {
ds.Spec.Template.Spec.NodeSelector = GetDefaultNodeSelector()
} else {
ds.Spec.Template.Spec.NodeSelector = dc.Spec.ConfigDaemonNodeSelector
}
err = r.Client.Update(ctx, ds)
if err != nil {
logger.Error(err, "Couldn't update daemonset", "name", name)
Expand Down