mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #65194 from luxas/kubeadm_fix_skip_preflight
Automatic merge from submit-queue (batch tested with PRs 64713, 65193, 65194). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. kubeadm: Fix a bug where skipping all preflight checks wouldn't activate the kubelet **What this PR does / why we need it**: Running `kubeadm init --skip-preflight-checks` or `--ignore-preflight-errors=all` kind of deterministically fails, as the kubelet service isn't started by kubeadm. This breaks most users' view of that kubeadm should do it automatically, instead of forcing the user to run a `systemctl daemon-reload && systemctl restart kubelet` during `kubeadm init' or `kubeadm join`. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` @kubernetes/sig-cluster-lifecycle-pr-reviews /kind bug /priority critical-urgent /milestone v1.11 /status approved-for-milestone
This commit is contained in:
commit
8f02de7de0
@ -297,7 +297,7 @@ func (i *Init) Run(out io.Writer) error {
|
||||
// Try to stop the kubelet service so no race conditions occur when configuring it
|
||||
if !i.dryRun {
|
||||
glog.V(1).Infof("Stopping the kubelet")
|
||||
preflight.TryStopKubelet(i.ignorePreflightErrors)
|
||||
preflight.TryStopKubelet()
|
||||
}
|
||||
|
||||
// Write env file with flags for the kubelet to use. We do not need to write the --register-with-taints for the master,
|
||||
@ -315,7 +315,7 @@ func (i *Init) Run(out io.Writer) error {
|
||||
if !i.dryRun {
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
glog.V(1).Infof("Starting the kubelet")
|
||||
preflight.TryStartKubelet(i.ignorePreflightErrors)
|
||||
preflight.TryStartKubelet()
|
||||
}
|
||||
|
||||
// certsDirToWriteTo is gonna equal cfg.CertificatesDir in the normal case, but gonna be a temp directory if dryrunning
|
||||
|
@ -281,7 +281,7 @@ func (j *Join) Run(out io.Writer) error {
|
||||
// Configure the kubelet. In this short timeframe, kubeadm is trying to stop/restart the kubelet
|
||||
// Try to stop the kubelet service so no race conditions occur when configuring it
|
||||
glog.V(1).Infof("Stopping the kubelet")
|
||||
preflight.TryStopKubelet(j.ignorePreflightErrors)
|
||||
preflight.TryStopKubelet()
|
||||
|
||||
// Write the configuration for the kubelet (using the bootstrap token credentials) to disk so the kubelet can start
|
||||
if err := kubeletphase.DownloadConfig(bootstrapClient, kubeletVersion, kubeadmconstants.KubeletRunDirectory); err != nil {
|
||||
@ -295,7 +295,7 @@ func (j *Join) Run(out io.Writer) error {
|
||||
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
glog.V(1).Infof("Starting the kubelet")
|
||||
preflight.TryStartKubelet(j.ignorePreflightErrors)
|
||||
preflight.TryStartKubelet()
|
||||
|
||||
// Now the kubelet will perform the TLS Bootstrap, transforming /etc/kubernetes/bootstrap-kubelet.conf to /etc/kubernetes/kubelet.conf
|
||||
// Wait for the kubelet to create the /etc/kubernetes/kubelet.conf KubeConfig file. If this process
|
||||
|
@ -1053,10 +1053,7 @@ func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String
|
||||
|
||||
// TryStartKubelet attempts to bring up kubelet service
|
||||
// TODO: Move these kubelet start/stop functions to some other place, e.g. phases/kubelet
|
||||
func TryStartKubelet(ignorePreflightErrors sets.String) {
|
||||
if setHasItemOrAll(ignorePreflightErrors, "StartKubelet") {
|
||||
return
|
||||
}
|
||||
func TryStartKubelet() {
|
||||
// If we notice that the kubelet service is inactive, try to start it
|
||||
initSystem, err := initsystem.GetInitSystem()
|
||||
if err != nil {
|
||||
@ -1077,10 +1074,7 @@ func TryStartKubelet(ignorePreflightErrors sets.String) {
|
||||
}
|
||||
|
||||
// TryStopKubelet attempts to bring down the kubelet service momentarily
|
||||
func TryStopKubelet(ignorePreflightErrors sets.String) {
|
||||
if setHasItemOrAll(ignorePreflightErrors, "StopKubelet") {
|
||||
return
|
||||
}
|
||||
func TryStopKubelet() {
|
||||
// If we notice that the kubelet service is inactive, try to start it
|
||||
initSystem, err := initsystem.GetInitSystem()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user