From a917c55d51331b4c98f4bb138253f82f01396efc Mon Sep 17 00:00:00 2001 From: Shuyang Xin Date: Thu, 9 May 2024 23:50:49 +0800 Subject: [PATCH] Add OVS driver installation in initContainer for Antrea Windows agent By integrating the OVS driver installation into an initContainer, we ensure that the necessary driver is installed before the main containers start, and the driver's presence is checked only once during the pod's lifecycle. Signed-off-by: Shuyang Xin --- build/yamls/antrea-windows-with-ovs.yml | 34 ++++++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/build/yamls/antrea-windows-with-ovs.yml b/build/yamls/antrea-windows-with-ovs.yml index ffc1e1bb0dd..370f7099350 100644 --- a/build/yamls/antrea-windows-with-ovs.yml +++ b/build/yamls/antrea-windows-with-ovs.yml @@ -34,6 +34,20 @@ data: cp $mountPath/etc/antrea/antrea-cni.conflist c:/etc/cni/net.d/10-antrea.conflist mkdir -force c:/k/antrea/bin cp $mountPath/k/antrea/bin/antctl.exe c:/k/antrea/bin/antctl.exe + Install-OVSDriver-Containerd.ps1: | + $ErrorActionPreference = "Stop" + mkdir -force c:/openvswitch/driver + $mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT + $mountPath = ($mountPath.Replace('\', '/')).TrimEnd('/') + $OVSDriverDir = "$mountPath\openvswitch\driver" + + # Check if OVSExt driver is already installed + $driverStatus = netcfg -q ovsext + if ($driverStatus -like '*not installed*') { + # Install OVS Driver + netcfg -l $OVSDriverDir/ovsext.inf -c s -i OVSExt + } + Run-AntreaAgent-Containerd.ps1: | $ErrorActionPreference = "Stop" $mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT @@ -45,14 +59,8 @@ data: $mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT $mountPath = ($mountPath.Replace('\', '/')).TrimEnd('/') $env:PATH = $env:PATH + ";$mountPath/Windows/System32;$mountPath/openvswitch/usr/bin;$mountPath/openvswitch/usr/sbin" - $OVSDriverDir="$mountPath\openvswitch\driver" - # Check if OVSExt driver is already installed - $driverStatus = netcfg -q ovsext - if ($driverStatus -like '*not installed*') { - # Install OVS Driver - netcfg -l $OVSDriverDir/ovsext.inf -c s -i OVSExt - } + $OVSDriverDir = "$mountPath\openvswitch\driver" # Configure OVS processes $OVS_DB_SCHEMA_PATH = "$mountPath/openvswitch/usr/share/openvswitch/vswitch.ovsschema" @@ -70,6 +78,7 @@ data: # Set OVS version. $OVS_VERSION=$(Get-Item $OVSDriverDir\OVSExt.sys).VersionInfo.ProductVersion + rm -r $OVSDriverDir ovs-vsctl --no-wait set Open_vSwitch . ovs_version=$OVS_VERSION ovs-vswitchd --log-file=/var/log/antrea/openvswitch/ovs-vswitchd.log --pidfile -vfile:info --detach @@ -376,6 +385,17 @@ spec: readOnly: true - mountPath: /var/lib/antrea-windows name: antrea-agent-windows + - args: + - -file + - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Install-OVSDriver-Containerd.ps1 + command: + - powershell + image: antrea/antrea-windows:latest + imagePullPolicy: IfNotPresent + name: install-ovs-driver + volumeMounts: + - mountPath: /var/lib/antrea-windows + name: antrea-agent-windows nodeSelector: kubernetes.io/os: windows priorityClassName: system-node-critical