Skip to content

Commit

Permalink
Add OVS driver installation in initContainer for Antrea Windows agent
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
XinShuYang committed May 11, 2024
1 parent d4922f0 commit 2383ee1
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions build/yamls/antrea-windows-with-ovs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ 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"
$localDriver = "C:/openvswitch/driver/OVSExt.sys"
$driverPath = "$OVSDriverDir/OVSExt.sys"
# 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
}
Copy-Item -Path $driverPath -Destination $localDriver -Force
Run-AntreaAgent-Containerd.ps1: |
$ErrorActionPreference = "Stop"
$mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT
Expand All @@ -45,14 +62,12 @@ 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
}
# Update Ovs Driver
$OVSDriverDir = "$mountPath\openvswitch\driver"
$localDriver = "C:/openvswitch/driver/OVSExt.sys"
$driverPath = "$OVSDriverDir/OVSExt.sys"
Copy-Item -Path $localDriver -Destination $driverPath -Force
# Configure OVS processes
$OVS_DB_SCHEMA_PATH = "$mountPath/openvswitch/usr/share/openvswitch/vswitch.ovsschema"
Expand Down Expand Up @@ -376,6 +391,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
Expand Down

0 comments on commit 2383ee1

Please sign in to comment.