-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
[wip] Kubeadm updates for Windows and Containerd #32862
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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -17,8 +17,6 @@ weight: 30 | |||||||
You can use Kubernetes to run a mixture of Linux and Windows nodes, so you can mix Pods that run on Linux on with Pods that run on Windows. This page shows how to register Windows nodes to your cluster. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
## {{% heading "prerequisites" %}} | ||||||||
{{< version-check >}} | ||||||||
|
||||||||
|
@@ -29,17 +27,11 @@ If you are using VXLAN/Overlay networking you must have also have [KB4489899](ht | |||||||
* A Linux-based Kubernetes kubeadm cluster in which you have access to the control plane (see [Creating a single control-plane cluster with kubeadm](/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/)). | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
## {{% heading "objectives" %}} | ||||||||
|
||||||||
|
||||||||
* Register a Windows node to the cluster | ||||||||
* Configure networking so Pods and Services on Linux and Windows can communicate with each other | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
<!-- lessoncontent --> | ||||||||
|
||||||||
## Getting Started: Adding a Windows Node to Your Cluster | ||||||||
|
@@ -107,89 +99,123 @@ Once you have a Linux-based Kubernetes control-plane node you are ready to choos | |||||||
kube-system kube-flannel-ds-54954 1/1 Running 0 1m | ||||||||
``` | ||||||||
|
||||||||
1. Add Windows Flannel and kube-proxy DaemonSets | ||||||||
|
||||||||
Now you can add Windows-compatible versions of Flannel and kube-proxy. In order | ||||||||
to ensure that you get a compatible version of kube-proxy, you'll need to substitute | ||||||||
the tag of the image. The following example shows usage for Kubernetes {{< param "fullversion" >}}, | ||||||||
but you should adjust the version for your own deployment. | ||||||||
|
||||||||
```bash | ||||||||
curl -L https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/kube-proxy.yml | sed 's/VERSION/{{< param "fullversion" >}}/g' | kubectl apply -f - | ||||||||
kubectl apply -f https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-overlay.yml | ||||||||
``` | ||||||||
{{< note >}} | ||||||||
If you're using host-gateway use https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-host-gw.yml instead | ||||||||
{{< /note >}} | ||||||||
|
||||||||
{{< note >}} | ||||||||
If you're using a different interface rather than Ethernet (i.e. "Ethernet0 2") on the Windows nodes, you have to modify the line: | ||||||||
### Joining a Windows worker node | ||||||||
|
||||||||
```powershell | ||||||||
wins cli process run --path /k/flannel/setup.exe --args "--mode=overlay --interface=Ethernet" | ||||||||
``` | ||||||||
{{< note >}} | ||||||||
All code snippets in Windows sections are to be run in a PowerShell environment | ||||||||
with elevated permissions (Administrator) on the Windows worker node unless otherwise noted. | ||||||||
{{< /note >}} | ||||||||
|
||||||||
in the `flannel-host-gw.yml` or `flannel-overlay.yml` file and specify your interface accordingly. | ||||||||
{{< tabs name="tab-windows-kubeadm-runtime-installation" >}} | ||||||||
|
||||||||
```bash | ||||||||
# Example | ||||||||
curl -L https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-overlay.yml | sed 's/Ethernet/Ethernet0 2/g' | kubectl apply -f - | ||||||||
``` | ||||||||
{{< /note >}} | ||||||||
{{% tab name="CRI-containerD" %}} | ||||||||
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. Why the name 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. I am not sure. This tab existed prior and I moved it. Should we rename it to simply 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. I think I might have added this (or maybe it was Patrick). |
||||||||
|
||||||||
### Intro | ||||||||
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. We never have a heading “introduction” in our documentation. Actual introductory text should appear before the first heading at Please reword this heading. Alternatively, you can list prerequisites under the Prerequisites heading (line 20 ish). |
||||||||
|
||||||||
The following instructions are require HostProcess container support with Kubernetes 1.22+. If you do not support HostProcess containers in you cluster you can install Flannel and kube-proxy as windows services directly on the host. | ||||||||
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. This isn't idiomatic English; also, the emphasis on Flannel is problematic (see other comments). Do we need this extra text here? |
||||||||
|
||||||||
### Joining a Windows worker node | ||||||||
The Before running any of these step the Windows node should have the following Windows Features installed: `Containers`,`Hyper-V`,`Hyper-V-PowerShell`. These can be installed using the Powershell `Install-WindowsFeature` command. | ||||||||
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. You can list prerequisites under the Prerequisites heading (line 20 ish). Also, PowerShell has a capital |
||||||||
|
||||||||
{{< note >}} | ||||||||
All code snippets in Windows sections are to be run in a PowerShell environment | ||||||||
with elevated permissions (Administrator) on the Windows worker node. | ||||||||
The following instructions are the manual steps to configure nodes. You can use the [image-builder](https://image-builder.sigs.k8s.io/capi/windows/windows.html) used as part of the Cluster Api project implements the following along with other optimizations. | ||||||||
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. This isn't the right place to introduce the cluster API. I would mention Cluster API in the What's Next section of that page, or under https://kubernetes.io/docs/setup/production-environment/ |
||||||||
{{< /note >}} | ||||||||
|
||||||||
{{< tabs name="tab-windows-kubeadm-runtime-installation" >}} | ||||||||
#### Install containerD | ||||||||
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. Can this be a third-level heading? |
||||||||
|
||||||||
{{% tab name="CRI-containerD" %}} | ||||||||
Follow the instructions for [installing the Containerd runtime on Windows using powershell](../../../setup/production-environment/container-runtimes.md#containerd) | ||||||||
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. Don't use |
||||||||
|
||||||||
#### Install containerD | ||||||||
#### Install kubelet | ||||||||
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. Can this be a third-level heading? |
||||||||
|
||||||||
```powershell | ||||||||
curl.exe -LO https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/Install-Containerd.ps1 | ||||||||
.\Install-Containerd.ps1 | ||||||||
Kubeadm sets some flags via a environment file. To support this it is common to use [nssm](https://nssm.cc/) to configure kubelet. To install nssm do the following: | ||||||||
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.
Consider using tabs to explain the approach without Avoid recommending that readers create a directory |
||||||||
|
||||||||
``` powershell | ||||||||
mkdir c:\k | ||||||||
$arch = "win64" | ||||||||
curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip | ||||||||
tar.exe C c:\k\ -xvf .\nssm.zip --strip-components 2 */$arch/*.exe | ||||||||
``` | ||||||||
Comment on lines
+131
to
136
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. We should hyperlink to https://nssm.cc/download and recommend that readers follow the external tool's docs on how to download and install it. I believe that https://nssm.cc/release/nssm-2.24.zip is the canonical download URI for v2.24 We really should not be recommending to readers that they download and run tools from noncanonical sources. SIG Security have opinions on this and I believe those opinions are similar to “yeah, don't do that”. |
||||||||
|
||||||||
{{< note >}} | ||||||||
To install a specific version of containerD specify the version with -ContainerDVersion. | ||||||||
Next we will set `$KubernetesVersion` to the desired version (ex: `$KubernetesVersion="v1.24.0"`), and then run the following commands to install kubelet: | ||||||||
|
||||||||
``` powerShell | ||||||||
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. For code formatting, write 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. and I think no space after the backticks? (or maybe that doesn't matter) |
||||||||
curl.exe -L https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe -o c:\k\kubelet.exe | ||||||||
|
||||||||
@" | ||||||||
# Start file needed to support kubeadm extra args | ||||||||
`$FileContent = Get-Content -Path "/var/lib/kubelet/kubeadm-flags.env" | ||||||||
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. Is |
||||||||
`$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)", | ||||||||
"--enable-debugging-handlers", | ||||||||
"--cgroups-per-qos=false", | ||||||||
"--enforce-node-allocatable=``"``"", | ||||||||
"--resolv-conf=``"``"" | ||||||||
|
||||||||
`$kubeletCommandLine = "c:\k\kubelet.exe " + (`$args -join " ") + " `$kubeAdmArgs" | ||||||||
Invoke-Expression `$kubeletCommandLine | ||||||||
"@ | Set-Content -Path c:\k\Start-kubelet.ps1 | ||||||||
|
||||||||
c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1 | ||||||||
c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log | ||||||||
c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log | ||||||||
``` | ||||||||
|
||||||||
```powershell | ||||||||
# Example | ||||||||
.\Install-Containerd.ps1 -ContainerDVersion 1.4.1 | ||||||||
We need to open a firewall port: | ||||||||
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.
|
||||||||
|
||||||||
``` | ||||||||
New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 | ||||||||
``` | ||||||||
|
||||||||
If you're using a different interface rather than Ethernet (i.e. "Ethernet0 2") on the Windows nodes, specify the name with `-netAdapterName`. | ||||||||
Verify kubelet is installed with `Get-service kubelet`. Kubeadm will start kubelet during joining the node. | ||||||||
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
|
||||||||
|
||||||||
```powershell | ||||||||
# Example | ||||||||
.\Install-Containerd.ps1 -netAdapterName "Ethernet0 2" | ||||||||
``` | ||||||||
Get-Service kubelet | ||||||||
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. Don't include the command in the sample output. |
||||||||
Status Name DisplayName | ||||||||
------ ---- ----------- | ||||||||
Stopped kubelet kubelet | ||||||||
``` | ||||||||
|
||||||||
{{< /note >}} | ||||||||
#### Install kubeadm | ||||||||
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. Can this be a third-level heading? |
||||||||
|
||||||||
#### Install wins, kubelet, and kubeadm | ||||||||
Start a Powershell session, set `$KubernetesVersion` to the desired version (ex: `$KubernetesVersion="v1.24.0"`), and then run the following commands: | ||||||||
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
|
||||||||
|
||||||||
```PowerShell | ||||||||
curl.exe -LO https://raw.githubusercontent.com/kubernetes-sigs/sig-windows-tools/master/kubeadm/scripts/PrepareNode.ps1 | ||||||||
.\PrepareNode.ps1 -KubernetesVersion {{< param "fullversion" >}} -ContainerRuntime containerD | ||||||||
``` | ||||||||
|
||||||||
[Install `crictl` from the cri-tools package](https://github.com/kubernetes-sigs/cri-tools) | ||||||||
which is required so that kubeadm can talk to the CRI endpoint. | ||||||||
curl.exe -L https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubeadm.exe -o c:\k\kubeadm.exe | ||||||||
``` | ||||||||
|
||||||||
#### Run `kubeadm` to join the node | ||||||||
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. Can this be a third-level heading? |
||||||||
|
||||||||
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. This should mention that the example uses containerd. |
||||||||
Use the command that was given to you when you ran `kubeadm init` on a control plane host. | ||||||||
Use the command that was given to you when you ran `kubeadm init` on a control plane host. You will need to add `--cri-socket "npipe:////./pipe/containerd-containerd"` to tell kubeadm to use the correct containerd pipe. | ||||||||
|
||||||||
The command will look like: | ||||||||
|
||||||||
``` | ||||||||
./kubeadm.exe join 10.240.0.10:6443 --token <your token> --discovery-token-ca-cert-hash sha256:<your hash> --cri-socket "npipe:////./pipe/containerd-containerd" | ||||||||
``` | ||||||||
|
||||||||
If you no longer have this command, or the token has expired, you can run `kubeadm token create --print-join-command` | ||||||||
(on a control plane host) to generate a new token and join command. | ||||||||
|
||||||||
#### Install Flannel CNI DaemonSet | ||||||||
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.
|
||||||||
|
||||||||
We will leverage host-process containers to run flannel as a DaemonSet: | ||||||||
|
||||||||
``` | ||||||||
kubectl apply -f https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-overlay-hpc.yml | ||||||||
``` | ||||||||
|
||||||||
#### Install kube-proxy DaemonSet | ||||||||
|
||||||||
We will leverage host-process containers to run kube-proxy as a DaemonSet. This can be run from any Linux machine that has kubectl installed with its context configured to your new cluster. | ||||||||
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.
|
||||||||
|
||||||||
``` powershell | ||||||||
curl -L https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/kube-proxy-flannel-hpc.yml | sed 's/KUBERNETES_VERSION/v1.23.5/g' | kubectl apply -f - | ||||||||
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. Should we have a floating image tag for latest patch release for each minor version (in addition to a tag for each major/minor/patch)? If we do that we can use 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. Avoid recommending that readers fetch things using |
||||||||
``` | ||||||||
|
||||||||
{{% /tab %}} | ||||||||
|
||||||||
{{% tab name="Docker Engine" %}} | ||||||||
|
@@ -226,6 +252,35 @@ curl.exe -LO https://raw.githubusercontent.com/kubernetes-sigs/sig-windows-tools | |||||||
.\PrepareNode.ps1 -KubernetesVersion {{< param "fullversion" >}} | ||||||||
``` | ||||||||
|
||||||||
#### Add Windows Flannel and kube-proxy DaemonSets | ||||||||
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.
|
||||||||
|
||||||||
Now you can add Windows-compatible versions of Flannel and kube-proxy. In order | ||||||||
to ensure that you get a compatible version of kube-proxy, you'll need to substitute | ||||||||
the tag of the image. The following example shows usage for Kubernetes {{< param "fullversion" >}}, | ||||||||
but you should adjust the version for your own deployment. | ||||||||
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
|
||||||||
|
||||||||
```bash | ||||||||
curl -L https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/kube-proxy.yml | sed 's/VERSION/{{< param "fullversion" >}}/g' | kubectl apply -f - | ||||||||
kubectl apply -f https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-overlay.yml | ||||||||
Comment on lines
+263
to
+264
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. Avoid recommending that readers fetch things using |
||||||||
``` | ||||||||
{{< note >}} | ||||||||
If you're using host-gateway use https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-host-gw.yml instead | ||||||||
{{< /note >}} | ||||||||
|
||||||||
{{< note >}} | ||||||||
If you're using a different interface rather than Ethernet (i.e. "Ethernet0 2") on the Windows nodes, you have to modify the line: | ||||||||
|
||||||||
```powershell | ||||||||
wins cli process run --path /k/flannel/setup.exe --args "--mode=overlay --interface=Ethernet" | ||||||||
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. Avoid recommending that readers create a directory |
||||||||
``` | ||||||||
|
||||||||
in the `flannel-host-gw.yml` or `flannel-overlay.yml` file and specify your interface accordingly. | ||||||||
|
||||||||
```bash | ||||||||
# Example | ||||||||
curl -L https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-overlay.yml | sed 's/Ethernet/Ethernet0 2/g' | kubectl apply -f - | ||||||||
``` | ||||||||
|
||||||||
#### Run `kubeadm` to join the node | ||||||||
|
||||||||
Use the command that was given to you when you ran `kubeadm init` on a control plane host. | ||||||||
|
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 recommend using an example that is deliberately not valid, and then helping the reader work out the right version.
Also, this page is likely to change: see #32738