diff --git a/templates/cluster-template-machinepool-windows.yaml b/templates/cluster-template-machinepool-windows.yaml index f5e8ce9fe5c..dce9307d850 100644 --- a/templates/cluster-template-machinepool-windows.yaml +++ b/templates/cluster-template-machinepool-windows.yaml @@ -266,6 +266,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe path: C:/defender-exclude-calico.ps1 permissions: "0744" @@ -274,9 +289,10 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell c:/create-external-network.ps1 diff --git a/templates/cluster-template-windows-apiserver-ilb.yaml b/templates/cluster-template-windows-apiserver-ilb.yaml index 2613ab07ad8..54dac7a7244 100644 --- a/templates/cluster-template-windows-apiserver-ilb.yaml +++ b/templates/cluster-template-windows-apiserver-ilb.yaml @@ -288,6 +288,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: |- Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico-ipam.exe @@ -298,11 +313,12 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' diff --git a/templates/cluster-template-windows.yaml b/templates/cluster-template-windows.yaml index a704c6040af..5165d9e0fe8 100644 --- a/templates/cluster-template-windows.yaml +++ b/templates/cluster-template-windows.yaml @@ -272,6 +272,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: |- Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico-ipam.exe @@ -282,11 +297,12 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: [] users: diff --git a/templates/flavors/machinepool-windows/machine-pool-deployment-windows.yaml b/templates/flavors/machinepool-windows/machine-pool-deployment-windows.yaml index 93ce0d8b990..6c84d65b563 100644 --- a/templates/flavors/machinepool-windows/machine-pool-deployment-windows.yaml +++ b/templates/flavors/machinepool-windows/machine-pool-deployment-windows.yaml @@ -51,7 +51,7 @@ spec: preKubeadmCommands: - powershell c:/create-external-network.ps1 postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 joinConfiguration: nodeRegistration: @@ -59,6 +59,7 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule files: - contentFrom: secret: @@ -67,6 +68,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - path: C:/defender-exclude-calico.ps1 permissions: "0744" content: |- diff --git a/templates/flavors/windows-apiserver-ilb/machine-deployment-windows.yaml b/templates/flavors/windows-apiserver-ilb/machine-deployment-windows.yaml index c3152480838..f8e368f0d44 100644 --- a/templates/flavors/windows-apiserver-ilb/machine-deployment-windows.yaml +++ b/templates/flavors/windows-apiserver-ilb/machine-deployment-windows.yaml @@ -59,7 +59,7 @@ spec: - ${AZURE_SSH_PUBLIC_KEY:=""} preKubeadmCommands: [] postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 joinConfiguration: nodeRegistration: @@ -67,6 +67,7 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: "ABOVE_NORMAL_PRIORITY_CLASS" files: @@ -77,6 +78,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - path: C:/defender-exclude-calico.ps1 permissions: "0744" content: |- diff --git a/templates/flavors/windows/machine-deployment-windows.yaml b/templates/flavors/windows/machine-deployment-windows.yaml index c3152480838..03495c37b4a 100644 --- a/templates/flavors/windows/machine-deployment-windows.yaml +++ b/templates/flavors/windows/machine-deployment-windows.yaml @@ -59,7 +59,7 @@ spec: - ${AZURE_SSH_PUBLIC_KEY:=""} preKubeadmCommands: [] postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 joinConfiguration: nodeRegistration: @@ -67,8 +67,9 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" - windows-priorityclass: "ABOVE_NORMAL_PRIORITY_CLASS" + windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS files: - contentFrom: secret: @@ -77,6 +78,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - path: C:/defender-exclude-calico.ps1 permissions: "0744" content: |- diff --git a/templates/test/ci/cluster-template-prow-ci-version-windows.yaml b/templates/test/ci/cluster-template-prow-ci-version-windows.yaml index 0934ee78f6a..98f29b22c36 100644 --- a/templates/test/ci/cluster-template-prow-ci-version-windows.yaml +++ b/templates/test/ci/cluster-template-prow-ci-version-windows.yaml @@ -497,6 +497,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: |- Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico-ipam.exe @@ -596,11 +611,12 @@ spec: feature-gates: ${NODE_FEATURE_GATES:-""} image-credential-provider-bin-dir: /var/lib/kubelet/credential-provider image-credential-provider-config: /var/lib/kubelet/credential-provider-config.yaml + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell C:/create-temp-folder.ps1 diff --git a/templates/test/ci/cluster-template-prow-clusterclass-ci-default.yaml b/templates/test/ci/cluster-template-prow-clusterclass-ci-default.yaml index 0db9729ca45..077cef648b8 100644 --- a/templates/test/ci/cluster-template-prow-clusterclass-ci-default.yaml +++ b/templates/test/ci/cluster-template-prow-clusterclass-ci-default.yaml @@ -529,6 +529,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: |- Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico-ipam.exe @@ -539,11 +554,12 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: [] --- diff --git a/templates/test/ci/cluster-template-prow-machine-pool-ci-version-windows.yaml b/templates/test/ci/cluster-template-prow-machine-pool-ci-version-windows.yaml index 6c629a749eb..b512506d906 100644 --- a/templates/test/ci/cluster-template-prow-machine-pool-ci-version-windows.yaml +++ b/templates/test/ci/cluster-template-prow-machine-pool-ci-version-windows.yaml @@ -504,6 +504,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe path: C:/defender-exclude-calico.ps1 permissions: "0744" @@ -562,9 +577,10 @@ spec: cloud-provider: external image-credential-provider-bin-dir: /var/lib/kubelet/credential-provider image-credential-provider-config: /var/lib/kubelet/credential-provider-config.yaml + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell c:/create-external-network.ps1 diff --git a/templates/test/ci/cluster-template-prow-machine-pool-windows.yaml b/templates/test/ci/cluster-template-prow-machine-pool-windows.yaml index fad34c0b614..83bfae61ca5 100644 --- a/templates/test/ci/cluster-template-prow-machine-pool-windows.yaml +++ b/templates/test/ci/cluster-template-prow-machine-pool-windows.yaml @@ -286,6 +286,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe path: C:/defender-exclude-calico.ps1 permissions: "0744" @@ -294,9 +309,10 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell c:/create-external-network.ps1 diff --git a/templates/test/ci/cluster-template-prow-windows.yaml b/templates/test/ci/cluster-template-prow-windows.yaml index 85d8e32f4bb..bb51290ef10 100644 --- a/templates/test/ci/cluster-template-prow-windows.yaml +++ b/templates/test/ci/cluster-template-prow-windows.yaml @@ -285,6 +285,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: |- Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico-ipam.exe @@ -333,11 +348,12 @@ spec: kubeletExtraArgs: cloud-provider: external feature-gates: ${NODE_FEATURE_GATES:-""} + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell C:/create-temp-folder.ps1 diff --git a/templates/test/ci/prow-clusterclass-ci-default/windows.yaml b/templates/test/ci/prow-clusterclass-ci-default/windows.yaml index 43060236823..41dc1093c51 100644 --- a/templates/test/ci/prow-clusterclass-ci-default/windows.yaml +++ b/templates/test/ci/prow-clusterclass-ci-default/windows.yaml @@ -20,7 +20,7 @@ spec: spec: preKubeadmCommands: [] postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 joinConfiguration: nodeRegistration: @@ -28,6 +28,7 @@ spec: criSocket: npipe:////./pipe/containerd-containerd kubeletExtraArgs: cloud-provider: external + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: "ABOVE_NORMAL_PRIORITY_CLASS" files: @@ -38,6 +39,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - path: C:/defender-exclude-calico.ps1 permissions: "0744" content: |- @@ -59,4 +75,4 @@ spec: managedDisk: storageAccountType: "Premium_LRS" sshPublicKey: "" - vmSize: replace_me \ No newline at end of file + vmSize: replace_me diff --git a/templates/test/dev/cluster-template-custom-builds-machine-pool-windows.yaml b/templates/test/dev/cluster-template-custom-builds-machine-pool-windows.yaml index d9e9315b424..a86710f6c85 100644 --- a/templates/test/dev/cluster-template-custom-builds-machine-pool-windows.yaml +++ b/templates/test/dev/cluster-template-custom-builds-machine-pool-windows.yaml @@ -457,6 +457,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe path: C:/defender-exclude-calico.ps1 permissions: "0744" @@ -516,9 +531,10 @@ spec: cloud-provider: external image-credential-provider-bin-dir: /var/lib/kubelet/credential-provider image-credential-provider-config: /var/lib/kubelet/credential-provider-config.yaml + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell c:/create-external-network.ps1 diff --git a/templates/test/dev/cluster-template-custom-builds-windows.yaml b/templates/test/dev/cluster-template-custom-builds-windows.yaml index 04f47b12501..7fa53ebad2e 100644 --- a/templates/test/dev/cluster-template-custom-builds-windows.yaml +++ b/templates/test/dev/cluster-template-custom-builds-windows.yaml @@ -446,6 +446,21 @@ spec: owner: root:root path: c:/k/azure.json permissions: "0644" + - content: | + # This script restarts the kubelet service. + # It supports both nssm and Windows service configurations, + # ensuring a smooth transition between service managers without interruption. + # This script will eventually be removed once nssm is no longer used. + $scriptPath = "$env:SYSTEMDRIVE/k/RestartKubelet.ps1" + if (Test-Path $scriptPath) { + Write-Host "Found RestartKubelet.ps1, executing..." + & $scriptPath + } else { + Write-Host "RestartKubelet.ps1 not found. Running fallback command..." + & "$env:SYSTEMDRIVE\k\nssm.exe" set kubelet start SERVICE_AUTO_START + } + path: C:/KubeletRestart_nssm_sc.ps1 + permissions: "0744" - content: |- Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico-ipam.exe @@ -561,11 +576,12 @@ spec: feature-gates: ${NODE_FEATURE_GATES:-""} image-credential-provider-bin-dir: /var/lib/kubelet/credential-provider image-credential-provider-config: /var/lib/kubelet/credential-provider-config.yaml + register-with-taints: node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule v: "2" windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS name: '{{ ds.meta_data["local_hostname"] }}' postKubeadmCommands: - - nssm set kubelet start SERVICE_AUTO_START + - powershell C:/KubeletRestart_nssm_sc.ps1 - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell C:/create-temp-folder.ps1