forked from antrea-io/antrea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to run Windows OVS in container
For antrea-io#4952 Signed-off-by: Shuyang Xin <[email protected]> Signed-off-by: Naman Agarwal <[email protected]> Signed-off-by: Kumar Atish <[email protected]>
- Loading branch information
Showing
18 changed files
with
671 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
configMapGenerator: | ||
- files: | ||
- conf/Install-WindowsCNI-Containerd.ps1 | ||
name: antrea-agent-windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
build/yamls/windows/ovs-containerd/conf/PostStart-AntreaAgent-Containerd.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
$networkName = "antrea-hnsnetwork" | ||
$networks = Get-HnsNetwork | ||
$networkExists = $false | ||
foreach ($network in $networks) { | ||
if ($network.Name -eq $networkName) { | ||
$networkExists = $true | ||
break | ||
} | ||
} | ||
if ($networkExists) { | ||
Enable-VMSwitchExtension -Name "Open vSwitch Extension" -VMSwitchName "antrea-hnsnetwork" | ||
} |
5 changes: 5 additions & 0 deletions
5
build/yamls/windows/ovs-containerd/conf/Run-AntreaAgent-OVS-Containerd.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$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" | ||
& "$mountPath/k/antrea/bin/antrea-agent.exe" --config=$mountPath/etc/antrea/antrea-agent.conf --logtostderr=false --log_dir=c:/var/log/antrea --alsologtostderr --log_file_max_size=100 --log_file_max_num=4 --v=0 |
31 changes: 31 additions & 0 deletions
31
build/yamls/windows/ovs-containerd/conf/Run-AntreaOVS-Containerd.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
$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" | ||
$OVS_DB_SCHEMA_PATH = "$mountPath/openvswitch/usr/share/openvswitch/vswitch.ovsschema" | ||
$OVS_DB_PATH = "C:\openvswitch\etc\openvswitch\conf.db" | ||
if ($(Test-Path $OVS_DB_SCHEMA_PATH) -and !$(Test-Path $OVS_DB_PATH)) { | ||
ovsdb-tool create "$OVS_DB_PATH" "$OVS_DB_SCHEMA_PATH" | ||
} | ||
ovsdb-server $OVS_DB_PATH -vfile:info --remote=punix:db.sock --log-file=/var/log/antrea/openvswitch/ovsdb-server.log --pidfile --detach | ||
ovs-vsctl --no-wait init | ||
|
||
# Set OVS version. | ||
$OVS_VERSION=$(Get-Item $mountPath\openvswitch\driver\OVSExt.sys).VersionInfo.ProductVersion | ||
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 | ||
|
||
$SleepInterval = 30 | ||
Write-Host "Started the loop that checks OVS status every $SleepInterval seconds" | ||
while ($true) { | ||
if ( !( Get-Process ovsdb-server ) ) { | ||
Write-Host "ovsdb-server is not running, starting it again..." | ||
ovsdb-server $OVS_DB_PATH -vfile:info --remote=punix:db.sock --log-file=/var/log/antrea/openvswitch/ovsdb-server.log --pidfile --detach | ||
} | ||
if ( !( Get-Process ovs-vswitchd ) ) { | ||
Write-Host "ovs-vswitchd is not running, starting it again..." | ||
ovs-vswitchd --log-file=/var/log/antrea/openvswitch/ovs-vswitchd.log --pidfile -vfile:info --detach | ||
} | ||
Start-Sleep -Seconds $SleepInterval | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ovs-containerd.yml | ||
- ../base | ||
- ../base-containerd | ||
namespace: kube-system | ||
commonLabels: | ||
app: antrea | ||
configMapGenerator: | ||
- files: | ||
- conf/Run-AntreaOVS-Containerd.ps1 | ||
- conf/Run-AntreaAgent-OVS-Containerd.ps1 | ||
- conf/PostStart-AntreaAgent-Containerd.ps1 | ||
name: antrea-agent-windows | ||
behavior: merge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
labels: | ||
component: antrea-agent | ||
name: antrea-agent-windows | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: antrea-agent | ||
template: | ||
metadata: | ||
annotations: | ||
"microsoft.com/hostprocess-inherit-user": "true" | ||
labels: | ||
component: antrea-agent | ||
spec: | ||
securityContext: | ||
windowsOptions: | ||
runAsUserName: "NT AUTHORITY\\SYSTEM" | ||
hostProcess: true | ||
containers: | ||
- name: antrea-agent | ||
image: katish9/antrea-windows:latest | ||
imagePullPolicy: IfNotPresent | ||
lifecycle: | ||
preStop: | ||
exec: | ||
command: ["powershell", "Disable-VMSwitchExtension -Name 'Open vSwitch Extension' -VMSwitchName antrea-hnsnetwork"] | ||
postStart: | ||
exec: | ||
command: ["powershell", "-file", "$env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/PostStart-AntreaAgent-Containerd.ps1"] | ||
args: | ||
- -file | ||
- $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Run-AntreaAgent-OVS-Containerd.ps1 | ||
command: | ||
- powershell | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
volumeMounts: | ||
- mountPath: /etc/antrea | ||
name: antrea-windows-config | ||
- mountPath: /var/lib/antrea-windows | ||
name: antrea-agent-windows | ||
- mountPath: /var/log/antrea/ | ||
name: var-log-antrea | ||
- name: antrea-ovs | ||
image: antrea/windows-ovs:1809-3.0.5 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- -file | ||
- $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Run-AntreaOVS-Containerd.ps1 | ||
command: | ||
- powershell | ||
volumeMounts: | ||
- mountPath: /var/lib/antrea-windows | ||
name: antrea-agent-windows | ||
- mountPath: /var/log/openvswitch | ||
name: var-log-antrea | ||
subPath: openvswitch | ||
hostNetwork: true | ||
initContainers: | ||
- args: | ||
- -file | ||
- $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Install-WindowsCNI-Containerd.ps1 | ||
command: | ||
- powershell | ||
image: antrea-windows | ||
imagePullPolicy: IfNotPresent | ||
name: install-cni | ||
volumeMounts: | ||
- mountPath: /etc/antrea | ||
name: antrea-windows-config | ||
readOnly: true | ||
- mountPath: /var/lib/antrea-windows | ||
name: antrea-agent-windows | ||
nodeSelector: | ||
kubernetes.io/os: windows | ||
priorityClassName: system-node-critical | ||
serviceAccountName: antrea-agent | ||
tolerations: | ||
- key: CriticalAddonsOnly | ||
operator: Exists | ||
- effect: NoSchedule | ||
operator: Exists | ||
volumes: | ||
- configMap: | ||
name: antrea-windows-config | ||
name: antrea-windows-config | ||
- configMap: | ||
defaultMode: 420 | ||
name: antrea-agent-windows | ||
name: antrea-agent-windows | ||
- hostPath: | ||
path: /var/log/antrea/ | ||
type: DirectoryOrCreate | ||
name: var-log-antrea | ||
updateStrategy: | ||
type: RollingUpdate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.