kubeadm: kubeadm.exe fails on Windows Server 2022

BUG REPORT

Versions

kubeadm version: &version.Info{Major:"1", Minor:"29", GitVersion:"v1.29.4", GitCommit:"55019c83b0fd51ef4ced8c29eec2c4847f896e74", GitTreeState:"clean", BuildDate:"2024-04-16T15:05:51Z", GoVersion:"go1.21.9", Compiler:"gc", Platform:"windows/amd64"}

Environment:

Existing kubeadm cluster based on four Linux nodes running Ubuntu 22.04 as VMware VMs. Cluster works fine and everything is updated recently to Kubernetes version 1.29.4.

All nodes have 16 cores and 64 GB memory. They run containerd and networking is Calico. We use an external Ubuntu host running HA Proxy as a load balancer for the API server. The four node cluster works fine.

What happened?

We need support for Windows containers as well, so I’m trying to add a Windows Server 2022 based host to the cluster. And this is where the fun starts. The new Windows host has 16 cores/64 GB as well, and it’s running in the same VMware cluster.

I hope (and believe) I’ve done the preparation of the Win host properly - primarily based on documentation from these sources:

https://k8s-docs.netlify.app/en/docs/setup/production-environment/windows/user-guide-windows-nodes/ https://docs.tigera.io/calico/latest/getting-started/kubernetes/windows-calico/operator

But when I try to run

PS C:\Windows\system32> kubeadm join kube-cph.bogus.com:6443 --token ue62yc.ks285c6i4vr4cy1n --discovery-token-ca-cert-hash sha256:8deeb01d3a1a7fbad9d3708405c503d458f32beba5b36294a284cce8d46fbf1f
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR IsPrivilegedUser]: user is not running as administrator
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

I am running as a user with Admin permissions and in a PowerShell session with elevated permissions. Every utility we can think of confirms that this is a session with full administrative rights.

If I ignore the error above, preflight will continue and emit a whole cascade of new errors, all Linux related and all showing clear signs that kubeadm believes it’s running on Linux.

But nevertheless

kubeadm version: &version.Info{Major:"1", Minor:"29", GitVersion:"v1.29.4", GitCommit:"55019c83b0fd51ef4ced8c29eec2c4847f896e74", GitTreeState:"clean", BuildDate:"2024-04-16T15:05:51Z", GoVersion:"go1.21.9", Compiler:"gc", Platform:"windows/amd64"}

states that platform is “windows/amd64”.

What you expected to happen?

I would expect the node to join the cluster.

How to reproduce it (as minimally and precisely as possible)?

Create a new Linux based kubeadm cluster. Verify that it runs fine. Setup a new Windows Server 2022 host with containerd. Try to add it to the cluster using kubeadm join.

Anything else we need to know?

I have asked for help in the Slack channel “Kubernetes/kubeadm”, but except for friendly interest I’ve had no response.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 21 (12 by maintainers)

Most upvoted comments

Eh - yes - I very much agree on that.

My comment was about trying to emphasize the importance of this problem: Even though it can be solved by adding people as local admins, this is an insecure and error prone workaround.

But that doesn’t matter now: You seem to have found an excellent solution.

or is there another hack we can use from what windows/x exposes? https://golang.org/x/sys/windows

this works and it’s the canonical UAC way:

package main

import (
	"fmt"

	"golang.org/x/sys/windows"
)

func isPrivProcess() (bool, error) {
	hProcess := windows.CurrentProcess()
	var hProcessToken windows.Token
	err := windows.OpenProcessToken(hProcess, windows.TOKEN_QUERY, &hProcessToken)
	if err != nil {
		return false, err
	}
	return hProcessToken.IsElevated(), nil
}

func main() {
	val, err := isPrivProcess()
	fmt.Println(val, err)
}

IsElevated() calls GetTokenInformation with TOKEN_ELEVATION which is valid; https://cs.opensource.google/go/x/sys/+/refs/tags/v0.19.0:windows/security_windows.go;l=759

i will change the kubeadm preflight check to this in 1.31.

It is pretty well tested at this point. We run our sig-windows tests using kubeadm via cluster-api-for-azure. An example test: https://testgrid.k8s.io/sig-windows-master-release#capz-windows-2022-master

yes, i edited my comment as i forgot that kubeadm is used in CAPZ.

I don’t really know the history of this check or why/if we need local admin. @marosset any ideas?

my guess is the following:

kubeadm has some service manager code (on Linux this “init system” is systemd) to start the kubelet. https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/util/initsystem/initsystem_windows.go

it uses golang.org/x/sys/windows/svc/mgr which wraps the OpenSCManager/OpenService WINAPI https://learn.microsoft.com/en-us/windows/win32/services/starting-a-service, and it think it fails if the user is not in the S-1-5-32-544 group.

i don’t think we should move away from managing the kubelet as a service or stop using golang.org/x/sys/windows/svc/mgr, so this seems to be a requirement and wont-fix.