From f6c561b438c932612e12092aab6dfd6fcdeacf03 Mon Sep 17 00:00:00 2001 From: Kalya Subramanian Date: Tue, 24 Mar 2020 12:59:32 -0700 Subject: [PATCH] feat: Windows azure-cni with containerd --- .../kubernetes-hybrid.azure-containerd.json | 55 +++++++++++++++++++ ...kubernetes-hybrid.kubenet-containerd.json} | 0 parts/k8s/kuberneteswindowssetup.ps1 | 1 - parts/k8s/windowscontainerdfunc.ps1 | 11 +++- pkg/api/vlabs/validate.go | 3 - pkg/engine/templates_generated.go | 6 +- 6 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 examples/windows/kubernetes-hybrid.azure-containerd.json rename examples/windows/{kubernetes-hybrid.containerd.json => kubernetes-hybrid.kubenet-containerd.json} (100%) diff --git a/examples/windows/kubernetes-hybrid.azure-containerd.json b/examples/windows/kubernetes-hybrid.azure-containerd.json new file mode 100644 index 00000000000..46107da68d5 --- /dev/null +++ b/examples/windows/kubernetes-hybrid.azure-containerd.json @@ -0,0 +1,55 @@ +{ + "apiVersion": "vlabs", + "properties": { + "orchestratorProfile": { + "orchestratorType": "Kubernetes", + "orchestratorRelease": "1.18", + "kubernetesConfig": { + "networkPlugin": "azure", + "containerRuntime": "containerd", + "windowsContainerdURL": "https://aksenginee2etestimages.blob.core.windows.net/test-content/windows-cri-containerd.zip", + "windowsSdnPluginURL": "https://aksenginee2etestimages.blob.core.windows.net/test-content/windows-cni-containerd.zip" + } + }, + "masterProfile": { + "count": 1, + "dnsPrefix": "", + "vmSize": "Standard_D2_v2" + }, + "agentPoolProfiles": [ + { + "name": "linuxpool1", + "count": 2, + "vmSize": "Standard_D2_v2", + "availabilityProfile": "AvailabilitySet" + }, + { + "name": "windowspool2", + "count": 2, + "vmSize": "Standard_D2s_v3", + "availabilityProfile": "AvailabilitySet", + "osType": "Windows" + } + ], + "windowsProfile": { + "adminUsername": "azureuser", + "adminPassword": "replacepassword1234$", + "enableAutomaticUpdates": false, + "sshEnabled": true + }, + "linuxProfile": { + "adminUsername": "azureuser", + "ssh": { + "publicKeys": [ + { + "keyData": "" + } + ] + } + }, + "servicePrincipalProfile": { + "clientId": "", + "secret": "" + } + } +} diff --git a/examples/windows/kubernetes-hybrid.containerd.json b/examples/windows/kubernetes-hybrid.kubenet-containerd.json similarity index 100% rename from examples/windows/kubernetes-hybrid.containerd.json rename to examples/windows/kubernetes-hybrid.kubenet-containerd.json diff --git a/parts/k8s/kuberneteswindowssetup.ps1 b/parts/k8s/kuberneteswindowssetup.ps1 index a9a3015426f..05333d874af 100644 --- a/parts/k8s/kuberneteswindowssetup.ps1 +++ b/parts/k8s/kuberneteswindowssetup.ps1 @@ -351,7 +351,6 @@ try } else { Update-WinCNI -CNIPath $global:CNIPath } - Get-HnsPsm1 -HNSModule $global:HNSModule } New-ExternalHnsNetwork diff --git a/parts/k8s/windowscontainerdfunc.ps1 b/parts/k8s/windowscontainerdfunc.ps1 index 2ea2c553a3f..ee72506a55d 100644 --- a/parts/k8s/windowscontainerdfunc.ps1 +++ b/parts/k8s/windowscontainerdfunc.ps1 @@ -27,7 +27,11 @@ function Install-Containerd { Param( [Parameter(Mandatory = $true)][string] - $ContainerdUrl + $ContainerdUrl, + [Parameter(Mandatory=$true)][string] + $CNIConfDir, + [Parameter(Mandatory=$true)][string] + $CNIBinDir, ) $zipfile = [Io.path]::Combine($ENV:TEMP, "containerd.zip") DownloadFileOverHttp -Url $ContainerdUrl -DestinationPath $zipfile @@ -44,6 +48,7 @@ function Install-Containerd # TODO: call containerd.exe dump config, then modify instead of starting with hardcoded $configFile = [Io.Path]::Combine($global:ContainerdInstallLocation, "config.toml") + @" version = 2 root = "C:\\ProgramData\\containerd\\root" @@ -131,8 +136,8 @@ oom_score = 0 runtime_root = "" privileged_without_host_devices = false [plugins."io.containerd.grpc.v1.cri".cni] - bin_dir = "C:\\k\\cni" - conf_dir = "C:\\k\\cni\\config" + bin_dir = "$(($CNIBinDir).Replace("\","//"))" + conf_dir = "$(($CNIConfDir).Replace("\","//"))" max_conf_num = 1 conf_template = "" [plugins."io.containerd.grpc.v1.cri".registry] diff --git a/pkg/api/vlabs/validate.go b/pkg/api/vlabs/validate.go index c37c234075d..52a5f0a928d 100644 --- a/pkg/api/vlabs/validate.go +++ b/pkg/api/vlabs/validate.go @@ -1619,9 +1619,6 @@ func (a *Properties) validateContainerRuntime() error { // TODO: These validations should be relaxed once ContainerD and CNI plugins are more readily available if containerRuntime == Containerd && a.HasWindows() { - if a.OrchestratorProfile.KubernetesConfig.NetworkPlugin != "kubenet" { - return errors.Errorf("Windows only supports kubenet with containerd runtime. %q is not supported", a.OrchestratorProfile.KubernetesConfig.NetworkPlugin) - } if a.OrchestratorProfile.KubernetesConfig.WindowsContainerdURL == "" { return errors.Errorf("WindowsContainerdURL must be provided when using Windows with ContainerRuntime=containerd") } diff --git a/pkg/engine/templates_generated.go b/pkg/engine/templates_generated.go index 7bed842a6e3..3b34453c7bc 100644 --- a/pkg/engine/templates_generated.go +++ b/pkg/engine/templates_generated.go @@ -39833,6 +39833,7 @@ try -AzureEnvironmentFilePath $([io.path]::Combine($global:KubeDir, "azurestackcloud.json")) ` + "`" + ` -IdentitySystem "{{ GetIdentitySystem }}" } + # To Check: Hopefully no change needed here for containerd } elseif ($global:NetworkPlugin -eq "kubenet") { Write-Log "Fetching additional files needed for kubenet" @@ -39842,7 +39843,6 @@ try } else { Update-WinCNI -CNIPath $global:CNIPath } - Get-HnsPsm1 -HNSModule $global:HNSModule } New-ExternalHnsNetwork @@ -40961,8 +40961,8 @@ oom_score = 0 runtime_root = "" privileged_without_host_devices = false [plugins."io.containerd.grpc.v1.cri".cni] - bin_dir = "C:\\k\\cni" - conf_dir = "C:\\k\\cni\\config" + bin_dir = "C:\\k\\azurecni\\bin" + conf_dir = "C:\\k\\azurecni\\netconf" max_conf_num = 1 conf_template = "" [plugins."io.containerd.grpc.v1.cri".registry]