From 6fce4e82741e00f23f5cb67bfec537d2a0c99905 Mon Sep 17 00:00:00 2001 From: Shikhar Soni <139053348+shikharish@users.noreply.github.com> Date: Wed, 12 Jun 2024 00:18:00 +0530 Subject: [PATCH] Use Helm to generate Antrea Windows manifests (#6360) Instead of Kustomize. This matches what we do for the Linux manifests. This change is only for manifest generation. We are not currently exposing the Helm chart to users. This could be done at a later time. Fixes #5564 Signed-off-by: Shikhar Soni --- Makefile | 1 - build/charts/antrea-windows/.helmignore | 23 +++ build/charts/antrea-windows/Chart.yaml | 25 +++ build/charts/antrea-windows/README.md | 25 +++ .../conf/Install-WindowsCNI.ps1 | 0 .../antrea-windows}/conf/Run-AntreaAgent.ps1 | 0 .../antrea-windows}/conf/antrea-agent.conf | 0 .../antrea-windows}/conf/antrea-cni.conflist | 0 .../conf/ovs}/Install-OVSDriver.ps1 | 0 .../conf/ovs}/Run-AntreaOVS.ps1 | 0 .../ovs}/VMSwitchExtension-AntreaAgent.ps1 | 0 .../configmaps/antrea-agent-windows.yaml | 15 ++ .../configmaps/antrea-windows-config.yaml | 10 ++ .../antrea-windows/templates/daemonset.yaml | 143 ++++++++++++++++++ build/charts/antrea-windows/values.yaml | 7 + build/yamls/antrea-windows-with-ovs.yml | 84 +++++----- build/yamls/antrea-windows.yml | 8 +- build/yamls/windows/base/kustomization.yml | 9 -- .../containerd-with-ovs.yml | 42 ----- .../containerd-with-ovs/kustomization.yml | 18 --- .../windows/containerd/agent-containerd.yml | 89 ----------- .../windows/containerd/kustomization.yml | 15 -- .../windows/patches/dev/imagePullPolicy.yml | 13 -- .../yamls/windows/patches/release/.gitignore | 1 - hack/generate-manifest-windows.sh | 72 ++++----- hack/update-checksum-windows.sh | 41 ----- 26 files changed, 325 insertions(+), 316 deletions(-) create mode 100644 build/charts/antrea-windows/.helmignore create mode 100644 build/charts/antrea-windows/Chart.yaml create mode 100644 build/charts/antrea-windows/README.md rename build/{yamls/windows/containerd => charts/antrea-windows}/conf/Install-WindowsCNI.ps1 (100%) rename build/{yamls/windows/containerd => charts/antrea-windows}/conf/Run-AntreaAgent.ps1 (100%) rename build/{yamls/windows/base => charts/antrea-windows}/conf/antrea-agent.conf (100%) rename build/{yamls/windows/base => charts/antrea-windows}/conf/antrea-cni.conflist (100%) rename build/{yamls/windows/containerd-with-ovs/conf => charts/antrea-windows/conf/ovs}/Install-OVSDriver.ps1 (100%) rename build/{yamls/windows/containerd-with-ovs/conf => charts/antrea-windows/conf/ovs}/Run-AntreaOVS.ps1 (100%) rename build/{yamls/windows/containerd-with-ovs/conf => charts/antrea-windows/conf/ovs}/VMSwitchExtension-AntreaAgent.ps1 (100%) create mode 100644 build/charts/antrea-windows/templates/configmaps/antrea-agent-windows.yaml create mode 100644 build/charts/antrea-windows/templates/configmaps/antrea-windows-config.yaml create mode 100644 build/charts/antrea-windows/templates/daemonset.yaml create mode 100644 build/charts/antrea-windows/values.yaml delete mode 100644 build/yamls/windows/base/kustomization.yml delete mode 100644 build/yamls/windows/containerd-with-ovs/containerd-with-ovs.yml delete mode 100644 build/yamls/windows/containerd-with-ovs/kustomization.yml delete mode 100644 build/yamls/windows/containerd/agent-containerd.yml delete mode 100644 build/yamls/windows/containerd/kustomization.yml delete mode 100644 build/yamls/windows/patches/dev/imagePullPolicy.yml delete mode 100644 build/yamls/windows/patches/release/.gitignore delete mode 100755 hack/update-checksum-windows.sh diff --git a/Makefile b/Makefile index 062c54bde49..985e8482dfe 100644 --- a/Makefile +++ b/Makefile @@ -421,7 +421,6 @@ manifest: $(CURDIR)/hack/generate-standard-manifests.sh --mode dev --out build/yamls $(CURDIR)/hack/generate-manifest-windows.sh --mode dev > build/yamls/antrea-windows.yml $(CURDIR)/hack/generate-manifest-windows.sh --mode dev --include-ovs > build/yamls/antrea-windows-with-ovs.yml - $(CURDIR)/hack/update-checksum-windows.sh $(CURDIR)/hack/generate-manifest-flow-aggregator.sh --mode dev > build/yamls/flow-aggregator.yml .PHONY: manifest-scale diff --git a/build/charts/antrea-windows/.helmignore b/build/charts/antrea-windows/.helmignore new file mode 100644 index 00000000000..0e8a0eb36f4 --- /dev/null +++ b/build/charts/antrea-windows/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/build/charts/antrea-windows/Chart.yaml b/build/charts/antrea-windows/Chart.yaml new file mode 100644 index 00000000000..7508d911924 --- /dev/null +++ b/build/charts/antrea-windows/Chart.yaml @@ -0,0 +1,25 @@ +apiVersion: v2 +name: antrea-windows +type: application +displayName: Antrea +home: https://antrea.io/ +version: 0.0.0 +appVersion: latest +kubeVersion: ">= 1.22.0-0" +icon: https://raw.githubusercontent.com/antrea-io/antrea/main/docs/assets/logo/antrea_logo.svg +description: Kubernetes networking based on Open vSwitch for Windows Nodes +keywords: + - Kubernetes + - CNCF + - Networking + - CNI + - Security + - Open vSwitch + - OVS + - Windows +sources: + - https://github.com/antrea-io/antrea +annotations: + artifacthub.io/license: Apache-2.0 + artifacthub.io/operator: "false" + artifacthub.io/prerelease: "false" diff --git a/build/charts/antrea-windows/README.md b/build/charts/antrea-windows/README.md new file mode 100644 index 00000000000..5acf2049b02 --- /dev/null +++ b/build/charts/antrea-windows/README.md @@ -0,0 +1,25 @@ +# antrea-windows + +![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square) + +Kubernetes networking based on Open vSwitch for Windows Nodes + +**Homepage:** + +## Source Code + +* + +## Requirements + +Kubernetes: `>= 1.22.0-0` + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| image | object | `{"repository":"antrea/antrea-windows","tag":"latest"}` | Container image used for Antrea Windows Nodes | +| includeOVS | bool | `true` | Enable running Windows OVS processes inside antrea-ovs container in antrea-agent Pod | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.7.0](https://github.com/norwoodj/helm-docs/releases/v1.7.0) diff --git a/build/yamls/windows/containerd/conf/Install-WindowsCNI.ps1 b/build/charts/antrea-windows/conf/Install-WindowsCNI.ps1 similarity index 100% rename from build/yamls/windows/containerd/conf/Install-WindowsCNI.ps1 rename to build/charts/antrea-windows/conf/Install-WindowsCNI.ps1 diff --git a/build/yamls/windows/containerd/conf/Run-AntreaAgent.ps1 b/build/charts/antrea-windows/conf/Run-AntreaAgent.ps1 similarity index 100% rename from build/yamls/windows/containerd/conf/Run-AntreaAgent.ps1 rename to build/charts/antrea-windows/conf/Run-AntreaAgent.ps1 diff --git a/build/yamls/windows/base/conf/antrea-agent.conf b/build/charts/antrea-windows/conf/antrea-agent.conf similarity index 100% rename from build/yamls/windows/base/conf/antrea-agent.conf rename to build/charts/antrea-windows/conf/antrea-agent.conf diff --git a/build/yamls/windows/base/conf/antrea-cni.conflist b/build/charts/antrea-windows/conf/antrea-cni.conflist similarity index 100% rename from build/yamls/windows/base/conf/antrea-cni.conflist rename to build/charts/antrea-windows/conf/antrea-cni.conflist diff --git a/build/yamls/windows/containerd-with-ovs/conf/Install-OVSDriver.ps1 b/build/charts/antrea-windows/conf/ovs/Install-OVSDriver.ps1 similarity index 100% rename from build/yamls/windows/containerd-with-ovs/conf/Install-OVSDriver.ps1 rename to build/charts/antrea-windows/conf/ovs/Install-OVSDriver.ps1 diff --git a/build/yamls/windows/containerd-with-ovs/conf/Run-AntreaOVS.ps1 b/build/charts/antrea-windows/conf/ovs/Run-AntreaOVS.ps1 similarity index 100% rename from build/yamls/windows/containerd-with-ovs/conf/Run-AntreaOVS.ps1 rename to build/charts/antrea-windows/conf/ovs/Run-AntreaOVS.ps1 diff --git a/build/yamls/windows/containerd-with-ovs/conf/VMSwitchExtension-AntreaAgent.ps1 b/build/charts/antrea-windows/conf/ovs/VMSwitchExtension-AntreaAgent.ps1 similarity index 100% rename from build/yamls/windows/containerd-with-ovs/conf/VMSwitchExtension-AntreaAgent.ps1 rename to build/charts/antrea-windows/conf/ovs/VMSwitchExtension-AntreaAgent.ps1 diff --git a/build/charts/antrea-windows/templates/configmaps/antrea-agent-windows.yaml b/build/charts/antrea-windows/templates/configmaps/antrea-agent-windows.yaml new file mode 100644 index 00000000000..aea4b86566a --- /dev/null +++ b/build/charts/antrea-windows/templates/configmaps/antrea-agent-windows.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +data: + {{- tpl ((.Files.Glob "conf/Install-WindowsCNI.ps1").AsConfig) . | nindent 2 | replace " \n" "\n" }} + {{- tpl ((.Files.Glob "conf/Run-AntreaAgent.ps1").AsConfig) . | nindent 2 | replace " \n" "\n" }} + {{- if .Values.includeOVS }} + {{- tpl ((.Files.Glob "conf/ovs/Install-OVSDriver.ps1").AsConfig) . | nindent 2 | replace " \n" "\n" }} + {{- tpl ((.Files.Glob "conf/ovs/Run-AntreaOVS.ps1").AsConfig) . | nindent 2 | replace " \n" "\n" }} + {{- tpl ((.Files.Glob "conf/ovs/VMSwitchExtension-AntreaAgent.ps1").AsConfig) . | nindent 2 | replace " \n" "\n" }} + {{- end }} +kind: ConfigMap +metadata: + labels: + app: antrea + name: antrea-agent-windows + namespace: kube-system diff --git a/build/charts/antrea-windows/templates/configmaps/antrea-windows-config.yaml b/build/charts/antrea-windows/templates/configmaps/antrea-windows-config.yaml new file mode 100644 index 00000000000..2bd49486731 --- /dev/null +++ b/build/charts/antrea-windows/templates/configmaps/antrea-windows-config.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +data: + {{- tpl ((.Files.Glob "conf/antrea-agent.conf").AsConfig) . | nindent 2 | replace " \n" "\n" }} + {{- tpl ((.Files.Glob "conf/antrea-cni.conflist").AsConfig) . | nindent 2 | replace " \n" "\n" }} +kind: ConfigMap +metadata: + labels: + app: antrea + name: antrea-windows-config + namespace: kube-system diff --git a/build/charts/antrea-windows/templates/daemonset.yaml b/build/charts/antrea-windows/templates/daemonset.yaml new file mode 100644 index 00000000000..959b97d2ba9 --- /dev/null +++ b/build/charts/antrea-windows/templates/daemonset.yaml @@ -0,0 +1,143 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + labels: + app: antrea + component: antrea-agent + name: antrea-agent-windows + namespace: kube-system +spec: + selector: + matchLabels: + app: antrea + component: antrea-agent + template: + metadata: + annotations: + checksum/agent-windows: {{ include (print $.Template.BasePath "/configmaps/antrea-agent-windows.yaml") . | sha256sum }} + checksum/windows-config: {{ include (print $.Template.BasePath "/configmaps/antrea-windows-config.yaml") . | sha256sum }} + microsoft.com/hostprocess-inherit-user: "true" + labels: + app: antrea + component: antrea-agent + spec: + containers: + - args: + - -file + - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Run-AntreaAgent.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 + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: IfNotPresent + {{- if .Values.includeOVS }} + lifecycle: + postStart: + exec: + command: + - powershell + - -file + - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/VMSwitchExtension-AntreaAgent.ps1 + - -VMSwitchExtension + - enable + preStop: + exec: + command: + - powershell + - -file + - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/VMSwitchExtension-AntreaAgent.ps1 + - -VMSwitchExtension + - disable + {{- end}} + name: antrea-agent + 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 + {{- if .Values.includeOVS }} + - args: + - -file + - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Run-AntreaOVS.ps1 + command: + - powershell + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: IfNotPresent + name: antrea-ovs + volumeMounts: + - mountPath: /var/lib/antrea-windows + name: antrea-agent-windows + - mountPath: /var/log/openvswitch + name: var-log-antrea + subPath: openvswitch + {{- end}} + hostNetwork: true + initContainers: + - args: + - -file + - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Install-WindowsCNI.ps1 + command: + - powershell + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: IfNotPresent + name: install-cni + volumeMounts: + - mountPath: /etc/antrea + name: antrea-windows-config + readOnly: true + - mountPath: /var/lib/antrea-windows + name: antrea-agent-windows + {{- if .Values.includeOVS }} + - args: + - -file + - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Install-OVSDriver.ps1 + command: + - powershell + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: IfNotPresent + name: install-ovs-driver + volumeMounts: + - mountPath: /var/lib/antrea-windows + name: antrea-agent-windows + {{- end }} + nodeSelector: + kubernetes.io/os: windows + priorityClassName: system-node-critical + securityContext: + windowsOptions: + hostProcess: true + runAsUserName: NT AUTHORITY\SYSTEM + 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 diff --git a/build/charts/antrea-windows/values.yaml b/build/charts/antrea-windows/values.yaml new file mode 100644 index 00000000000..c80d289701a --- /dev/null +++ b/build/charts/antrea-windows/values.yaml @@ -0,0 +1,7 @@ +# -- Container image used for Antrea Windows Nodes +image: + repository: "antrea/antrea-windows" + tag: "latest" + +# -- Enable running Windows OVS processes inside antrea-ovs container in antrea-agent Pod +includeOVS: true diff --git a/build/yamls/antrea-windows-with-ovs.yml b/build/yamls/antrea-windows-with-ovs.yml index fe444f28c64..fb4d7d69748 100644 --- a/build/yamls/antrea-windows-with-ovs.yml +++ b/build/yamls/antrea-windows-with-ovs.yml @@ -1,43 +1,7 @@ +--- +# Source: antrea-windows/templates/configmaps/antrea-agent-windows.yaml apiVersion: v1 data: - Install-OVSDriver.ps1: | - $ErrorActionPreference = "Stop" - $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 - } - Write-Host "OVSExt driver has been installed" - } - - # Check if the VC redistributable is already installed. - $OVSRedistDir="$mountPath\openvswitch\redist" - if (Test-Path $OVSRedistDir) { - $dllFound = $false - $paths = $env:PATH -split ';' - foreach ($path in $paths) { - $dllFiles = Get-ChildItem -Path $path -Filter "vcruntime*.dll" -File -ErrorAction SilentlyContinue - if ($dllFiles.Count -gt 0) { - $dllFound = $true - break - } - } - - # vcruntime dlls are not installed on the host, then install the binaries. - if (-not $dllFound) { - Get-ChildItem $OVSRedistDir -Filter *.exe | ForEach-Object { - Start-Process -FilePath $_.FullName -Args '/install /passive /norestart' -Verb RunAs -Wait - } - } - } Install-WindowsCNI.ps1: | $ErrorActionPreference = "Stop"; mkdir -force c:/var/log/antrea @@ -78,6 +42,44 @@ data: $mountPath = ($mountPath.Replace('\', '/')).TrimEnd('/') $env:PATH = $env:PATH + ";$mountPath/Windows/System32;$mountPath/k/antrea/bin;$mountPath/openvswitch/usr/bin;$mountPath/openvswitch/usr/sbin" & antrea-agent --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 + Install-OVSDriver.ps1: | + $ErrorActionPreference = "Stop" + $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 + } + Write-Host "OVSExt driver has been installed" + } + + # Check if the VC redistributable is already installed. + $OVSRedistDir="$mountPath\openvswitch\redist" + if (Test-Path $OVSRedistDir) { + $dllFound = $false + $paths = $env:PATH -split ';' + foreach ($path in $paths) { + $dllFiles = Get-ChildItem -Path $path -Filter "vcruntime*.dll" -File -ErrorAction SilentlyContinue + if ($dllFiles.Count -gt 0) { + $dllFound = $true + break + } + } + + # vcruntime dlls are not installed on the host, then install the binaries. + if (-not $dllFound) { + Get-ChildItem $OVSRedistDir -Filter *.exe | ForEach-Object { + Start-Process -FilePath $_.FullName -Args '/install /passive /norestart' -Verb RunAs -Wait + } + } + } Run-AntreaOVS.ps1: | $ErrorActionPreference = "Stop" $mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT @@ -142,6 +144,7 @@ metadata: name: antrea-agent-windows namespace: kube-system --- +# Source: antrea-windows/templates/configmaps/antrea-windows-config.yaml apiVersion: v1 data: antrea-agent.conf: | @@ -308,6 +311,7 @@ metadata: name: antrea-windows-config namespace: kube-system --- +# Source: antrea-windows/templates/daemonset.yaml apiVersion: apps/v1 kind: DaemonSet metadata: @@ -324,8 +328,8 @@ spec: template: metadata: annotations: - checksum/agent-windows: da4b49898e3181dfcb6359f2b2acba452c2ff9a17af8342b6cccb73e8857aad6 - checksum/windows-config: 6ff4f8bd0b310ebe4d4612bdd9697ffb3d79e0e0eab3936420417dd5a8fc128d + checksum/agent-windows: 5efe6525007ef87c58914b37d190f84bc93b8cf081d204979dffce0859ee2da3 + checksum/windows-config: 10ad2be0a04b1752abc224fed0124f7b1da36efc5e7323e193eb38e11b25e798 microsoft.com/hostprocess-inherit-user: "true" labels: app: antrea diff --git a/build/yamls/antrea-windows.yml b/build/yamls/antrea-windows.yml index 8728efde011..447cea20b6d 100644 --- a/build/yamls/antrea-windows.yml +++ b/build/yamls/antrea-windows.yml @@ -1,3 +1,5 @@ +--- +# Source: antrea-windows/templates/configmaps/antrea-agent-windows.yaml apiVersion: v1 data: Install-WindowsCNI.ps1: | @@ -47,6 +49,7 @@ metadata: name: antrea-agent-windows namespace: kube-system --- +# Source: antrea-windows/templates/configmaps/antrea-windows-config.yaml apiVersion: v1 data: antrea-agent.conf: | @@ -213,6 +216,7 @@ metadata: name: antrea-windows-config namespace: kube-system --- +# Source: antrea-windows/templates/daemonset.yaml apiVersion: apps/v1 kind: DaemonSet metadata: @@ -229,8 +233,8 @@ spec: template: metadata: annotations: - checksum/agent-windows: 542068477bbe94774e38a839710706f2d0705ecc7f1ab9aa1a1cf3e46eb73afb - checksum/windows-config: 6ff4f8bd0b310ebe4d4612bdd9697ffb3d79e0e0eab3936420417dd5a8fc128d + checksum/agent-windows: adb135c962fe85e0a2bc86a45f4b8c72d89b09a1da35bb16775e547813295679 + checksum/windows-config: 10ad2be0a04b1752abc224fed0124f7b1da36efc5e7323e193eb38e11b25e798 microsoft.com/hostprocess-inherit-user: "true" labels: app: antrea diff --git a/build/yamls/windows/base/kustomization.yml b/build/yamls/windows/base/kustomization.yml deleted file mode 100644 index dafaaa672d7..00000000000 --- a/build/yamls/windows/base/kustomization.yml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -configMapGenerator: -- files: - - conf/antrea-agent.conf - - conf/antrea-cni.conflist - name: antrea-windows-config -generatorOptions: - disableNameSuffixHash: true diff --git a/build/yamls/windows/containerd-with-ovs/containerd-with-ovs.yml b/build/yamls/windows/containerd-with-ovs/containerd-with-ovs.yml deleted file mode 100644 index f5d69ca280c..00000000000 --- a/build/yamls/windows/containerd-with-ovs/containerd-with-ovs.yml +++ /dev/null @@ -1,42 +0,0 @@ -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: antrea-agent-windows -spec: - template: - spec: - containers: - - name: antrea-agent - lifecycle: - preStop: - exec: - command: ["powershell", "-file", "$env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/VMSwitchExtension-AntreaAgent.ps1", "-VMSwitchExtension", "disable"] - postStart: - exec: - command: ["powershell", "-file", "$env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/VMSwitchExtension-AntreaAgent.ps1", "-VMSwitchExtension", "enable"] - - name: antrea-ovs - image: antrea-windows - imagePullPolicy: IfNotPresent - args: - - -file - - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Run-AntreaOVS.ps1 - command: - - powershell - volumeMounts: - - mountPath: /var/lib/antrea-windows - name: antrea-agent-windows - - mountPath: /var/log/openvswitch - name: var-log-antrea - subPath: openvswitch - initContainers: - - args: - - -file - - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Install-OVSDriver.ps1 - command: - - powershell - image: antrea/antrea-windows:latest - imagePullPolicy: IfNotPresent - name: install-ovs-driver - volumeMounts: - - mountPath: /var/lib/antrea-windows - name: antrea-agent-windows diff --git a/build/yamls/windows/containerd-with-ovs/kustomization.yml b/build/yamls/windows/containerd-with-ovs/kustomization.yml deleted file mode 100644 index df207bcde62..00000000000 --- a/build/yamls/windows/containerd-with-ovs/kustomization.yml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: -- ../containerd -patchesStrategicMerge: -- containerd-with-ovs.yml -commonLabels: - app: antrea -configMapGenerator: -- files: - - conf/Install-OVSDriver.ps1 - - conf/Run-AntreaOVS.ps1 - - conf/VMSwitchExtension-AntreaAgent.ps1 - name: antrea-agent-windows - namespace: kube-system - behavior: merge -generatorOptions: - disableNameSuffixHash: true diff --git a/build/yamls/windows/containerd/agent-containerd.yml b/build/yamls/windows/containerd/agent-containerd.yml deleted file mode 100644 index 04d402648b2..00000000000 --- a/build/yamls/windows/containerd/agent-containerd.yml +++ /dev/null @@ -1,89 +0,0 @@ -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" - checksum/windows-config: windows-config-checksum-placeholder - checksum/agent-windows: agent-windows-checksum-placeholder - labels: - component: antrea-agent - spec: - securityContext: - windowsOptions: - runAsUserName: "NT AUTHORITY\\SYSTEM" - hostProcess: true - containers: - - args: - - -file - - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Run-AntreaAgent.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 - image: antrea-windows - name: antrea-agent - 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 - hostNetwork: true - initContainers: - - args: - - -file - - $env:CONTAINER_SANDBOX_MOUNT_POINT/var/lib/antrea-windows/Install-WindowsCNI.ps1 - command: - - powershell - image: antrea-windows - 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 diff --git a/build/yamls/windows/containerd/kustomization.yml b/build/yamls/windows/containerd/kustomization.yml deleted file mode 100644 index a570699cd0e..00000000000 --- a/build/yamls/windows/containerd/kustomization.yml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: -- agent-containerd.yml -- ../base -namespace: kube-system -commonLabels: - app: antrea -configMapGenerator: -- files: - - conf/Run-AntreaAgent.ps1 - - conf/Install-WindowsCNI.ps1 - name: antrea-agent-windows -generatorOptions: - disableNameSuffixHash: true diff --git a/build/yamls/windows/patches/dev/imagePullPolicy.yml b/build/yamls/windows/patches/dev/imagePullPolicy.yml deleted file mode 100644 index 85705b69317..00000000000 --- a/build/yamls/windows/patches/dev/imagePullPolicy.yml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: antrea-agent-windows -spec: - template: - spec: - containers: - - name: antrea-agent - imagePullPolicy: IfNotPresent - initContainers: - - name: install-cni - imagePullPolicy: IfNotPresent diff --git a/build/yamls/windows/patches/release/.gitignore b/build/yamls/windows/patches/release/.gitignore deleted file mode 100644 index fdffa2a0fd7..00000000000 --- a/build/yamls/windows/patches/release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# placeholder diff --git a/hack/generate-manifest-windows.sh b/hack/generate-manifest-windows.sh index e6e13d600a3..068b1c3cf77 100755 --- a/hack/generate-manifest-windows.sh +++ b/hack/generate-manifest-windows.sh @@ -20,20 +20,19 @@ function echoerr { >&2 echo "$@" } -_usage="Usage: $0 [--mode (dev|release)] [--keep] [--help|-h] -Generate a YAML manifest to run Antrea on Windows Nodes, using Kustomize, and print it to stdout. +_usage="Usage: $0 [--mode (dev|release)] [--include-ovs] [--help|-h] +Generate a YAML manifest to run Antrea on Windows Nodes, using Helm, and print it to stdout. --mode (dev|release) Choose the configuration variant that you need (default is 'dev') - --keep Debug flag which will preserve the generated kustomization.yml --help, -h Print this message and exit --include-ovs Run Windows OVS processes inside antrea-ovs container in antrea-agent pod on Windows host with containerd runtime. In 'release' mode, environment variables IMG_NAME and IMG_TAG must be set. -This tool uses kustomize (https://github.com/kubernetes-sigs/kustomize) to generate manifests for -running Antrea on Windows Nodes. You can set the KUSTOMIZE environment variable to the path of the -kustomize binary you want us to use. Otherwise we will look for kustomize in your PATH and your -GOPATH. If we cannot find kustomize there, we will try to install it." +This tool uses Helm 3 (https://helm.sh/) to generate manifests for Antrea. You can set the HELM +environment variable to the path of the helm binary you want us to use. Otherwise we will download +the appropriate version of the helm binary and use it (this is the recommended approach since +different versions of helm may create different output YAMLs)." function print_usage { echoerr "$_usage" @@ -44,8 +43,8 @@ function print_help { } MODE="dev" -KEEP=false INCLUDE_OVS=false +HELM_VALUES=() while [[ $# -gt 0 ]] do @@ -56,10 +55,6 @@ case $key in MODE="$2" shift 2 ;; - --keep) - KEEP=true - shift - ;; --include-ovs) INCLUDE_OVS=true shift @@ -95,49 +90,36 @@ fi THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -source $THIS_DIR/verify-kustomize.sh +source $THIS_DIR/verify-helm.sh -if [ -z "$KUSTOMIZE" ]; then - KUSTOMIZE="$(verify_kustomize)" -elif ! $KUSTOMIZE version > /dev/null 2>&1; then - echoerr "$KUSTOMIZE does not appear to be a valid kustomize binary" +if [ -z "$HELM" ]; then + HELM="$(verify_helm)" +elif ! $HELM version > /dev/null 2>&1; then + echoerr "$HELM does not appear to be a valid helm binary" print_help exit 1 fi -KUSTOMIZATION_DIR=$THIS_DIR/../build/yamls/windows - -TMP_DIR=$(mktemp -d $KUSTOMIZATION_DIR/overlays.XXXXXXXX) - -pushd $TMP_DIR > /dev/null - -BASE=../../containerd if $INCLUDE_OVS; then - BASE=../../containerd-with-ovs -fi - -mkdir $MODE && cd $MODE -touch kustomization.yml -# ../../patches/$MODE may be empty so we use find and not simply cp -find ../../patches/$MODE -name \*.yml -exec cp {} . \; - -$KUSTOMIZE edit add base $BASE - -if [ "$MODE" == "dev" ]; then - $KUSTOMIZE edit set image antrea-windows=antrea/antrea-windows:latest - $KUSTOMIZE edit add patch --path imagePullPolicy.yml + HELM_VALUES+=("includeOVS=true") +else + HELM_VALUES+=("includeOVS=false") fi if [ "$MODE" == "release" ]; then - $KUSTOMIZE edit set image antrea-windows=$IMG_NAME:$IMG_TAG + HELM_VALUES+=("image.repository=$IMG_NAME,image.tag=$IMG_TAG") fi -$KUSTOMIZE build +delim="" +HELM_VALUES_OPTION="" +for v in "${HELM_VALUES[@]}"; do + HELM_VALUES_OPTION="$HELM_VALUES_OPTION$delim$v" + delim="," +done +if [ "$HELM_VALUES_OPTION" != "" ]; then + HELM_VALUES_OPTION="--set $HELM_VALUES_OPTION" +fi -popd > /dev/null +ANTREA_CHART="$THIS_DIR/../build/charts/antrea-windows" -if $KEEP; then - echoerr "Kustomization file is at $TMP_DIR/$MODE/kustomization.yml" -else - rm -rf $TMP_DIR -fi +$HELM template $HELM_VALUES_OPTION "$ANTREA_CHART" diff --git a/hack/update-checksum-windows.sh b/hack/update-checksum-windows.sh deleted file mode 100755 index 7824f0243cc..00000000000 --- a/hack/update-checksum-windows.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2023 Antrea Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -YAMLS_DIR="${WORK_DIR}"/../build/yamls -MANIFESTS=$(ls $YAMLS_DIR/antrea-windows*.yml) -WINDOWS_DIR="${YAMLS_DIR}"/windows -BASE_CONF_FILES="${WINDOWS_DIR}/base/conf/antrea-agent.conf ${WINDOWS_DIR}/base/conf/antrea-cni.conflist" -CONTAINERD_CONF_FILES="${WINDOWS_DIR}/containerd/conf/Install-WindowsCNI.ps1 \ - ${WINDOWS_DIR}/containerd/conf/Run-AntreaAgent.ps1" -CONTAINERD_WITH_OVS_CONF_FILES="${WINDOWS_DIR}/containerd-with-ovs/conf/Run-AntreaOVS.ps1 \ - ${WINDOWS_DIR}/containerd-with-ovs/conf/VMSwitchExtension-AntreaAgent.ps1 \ - ${WINDOWS_DIR}/containerd-with-ovs/conf/Install-OVSDriver.ps1" - -checksum_windows_config=$(cat ${BASE_CONF_FILES} | sha256sum | cut -d " " -f 1) - -checksum_containerd=$( cat ${CONTAINERD_CONF_FILES} | sha256sum | cut -d " " -f 1) - -checksum_containerd_with_ovs=$(cat ${CONTAINERD_CONF_FILES} ${CONTAINERD_WITH_OVS_CONF_FILES} | sha256sum | cut -d " " -f 1) - -for file in ${MANIFESTS[@]}; do - sed -i.bak "s/windows-config-checksum-placeholder/${checksum_windows_config}/g" ${file} -done - -sed -i.bak "s/agent-windows-checksum-placeholder/${checksum_containerd}/g" ${YAMLS_DIR}/antrea-windows.yml -sed -i.bak "s/agent-windows-checksum-placeholder/${checksum_containerd_with_ovs}/g" ${YAMLS_DIR}/antrea-windows-with-ovs.yml