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 <gavinx@vmware.com>
  • Loading branch information
XinShuYang committed May 15, 2024
1 parent d4922f0 commit b1a43c8
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,26 @@ 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
$result = netcfg -l $OVSDriverDir/ovsext.inf -c s -i OVSExt
if ($result -like '*failed*') {
Write-Host "Failed to install OVSExt driver: $result"
exit 1
} else {
Write-Host "OVSExt driver has been installed"
}
}
Run-AntreaAgent-Containerd.ps1: |
$ErrorActionPreference = "Stop"
$mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT
Expand All @@ -45,14 +65,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"
Expand All @@ -70,6 +84,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
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 b1a43c8

Please sign in to comment.