Skip to content
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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ installing the `containerd.io` package can be found at
{{% /tab %}}
{{% tab name="Windows (PowerShell)" %}}

Start a Powershell session, set `$Version` to the desired version (ex: `$Version="1.4.3"`),
Start a Powershell session, set `$Version` to the desired version (ex: `$Version="1.6.2"`),
Copy link
Contributor

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

and then run the following commands:

1. Download containerd:
Expand Down
177 changes: 116 additions & 61 deletions content/en/docs/tasks/administer-cluster/kubeadm/adding-windows-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}

Expand All @@ -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
Expand Down Expand Up @@ -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" %}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the name CRI-containerD? That's not how most people name that container runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 containerd?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I might have added this (or maybe it was Patrick).
We can just call it containerd like everywhere else.


### Intro
Copy link
Contributor

Choose a reason for hiding this comment

The 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 <h2> level.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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 S.


{{< 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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use .. in hyperlinks. Use site-relative paths.


#### Install containerD
#### Install kubelet
Copy link
Contributor

Choose a reason for hiding this comment

The 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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nssm is third-party software; this will need a third party software disclaimer.

Consider using tabs to explain the approach without nssm and the approach where it is used; default to the “without” approach because nssm is not part of Kubernetes.

Avoid recommending that readers create a directory k directly under C:\; this does not represent good practice.


``` 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code formatting, write powershell all-lowercase.

Copy link
Contributor

Choose a reason for hiding this comment

The 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is /var/lib/kubelet/kubeadm-flags.env definitely the right path to use here?

`$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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please address the reader as you.
  • Allow TCP traffic to the kubelet from the API server
    • Allowing traffic from anywhere might not be as secure as readers imagine; the page should explain how to restrict that traffic to the API server hosts only, or caution the reader about the risks this implies.


```
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Verify kubelet is installed with `Get-service kubelet`. Kubeadm will start kubelet during joining the node.
Verify that kubelet is installed, by running `Get-Service kubelet`. The kubeadm tool starts the kubelet during the node join process. The output from `Get-Service` is similar to:


```powershell
# Example
.\Install-Containerd.ps1 -netAdapterName "Ethernet0 2"
```
Get-Service kubelet
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Start a Powershell session, set `$KubernetesVersion` to the desired version (ex: `$KubernetesVersion="v1.24.0"`), and then run the following commands:
Start a PowerShell session. Set `$KubernetesVersion` to the desired version (for example: `$KubernetesVersion="v1.24.0"`), and then run the following commands:


```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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a third-level heading?


Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Because Flannel is not part of Kubernetes, this doesn't comply with our content guide. Please read https://kubernetes.io/blog/2020/05/third-party-dual-sourced-content/ for context.
    Make sure to include the relevant third-party shortcode as part of this page rewrite.
  • Setting up networking is not specific to containerd, so this advice seems to be in the wrong place.


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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please address the reader as you.
  • Setting up networking is not specific to containerd, so this advice seems to be in the wrong place.
  • Can you run kubectl on Windows, or does it require Linux?


``` 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 -
Copy link
Contributor

Choose a reason for hiding this comment

The 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 v{{< skew currentVersion >}} instead of hardcoding the K8s version to use in the sec command here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid recommending that readers fetch things using curl and then apply those manifests to production clusters.
If there's no reasonable alternative, explain that readers should verify the manifest before they apply it.

```

{{% /tab %}}

{{% tab name="Docker Engine" %}}
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Because Flannel is not part of Kubernetes, this doesn't comply with our content guide. Please read https://kubernetes.io/blog/2020/05/third-party-dual-sourced-content/ for context.
    Make sure to include the relevant third-party shortcode as part of this page rewrite.
  • Setting up networking is not specific to containerd, so this advice seems to be in the wrong place.
  • Overall, it might be better to link to the Flannel docs about how to set that up on a Windows node.
    • If those docs don't exist, make them (in the Flannel docs) and then hyperlink to the page you made.


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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
but you should adjust the version for your own deployment.
however, if you are running a different version of Kubernetes, you should consult the
documentation for that release instead.


```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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid recommending that readers fetch things using curl and then apply those manifests to production clusters.
If there's no reasonable alternative, explain that readers should verify the manifest before they apply it.

```
{{< 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid recommending that readers create a directory k directly under C:\; this does not represent good practice.

```

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.
Expand Down