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 21, 2024
1 parent d4922f0 commit 26df20f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 18 deletions.
41 changes: 32 additions & 9 deletions build/yamls/antrea-windows-with-ovs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
apiVersion: v1
data:
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"
}
}
Install-WindowsCNI-Containerd.ps1: |
$ErrorActionPreference = "Stop";
mkdir -force c:/var/log/antrea
Expand Down Expand Up @@ -45,14 +64,7 @@ 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 Down Expand Up @@ -293,7 +305,7 @@ spec:
template:
metadata:
annotations:
checksum/agent-windows: bb43d8d5840ffd71ff946d44052fefc5bd88ca5ad58ac5048d85a5cf26a7ef13
checksum/agent-windows: 8c254572ffa923c76be75d5d6b235a82e65d3e0da4a4ce969dac0bbcababa3c4
checksum/windows-config: 6ff4f8bd0b310ebe4d4612bdd9697ffb3d79e0e0eab3936420417dd5a8fc128d
microsoft.com/hostprocess-inherit-user: "true"
labels:
Expand Down Expand Up @@ -376,6 +388,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ $ErrorActionPreference = "Stop"
$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 Down
12 changes: 12 additions & 0 deletions build/yamls/windows/containerd-with-ovs/containerd-with-ovs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,15 @@ spec:
- mountPath: /var/log/openvswitch
name: var-log-antrea
subPath: openvswitch
initContainers:
- 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
1 change: 1 addition & 0 deletions build/yamls/windows/containerd-with-ovs/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ commonLabels:
app: antrea
configMapGenerator:
- files:
- conf/Install-OVSDriver-Containerd.ps1
- conf/Run-AntreaOVS-Containerd.ps1
- conf/VMSwitchExtension-AntreaAgent-Containerd.ps1
name: antrea-agent-windows
Expand Down
3 changes: 2 additions & 1 deletion hack/update-checksum-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ BASE_CONF_FILES="${WINDOWS_DIR}/base/conf/antrea-agent.conf ${WINDOWS_DIR}/base/
CONTAINERD_CONF_FILES="${WINDOWS_DIR}/containerd/conf/Install-WindowsCNI-Containerd.ps1 \
${WINDOWS_DIR}/containerd/conf/Run-AntreaAgent-Containerd.ps1"
CONTAINERD_WITH_OVS_CONF_FILES="${WINDOWS_DIR}/containerd-with-ovs/conf/Run-AntreaOVS-Containerd.ps1 \
${WINDOWS_DIR}/containerd-with-ovs/conf/VMSwitchExtension-AntreaAgent-Containerd.ps1"
${WINDOWS_DIR}/containerd-with-ovs/conf/VMSwitchExtension-AntreaAgent-Containerd.ps1 \
${WINDOWS_DIR}/containerd-with-ovs/conf/Install-OVSDriver-Containerd.ps1"

checksum_windows_config=$(cat ${BASE_CONF_FILES} | sha256sum | cut -d " " -f 1)

Expand Down

0 comments on commit 26df20f

Please sign in to comment.