如何在Windows Server 2019上安装Kubernetes?预览版功能咨询
Hey Benjamin, totally get the confusion here—when that preview dropped, Microsoft’s docs were a bit scattered, and the feature wasn’t exactly "turnkey" out of the box. Let’s break this down clearly:
First, to answer your last question: Kubernetes support was announced for Windows Server 2019, but in the early preview builds, it was a hidden technical preview feature that required manual setup—it wasn’t enabled by default, which is why you couldn’t find it right away.
Here’s a step-by-step guide that should work for your Hyper-V VM with Desktop Experience:
Prerequisites
- Make sure your Windows Server 2019 Preview VM is running the latest preview build (Slow or Fast Ring). Run this in an elevated PowerShell to force updates:
wuauclt /detectnow /updatenow - Enable nested virtualization on your Hyper-V VM (critical for containers/K8s to work properly). On your host machine’s PowerShell:
Then restart the VM.Set-VMProcessor -VMName "Your VM Name" -ExposeVirtualizationExtensions $true
Step 1: Enable Required Windows Features
Open an elevated PowerShell on your VM and run these commands:
- Install the Containers feature:
Install-WindowsFeature -Name Containers -IncludeManagementTools - Enable the Kubernetes technical preview component:
Enable-WindowsOptionalFeature -Online -FeatureName Containers-Kubernetes -All - Restart the VM to apply changes:
Restart-Computer -Force
Step 2: Initialize the Kubernetes Cluster
After the VM restarts, open another elevated PowerShell:
- Initialize the control plane (this sets up a single-node cluster, which was the only supported setup in early previews):
kubeadm init --pod-network-cidr=10.244.0.0/16 - Configure
kubectlfor your user account:mkdir -p $HOME/.kube Copy-Item -Path /etc/kubernetes/admin.conf -Destination $HOME/.kube/config Set-ItemProperty -Path $HOME/.kube/config -Name IsReadOnly -Value $false
Step 3: Install a Pod Network Plugin
Windows nodes in early previews only supported specific network plugins—Flannel was the most reliable option:
- Obtain the Flannel configuration file (
kube-flannel.yml) optimized for Windows nodes (this file is available in the official Flannel project resources). - Apply the config to your cluster using:
kubectl apply -f kube-flannel.yml - Wait 5-10 minutes, then verify all pods are running:
kubectl get pods --all-namespaces
Common Gotchas to Watch For
- If you get an error that the
Containers-Kubernetesfeature doesn’t exist, your preview build is too old. Grab the latest Windows Server 2019 Preview ISO and redeploy your VM. - Early previews only supported single-node clusters. Multi-node Windows K8s support came later in the preview cycle.
- Make sure your VM has at least 4GB of RAM—Kubernetes and containers need a decent amount of resources to run smoothly.
Hope this gets you up and running!
内容的提问来源于stack exchange,提问作者Benjamin Abt

