From 4b3a309a38d419a86dc7edb0a1bbb78fb13f71ac Mon Sep 17 00:00:00 2001 From: Yury Kulazhenkov Date: Thu, 7 Mar 2024 12:16:18 +0200 Subject: [PATCH] Add logic to deploy OVS-cni If OVS_CNI_IMAGE env variable is set to empty string, then deployment of the CNI will be skipped Signed-off-by: Yury Kulazhenkov --- bindata/manifests/daemon/daemonset.yaml | 22 +++++++++++++++++++ controllers/sriovoperatorconfig_controller.go | 1 + controllers/suite_test.go | 2 ++ deploy/operator.yaml | 2 ++ deployment/sriov-network-operator/README.md | 1 + .../templates/operator.yaml | 2 ++ deployment/sriov-network-operator/values.yaml | 1 + hack/env.sh | 4 ++++ hack/run-e2e-test.sh | 1 + 9 files changed, 36 insertions(+) diff --git a/bindata/manifests/daemon/daemonset.yaml b/bindata/manifests/daemon/daemonset.yaml index 8fc58806c..b5126ae28 100644 --- a/bindata/manifests/daemon/daemonset.yaml +++ b/bindata/manifests/daemon/daemonset.yaml @@ -70,6 +70,28 @@ spec: - name: os-release mountPath: /host/etc/os-release readOnly: true + {{- if .OVSCNIImage }} + - name: ovs-cni + image: {{.OVSCNIImage}} + command: ["/bin/sh","-c"] + args: + - > + cp /ovs /host/opt/cni/bin/ovs && + cp /ovs-mirror-producer /host/opt/cni/bin/ovs-mirror-producer && + cp /ovs-mirror-consumer /host/opt/cni/bin/ovs-mirror-consumer + securityContext: + privileged: true + resources: + requests: + cpu: 10m + memory: 10Mi + volumeMounts: + - name: cnibin + mountPath: /host/opt/cni/bin + - name: os-release + mountPath: /host/etc/os-release + readOnly: true + {{- end }} {{- if .UsedSystemdMode}} - name: sriov-service-copy image: {{.Image}} diff --git a/controllers/sriovoperatorconfig_controller.go b/controllers/sriovoperatorconfig_controller.go index dcf13c46a..13f87bb72 100644 --- a/controllers/sriovoperatorconfig_controller.go +++ b/controllers/sriovoperatorconfig_controller.go @@ -162,6 +162,7 @@ func (r *SriovOperatorConfigReconciler) syncConfigDaemonSet(ctx context.Context, data.Data["Namespace"] = vars.Namespace data.Data["SRIOVCNIImage"] = os.Getenv("SRIOV_CNI_IMAGE") data.Data["SRIOVInfiniBandCNIImage"] = os.Getenv("SRIOV_INFINIBAND_CNI_IMAGE") + data.Data["OVSCNIImage"] = os.Getenv("OVS_CNI_IMAGE") data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION") data.Data["ClusterType"] = vars.ClusterType data.Data["DevMode"] = os.Getenv("DEV_MODE") diff --git a/controllers/suite_test.go b/controllers/suite_test.go index bc5870f34..4f42b687c 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -109,6 +109,8 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) err = os.Setenv("SRIOV_INFINIBAND_CNI_IMAGE", "mock-image") Expect(err).NotTo(HaveOccurred()) + err = os.Setenv("OVS_CNI_IMAGE", "mock-image") + Expect(err).NotTo(HaveOccurred()) err = os.Setenv("SRIOV_DEVICE_PLUGIN_IMAGE", "mock-image") Expect(err).NotTo(HaveOccurred()) err = os.Setenv("NETWORK_RESOURCES_INJECTOR_IMAGE", "mock-image") diff --git a/deploy/operator.yaml b/deploy/operator.yaml index 069f2eff1..8d9f88cf2 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -54,6 +54,8 @@ spec: value: $SRIOV_CNI_IMAGE - name: SRIOV_INFINIBAND_CNI_IMAGE value: $SRIOV_INFINIBAND_CNI_IMAGE + - name: OVS_CNI_IMAGE + value: $OVS_CNI_IMAGE - name: SRIOV_DEVICE_PLUGIN_IMAGE value: $SRIOV_DEVICE_PLUGIN_IMAGE - name: NETWORK_RESOURCES_INJECTOR_IMAGE diff --git a/deployment/sriov-network-operator/README.md b/deployment/sriov-network-operator/README.md index b2a57c418..9cabcee74 100644 --- a/deployment/sriov-network-operator/README.md +++ b/deployment/sriov-network-operator/README.md @@ -124,6 +124,7 @@ This section contains general parameters that apply to both the operator and dae | `images.sriovConfigDaemon` | Daemon node agent image | | `images.sriovCni` | SR-IOV CNI image | | `images.ibSriovCni` | InfiniBand SR-IOV CNI image | +| `images.ovsCni` | OVS CNI image | | `images.sriovDevicePlugin` | SR-IOV device plugin image | | `images.resourcesInjector` | Resources Injector image | | `images.webhook` | Operator Webhook image | diff --git a/deployment/sriov-network-operator/templates/operator.yaml b/deployment/sriov-network-operator/templates/operator.yaml index d3fea3d1c..1200e34ac 100644 --- a/deployment/sriov-network-operator/templates/operator.yaml +++ b/deployment/sriov-network-operator/templates/operator.yaml @@ -56,6 +56,8 @@ spec: value: {{ .Values.images.sriovCni }} - name: SRIOV_INFINIBAND_CNI_IMAGE value: {{ .Values.images.ibSriovCni }} + - name: OVS_CNI_IMAGE + value: {{ .Values.images.ovsCni }} - name: SRIOV_DEVICE_PLUGIN_IMAGE value: {{ .Values.images.sriovDevicePlugin }} - name: NETWORK_RESOURCES_INJECTOR_IMAGE diff --git a/deployment/sriov-network-operator/values.yaml b/deployment/sriov-network-operator/values.yaml index 81b3d1172..0799b35ea 100644 --- a/deployment/sriov-network-operator/values.yaml +++ b/deployment/sriov-network-operator/values.yaml @@ -95,6 +95,7 @@ images: sriovConfigDaemon: ghcr.io/k8snetworkplumbingwg/sriov-network-operator-config-daemon sriovCni: ghcr.io/k8snetworkplumbingwg/sriov-cni ibSriovCni: ghcr.io/k8snetworkplumbingwg/ib-sriov-cni + ovsCni: quay.io/kubevirt/ovs-cni-plugin sriovDevicePlugin: ghcr.io/k8snetworkplumbingwg/sriov-network-device-plugin resourcesInjector: ghcr.io/k8snetworkplumbingwg/network-resources-injector webhook: ghcr.io/k8snetworkplumbingwg/sriov-network-operator-webhook diff --git a/hack/env.sh b/hack/env.sh index 1dccb157e..eede3a1e5 100755 --- a/hack/env.sh +++ b/hack/env.sh @@ -1,6 +1,8 @@ if [ -z $SKIP_VAR_SET ]; then export SRIOV_CNI_IMAGE=${SRIOV_CNI_IMAGE:-ghcr.io/k8snetworkplumbingwg/sriov-cni} export SRIOV_INFINIBAND_CNI_IMAGE=${SRIOV_INFINIBAND_CNI_IMAGE:-ghcr.io/k8snetworkplumbingwg/ib-sriov-cni} + # OVS_CNI_IMAGE can be explicitly set to empty value, use default only if the var is not set + export OVS_CNI_IMAGE=${OVS_CNI_IMAGE-quay.io/kubevirt/ovs-cni-plugin} export SRIOV_DEVICE_PLUGIN_IMAGE=${SRIOV_DEVICE_PLUGIN_IMAGE:-ghcr.io/k8snetworkplumbingwg/sriov-network-device-plugin} export NETWORK_RESOURCES_INJECTOR_IMAGE=${NETWORK_RESOURCES_INJECTOR_IMAGE:-ghcr.io/k8snetworkplumbingwg/network-resources-injector} export SRIOV_NETWORK_CONFIG_DAEMON_IMAGE=${SRIOV_NETWORK_CONFIG_DAEMON_IMAGE:-ghcr.io/k8snetworkplumbingwg/sriov-network-operator-config-daemon} @@ -9,6 +11,8 @@ if [ -z $SKIP_VAR_SET ]; then else [ -z $SRIOV_CNI_IMAGE ] && echo "SRIOV_CNI_IMAGE is empty but SKIP_VAR_SET is set" && exit 1 [ -z $SRIOV_INFINIBAND_CNI_IMAGE ] && echo "SRIOV_INFINIBAND_CNI_IMAGE is empty but SKIP_VAR_SET is set" && exit 1 + # check that OVS_CNI_IMAGE is set to any value, empty string is a valid value + [ -z ${OVS_CNI_IMAGE+set} ] && echo "OVS_CNI_IMAGE is empty but SKIP_VAR_SET is set" && exit 1 [ -z $SRIOV_DEVICE_PLUGIN_IMAGE ] && echo "SRIOV_DEVICE_PLUGIN_IMAGE is empty but SKIP_VAR_SET is set" && exit 1 [ -z $NETWORK_RESOURCES_INJECTOR_IMAGE ] && echo "NETWORK_RESOURCES_INJECTOR_IMAGE is empty but SKIP_VAR_SET is set" && exit 1 [ -z $SRIOV_NETWORK_CONFIG_DAEMON_IMAGE ] && echo "SRIOV_NETWORK_CONFIG_DAEMON_IMAGE is empty but SKIP_VAR_SET is set" && exit 1 diff --git a/hack/run-e2e-test.sh b/hack/run-e2e-test.sh index 24cfc934a..df25b87e6 100755 --- a/hack/run-e2e-test.sh +++ b/hack/run-e2e-test.sh @@ -7,6 +7,7 @@ KUBECONFIG=${KUBECONFIG:-/root/env/ign/auth/kubeconfig} echo ${SRIOV_CNI_IMAGE} echo ${SRIOV_INFINIBAND_CNI_IMAGE} +echo ${OVS_CNI_IMAGE} echo ${SRIOV_DEVICE_PLUGIN_IMAGE} echo ${NETWORK_RESOURCES_INJECTOR_IMAGE} echo ${SRIOV_NETWORK_CONFIG_DAEMON_IMAGE}