-
Notifications
You must be signed in to change notification settings - Fork 428
Make kubelet starting as a windows service #1752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ kubernetes_bins: | |
- kubeadm | ||
- kubectl | ||
- kubelet | ||
- kube-log-runner |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||
# Copyright 2025 The Kubernetes 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. | ||||
|
||||
# Need to keep sync with StartKubelet.ps1 | ||||
$FileContent = Get-Content -Path "$env:SYSTEMDRIVE/var/lib/kubelet/kubeadm-flags.env" | ||||
$kubeAdmArgs = $FileContent.TrimStart('KUBELET_KUBEADM_ARGS=').Trim('"') | ||||
|
||||
$args = "--cert-dir=$env:SYSTEMDRIVE/var/lib/kubelet/pki", | ||||
"--config=$env:SYSTEMDRIVE/var/lib/kubelet/config.yaml", | ||||
"--bootstrap-kubeconfig=$env:SYSTEMDRIVE/etc/kubernetes/bootstrap-kubelet.conf", | ||||
"--kubeconfig=$env:SYSTEMDRIVE/etc/kubernetes/kubelet.conf", | ||||
"--hostname-override=$(hostname)", | ||||
"--pod-infra-container-image=`"{{ pause_image }}`"", | ||||
"--enable-debugging-handlers", | ||||
"--cgroups-per-qos=false", | ||||
"--enforce-node-allocatable=`"`"", | ||||
"--resolv-conf=`"`"", | ||||
"--windows-service" | ||||
|
||||
$KubeletArgListStr = ($args -join " ") + " $kubeAdmArgs" | ||||
$KubeletArgListStr = $KubeletArgListStr.Replace("`"", "\`"") | ||||
# Used by sc.exe to create the service | ||||
$KubeletCommandLine = "`"" + "\`"" + "$env:SYSTEMDRIVE\k\kube-log-runner.exe" + "\`" " + "--log-file=/var/log/kubelet/kubelet.log " + "$env:SYSTEMDRIVE\k\kubelet.exe " + $KubeletArgListStr + "`"" | ||||
|
||||
# Write-Output $kubeletCommandLine | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer to keep it here as the parameters (kubeletcommdnline) send to sc.exe tend to be tricky, and we can use this to check that kind of commandline is used to start the kubelet service, when we need to do some debugging |
||||
$null = sc.exe stop kubelet | ||||
$null = sc.exe delete kubelet | ||||
for ($i = 0; $i -lt 10; $i++) { | ||||
$service = Get-Service -Name kubelet -ErrorAction SilentlyContinue | ||||
if ($null -eq $service) { | ||||
Write-Host "kubelet service deleted successfully, restarting" | ||||
sc.exe create kubelet binPath= $KubeletCommandLine start= auto depend= containerd | ||||
sc.exe start kubelet | ||||
return | ||||
} | ||||
else { | ||||
Write-Host "Waiting for service to be fully deleted... (attempt $($i + 1)/10)" | ||||
} | ||||
Start-Sleep -Seconds 3 | ||||
} | ||||
|
||||
|
||||
Write-Host "kubelet service failed to restart." |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
"prepull": "true", | ||
"runtime": "containerd", | ||
"ssh_source_url": "", | ||
"windows_service_manager": "nssm", | ||
"windows_service_manager": "windows_service", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or maybe I should make it applied to azure only in the begining? |
||
"windows_updates_categories": "", | ||
"windows_updates_kbs": "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this file in both sc.yml and nssm.yml? Only one is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will revert the change in sc.yaml as this is not the one we will use