Skip to content

Commit

Permalink
Update prepare-node script and antrea-windows-containerd.yml
Browse files Browse the repository at this point in the history
Signed-off-by: Naman Agarwal <naman.agarwal75@gmail.com>
  • Loading branch information
NamanAg30 committed Oct 7, 2023
1 parent 813372b commit c60c29c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 10 deletions.
26 changes: 23 additions & 3 deletions build/yamls/antrea-windows-containerd-with-ovs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,29 @@ data:
mkdir -force c:/var/log/antrea
$mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT
$mountPath = ($mountPath.Replace('\', '/')).TrimEnd('/')
mkdir -force C:/var/run/secrets/kubernetes.io/serviceaccount
cp $mountPath/var/run/secrets/kubernetes.io/serviceaccount/ca.crt C:/var/run/secrets/kubernetes.io/serviceaccount
cp $mountPath/var/run/secrets/kubernetes.io/serviceaccount/token C:/var/run/secrets/kubernetes.io/serviceaccount
#From containerd version 1.7 onwards servcieaccount directory and the ca.cert and token files will automatically be created.
$serviceAccountPath = "C:\var\run\secrets\kubernetes.io\serviceaccount"
if (-Not $(Test-Path $serviceAccountPath)) {
mkdir -force C:/var/run/secrets/kubernetes.io/serviceaccount
}
$localTokenFile = "$serviceAccountPath/token"
$localCAFile="$serviceAccountPath/ca.crt"
$tokenPath = "$mountPath/var/run/secrets/kubernetes.io/serviceaccount/token"
$certPath = "$mountPath/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
# Check if the local token file is not present or its content is different
if (-Not (Test-Path $localTokenFile) -or (Get-Content -Raw $localTokenFile) -ne (Get-Content -Raw $tokenPath)) {
Copy-Item -Path $tokenPath -Destination $localTokenFile -Force
}
# Check if the local ca.crt file is not present or its content is different
if (-Not (Test-Path $localCAFile) -or (Get-Content -Raw $localCAFile) -ne (Get-Content -Raw $certPath)) {
Copy-Item -Path $certPath -Destination $localCAFile -Force
}
mkdir -force c:/opt/cni/bin/
mkdir -force c:/etc/cni/net.d/
cp $mountPath/k/antrea/cni/* c:/opt/cni/bin/
Expand Down
26 changes: 23 additions & 3 deletions build/yamls/antrea-windows-containerd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,35 @@ data:
mkdir -force c:/var/log/antrea
$mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT
$mountPath = ($mountPath.Replace('\', '/')).TrimEnd('/')
mkdir -force C:/var/run/secrets/kubernetes.io/serviceaccount
cp $mountPath/var/run/secrets/kubernetes.io/serviceaccount/ca.crt C:/var/run/secrets/kubernetes.io/serviceaccount
cp $mountPath/var/run/secrets/kubernetes.io/serviceaccount/token C:/var/run/secrets/kubernetes.io/serviceaccount
$serviceAccountPath = "C:\var\run\secrets\kubernetes.io\serviceaccount"
if (-Not $(Test-Path $serviceAccountPath)) {
mkdir -force C:/var/run/secrets/kubernetes.io/serviceaccount
}
$localTokenFile = "$serviceAccountPath/token"
$localCAFile="$serviceAccountPath/ca.crt"
$tokenPath = "$mountPath/var/run/secrets/kubernetes.io/serviceaccount/token"
$certPath = "$mountPath/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
# Check if the local token file is not present or its content is different
if (-Not (Test-Path $localTokenFile) -or (Get-Content -Raw $localTokenFile) -ne (Get-Content -Raw $tokenPath)) {
Copy-Item -Path $tokenPath -Destination $localTokenFile -Force
}
# Check if the local ca.crt file is not present or its content is different
if (-Not (Test-Path $localCAFile) -or (Get-Content -Raw $localCAFile) -ne (Get-Content -Raw $certPath)) {
Copy-Item -Path $certPath -Destination $localCAFile -Force
}
mkdir -force c:/opt/cni/bin/
mkdir -force c:/etc/cni/net.d/
cp $mountPath/k/antrea/cni/* c:/opt/cni/bin/
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
Run-AntreaAgent-Containerd.ps1: |
$ErrorActionPreference = "Stop"
$mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ $ErrorActionPreference = "Stop";
mkdir -force c:/var/log/antrea
$mountPath = $env:CONTAINER_SANDBOX_MOUNT_POINT
$mountPath = ($mountPath.Replace('\', '/')).TrimEnd('/')
mkdir -force C:/var/run/secrets/kubernetes.io/serviceaccount
cp $mountPath/var/run/secrets/kubernetes.io/serviceaccount/ca.crt C:/var/run/secrets/kubernetes.io/serviceaccount
cp $mountPath/var/run/secrets/kubernetes.io/serviceaccount/token C:/var/run/secrets/kubernetes.io/serviceaccount

$serviceAccountPath = "C:\var\run\secrets\kubernetes.io\serviceaccount"
if (-Not $(Test-Path $serviceAccountPath)) {
mkdir -force C:/var/run/secrets/kubernetes.io/serviceaccount
}

$localTokenFile = "$serviceAccountPath/token"
$localCAFile="$serviceAccountPath/ca.crt"

$tokenPath = "$mountPath/var/run/secrets/kubernetes.io/serviceaccount/token"
$certPath = "$mountPath/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"

# Check if the local token file is not present or its content is different
if (-Not (Test-Path $localTokenFile) -or (Get-Content -Raw $localTokenFile) -ne (Get-Content -Raw $tokenPath)) {
Copy-Item -Path $tokenPath -Destination $localTokenFile -Force
}

# Check if the local ca.crt file is not present or its content is different
if (-Not (Test-Path $localCAFile) -or (Get-Content -Raw $localCAFile) -ne (Get-Content -Raw $certPath)) {
Copy-Item -Path $certPath -Destination $localCAFile -Force
}

mkdir -force c:/opt/cni/bin/
mkdir -force c:/etc/cni/net.d/
cp $mountPath/k/antrea/cni/* c:/opt/cni/bin/
Expand Down
4 changes: 3 additions & 1 deletion hack/windows/Prepare-Node.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ if ($InstallKubeProxy) {

$StartKubeletFileContent += [Environment]::NewLine + '$global:KubeletArgs += "--cert-dir=$env:SYSTEMDRIVE\var\lib\kubelet\pki --config=/var/lib/kubelet/config.yaml --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --hostname-override=$(hostname) --pod-infra-container-image=`"mcr.microsoft.com/oss/kubernetes/pause:1.4.1`" --enable-debugging-handlers --cgroups-per-qos=false --enforce-node-allocatable=`"`" --resolv-conf=`"`" --node-ip=$env:NODE_IP"'

if ($ContainerRuntime -eq "containerd") {
$targetVersion = [version]"1.28.0"

if ($ContainerRuntime -eq "containerd" -and [version]($KubernetesVersion -replace '^v') -lt $targetVersion) {
$StartKubeletFileContent += [Environment]::NewLine + '$global:KubeletArgs += " --feature-gates=WindowsHostProcessContainers=true"'
}

Expand Down

0 comments on commit c60c29c

Please sign in to comment.