From a75c748d834a8823ffd2da927ee61b3d171dcc7c Mon Sep 17 00:00:00 2001 From: Ivan Kolodiazhnyi Date: Thu, 2 Jan 2025 12:50:40 +0200 Subject: [PATCH] fix: Allow to deploy SR-IOV Device Plugin with SR-IOV Operator We need to allow to deploy two instances of device plugins to allow run SR-IOV Network Operatro and use HostDeviceNetwork at the same time. Signed-off-by: Ivan Kolodiazhnyi --- .../0010-sriov-dp-configmap.yaml | 2 +- .../0020-sriov-dp-service-account.yaml | 2 +- .../0021_role.openshift.yaml | 2 +- .../0022_rolebinding.openshift.yaml | 6 +++--- .../0030-sriov-dp-daemonset.yaml | 10 +++++----- pkg/state/state_sriov_dp_test.go | 12 ++++++------ 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/manifests/state-sriov-device-plugin/0010-sriov-dp-configmap.yaml b/manifests/state-sriov-device-plugin/0010-sriov-dp-configmap.yaml index 5d6633f7d..ac23ec81f 100644 --- a/manifests/state-sriov-device-plugin/0010-sriov-dp-configmap.yaml +++ b/manifests/state-sriov-device-plugin/0010-sriov-dp-configmap.yaml @@ -15,7 +15,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: sriovdp-config + name: network-operator-sriovdp-config namespace: {{ .RuntimeSpec.Namespace }} data: config.json: '{{ .CrSpec.Config }}' diff --git a/manifests/state-sriov-device-plugin/0020-sriov-dp-service-account.yaml b/manifests/state-sriov-device-plugin/0020-sriov-dp-service-account.yaml index 354b71de2..456d6a5ba 100644 --- a/manifests/state-sriov-device-plugin/0020-sriov-dp-service-account.yaml +++ b/manifests/state-sriov-device-plugin/0020-sriov-dp-service-account.yaml @@ -14,5 +14,5 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: sriov-device-plugin + name: network-operator-sriov-device-plugin namespace: {{ .RuntimeSpec.Namespace }} diff --git a/manifests/state-sriov-device-plugin/0021_role.openshift.yaml b/manifests/state-sriov-device-plugin/0021_role.openshift.yaml index d76c99ea4..ba6e4b7c4 100644 --- a/manifests/state-sriov-device-plugin/0021_role.openshift.yaml +++ b/manifests/state-sriov-device-plugin/0021_role.openshift.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - name: sriov-device-plugin + name: network-operator-sriov-device-plugin namespace: {{ .RuntimeSpec.Namespace }} rules: - apiGroups: diff --git a/manifests/state-sriov-device-plugin/0022_rolebinding.openshift.yaml b/manifests/state-sriov-device-plugin/0022_rolebinding.openshift.yaml index 2a910c3bf..7053d6889 100644 --- a/manifests/state-sriov-device-plugin/0022_rolebinding.openshift.yaml +++ b/manifests/state-sriov-device-plugin/0022_rolebinding.openshift.yaml @@ -2,13 +2,13 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: sriov-device-plugin + name: network-operator-sriov-device-plugin namespace: {{ .RuntimeSpec.Namespace }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: sriov-device-plugin + name: network-operator-sriov-device-plugin subjects: - kind: ServiceAccount - name: sriov-device-plugin + name: network-operator-sriov-device-plugin {{end}} diff --git a/manifests/state-sriov-device-plugin/0030-sriov-dp-daemonset.yaml b/manifests/state-sriov-device-plugin/0030-sriov-dp-daemonset.yaml index 7d4d5d399..2a7378f01 100644 --- a/manifests/state-sriov-device-plugin/0030-sriov-dp-daemonset.yaml +++ b/manifests/state-sriov-device-plugin/0030-sriov-dp-daemonset.yaml @@ -14,7 +14,7 @@ apiVersion: apps/v1 kind: DaemonSet metadata: - name: sriov-device-plugin + name: network-operator-sriov-device-plugin namespace: {{ .RuntimeSpec.Namespace }} labels: tier: node @@ -22,11 +22,11 @@ metadata: spec: selector: matchLabels: - name: sriov-device-plugin + name: network-operator-sriov-device-plugin template: metadata: labels: - name: sriov-device-plugin + name: network-operator-sriov-device-plugin tier: node app: sriovdp spec: @@ -47,7 +47,7 @@ spec: - key: nvidia.com/gpu operator: Exists effect: NoSchedule - serviceAccountName: sriov-device-plugin + serviceAccountName: network-operator-sriov-device-plugin {{- if .CrSpec.ImagePullSecrets }} imagePullSecrets: {{- range .CrSpec.ImagePullSecrets }} @@ -122,7 +122,7 @@ spec: type: DirectoryOrCreate - name: config-volume configMap: - name: sriovdp-config + name: network-operator-sriovdp-config items: - key: config.json path: config.json diff --git a/pkg/state/state_sriov_dp_test.go b/pkg/state/state_sriov_dp_test.go index 281909017..770775bf6 100644 --- a/pkg/state/state_sriov_dp_test.go +++ b/pkg/state/state_sriov_dp_test.go @@ -53,7 +53,7 @@ var _ = Describe("SR-IOV Device Plugin State tests", func() { By("Verify DaemonSet") ds := &appsv1.DaemonSet{} err = ts.client.Get(context.Background(), types.NamespacedName{Namespace: ts.namespace, - Name: "sriov-device-plugin"}, ds) + Name: "network-operator-sriov-device-plugin"}, ds) Expect(err).NotTo(HaveOccurred()) assertCommonDaemonSetFields(ds, &cr.Spec.SriovDevicePlugin.ImageSpec, cr) // expect privileged mode @@ -70,7 +70,7 @@ var _ = Describe("SR-IOV Device Plugin State tests", func() { By("Verify DaemonSet") ds := &appsv1.DaemonSet{} err = ts.client.Get(context.Background(), types.NamespacedName{Namespace: ts.namespace, - Name: "sriov-device-plugin"}, ds) + Name: "network-operator-sriov-device-plugin"}, ds) Expect(err).NotTo(HaveOccurred()) assertCommonDaemonSetFields(ds, &cr.Spec.SriovDevicePlugin.ImageSpec, cr) // expect privileged mode @@ -90,7 +90,7 @@ var _ = Describe("SR-IOV Device Plugin State tests", func() { By("Verify DaemonSet") ds := &appsv1.DaemonSet{} err = ts.client.Get(context.Background(), types.NamespacedName{Namespace: ts.namespace, - Name: "sriov-device-plugin"}, ds) + Name: "network-operator-sriov-device-plugin"}, ds) Expect(err).NotTo(HaveOccurred()) assertCommonDaemonSetFields(ds, &cr.Spec.SriovDevicePlugin.ImageSpec, cr) assertSriovDpPodTemplatesVolumeFields(&ds.Spec.Template, false) @@ -121,7 +121,7 @@ var _ = Describe("SR-IOV Device Plugin State tests", func() { By("Verify DaemonSet") ds := &appsv1.DaemonSet{} err = ts.client.Get(context.Background(), types.NamespacedName{Namespace: ts.namespace, - Name: "sriov-device-plugin"}, ds) + Name: "network-operator-sriov-device-plugin"}, ds) Expect(err).NotTo(HaveOccurred()) assertCommonDaemonSetFields(ds, &cr.Spec.SriovDevicePlugin.ImageSpec, cr) assertSriovDpPodTemplatesVolumeFields(&ds.Spec.Template, false) @@ -134,7 +134,7 @@ var _ = Describe("SR-IOV Device Plugin State tests", func() { By("Verify DaemonSet is deleted") ds = &appsv1.DaemonSet{} err = ts.client.Get(context.Background(), types.NamespacedName{Namespace: ts.namespace, - Name: "sriov-device-plugin"}, ds) + Name: "network-operator-sriov-device-plugin"}, ds) Expect(errors.IsNotFound(err)).To(BeTrue()) }) }) @@ -196,7 +196,7 @@ func assertSriovDpPodTemplatesVolumeFields(tpl *v1.PodTemplateSpec, useCdi bool) VolumeSource: v1.VolumeSource{ ConfigMap: &v1.ConfigMapVolumeSource{ LocalObjectReference: v1.LocalObjectReference{ - Name: "sriovdp-config", + Name: "network-operator-sriovdp-config", }, Items: []v1.KeyToPath{ {