Skip to content

Commit 5cfc90d

Browse files
authored
Guide for Adding Windows Node (#236)
Adding a guide to help new users to add a Windows node to the cluster
1 parent ba81c7a commit 5cfc90d

File tree

2 files changed

+304
-0
lines changed

2 files changed

+304
-0
lines changed
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
2+
# Adding Windows nodes
3+
4+
5+
6+
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 is a guide on how to register Windows nodes to your cluster.
7+
8+
9+
10+
## Before you begin
11+
12+
13+
14+
Your Kubernetes server must be at or later than version 1.22. To check the version, enter `kubectl version`.
15+
16+
17+
18+
- Obtain a [Windows Server 2019 license](https://www.microsoft.com/en-us/cloud-platform/windows-server-pricing) (or higher) in order to configure the Windows node that hosts Windows containers. If you are using VXLAN/Overlay networking you must have also have [KB4489899](https://support.microsoft.com/help/4489899) installed.
19+
20+
- A Linux-based Kubernetes kubeadm cluster in which you have access to the control plane (see [Creating a single control-plane cluster with kubeadm](https://kubernetes-docsy-staging.netlify.app/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/)).
21+
22+
23+
24+
## Objectives
25+
26+
27+
28+
- Register a Windows node to the cluster
29+
30+
- Configure networking so Pods and Services on Linux and Windows can communicate with each other
31+
32+
33+
34+
## Getting Started: Adding a Windows Node to Your Cluster
35+
36+
37+
38+
### Networking Configuration
39+
40+
41+
42+
Once you have a Linux-based Kubernetes control-plane node you are ready to choose a networking solution.
43+
44+
45+
46+
#### Configuring Flannel with rancher
47+
48+
49+
50+
1. Prepare Kubernetes control plane for Flannel
51+
52+
Some minor preparation is recommended on the Kubernetes control plane in our cluster. It is recommended to enable bridged IPv4 traffic to iptables chains when using Flannel. The following command must be run on all Linux nodes:
53+
54+
```bash
55+
56+
sudo sysctl net.bridge.bridge-nf-call-iptables=1
57+
58+
```
59+
60+
2. Download & configure Flannel for Linux
61+
62+
Download the most recent Flannel manifest:
63+
64+
```bash
65+
66+
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
67+
68+
```
69+
70+
Modify the `net-conf.json` section of the flannel manifest in order to set the VNI to 4096 and the Port to 4789. It should look as follows:
71+
72+
```json
73+
74+
net-conf.json: |
75+
76+
{
77+
78+
"Network": "10.244.0.0/16",
79+
80+
"Backend": {
81+
82+
"Type": "vxlan",
83+
84+
"VNI" : 4096,
85+
86+
"Port": 4789
87+
88+
}
89+
90+
}
91+
92+
```
93+
94+
> **Note:** The VNI must be set to 4096 and port 4789 for Flannel on Linux to interoperate with Flannel on Windows. See the [VXLAN documentation](https://github.com/coreos/flannel/blob/master/Documentation/backends.md#vxlan). for an explanation of these fields.
95+
96+
> **Note:** To use L2Bridge/Host-gateway mode instead change the value of `Type` to `"host-gw"` and omit `VNI` and `Port`.
97+
98+
3. Apply the Flannel manifest and validate
99+
100+
Let's apply the Flannel configuration:
101+
102+
```bash
103+
104+
kubectl apply -f kube-flannel.yml
105+
106+
```
107+
108+
After a few minutes, you should see all the pods as running if the Flannel pod network was deployed.
109+
110+
```bash
111+
112+
kubectl get pods -n kube-system
113+
114+
```
115+
116+
The output should include the Linux flannel DaemonSet as running:
117+
118+
```
119+
120+
NAMESPACE NAME READY STATUS RESTARTS AGE
121+
122+
...
123+
124+
kube-system kube-flannel-ds-54954 1/1 Running 0 1m
125+
126+
```
127+
128+
4. Add Windows Flannel and kube-proxy DaemonSets
129+
130+
131+
132+
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 v1.24.3, but you should adjust the version for your own deployment.
133+
134+
135+
136+
```bash
137+
138+
curl -L https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/kube-proxy.yml | sed 's/VERSION/v1.24.3/g' | kubectl apply -f -
139+
140+
kubectl apply -f https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/flannel-overlay.yml
141+
142+
```
143+
144+
> **Note** If you are using another version of kubernetes on your windows node, change v1.24.3 with your own version .
145+
146+
> To find your version of kubernetes run the following command:
147+
148+
> `kubeadm version`
149+
5. Apply kube-flannel-rbac.yml from sig-windows-tools/kubeadm/flannel
150+
Next you will need to apply the configuration that allows flannel to spawn pods and keep them running:
151+
```bash
152+
git clone https://github.com/kubernetes-sigs/sig-windows-tools
153+
kubectl apply -f sig-windows-tools/kubeadm/flannel/kube-flannel-rbac.yml
154+
```
155+
156+
### Joining a Windows worker node
157+
158+
159+
160+
> **Note:** All code snippets in Windows sections are to be run in a PowerShell environment with elevated permissions (Administrator) on the Windows worker node.
161+
162+
163+
164+
1. Install ContainerD, wins, kubelet, and kubeadm.
165+
166+
```PowerShell
167+
168+
git clone https://github.com/kubernetes-sigs/sig-windows-tools
169+
170+
cd .\sig-windows-tools\kubeadm\scripts\
171+
172+
# Install ContainerD
173+
174+
.\Install-Containerd.ps1
175+
176+
# Install wins, kubelet and kubeadm
177+
178+
.\PrepareNode.ps1 -KubernetesVersion v1.24.3 -ContainerRuntime containerD
179+
180+
```
181+
182+
> **Note** If you want to install another version of kubernetes, modify v1.24.3 with the version you want to install
183+
184+
185+
2. Run `kubeadm` to join the node
186+
> **Note** Before joining the node, copy the file from /run/flannel/subnet.env to your windows machine to C:\run\flannel\subnet.env
187+
> You will need to create the folders for it
188+
189+
Use the command that was given to you when you ran `kubeadm init` on a control plane host. 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.
190+
191+
> **Note:** Do not forget to add `--cri-socket "npipe:////./pipe/containerd-containerd" --v=5` at the end of the join command, if you use ContainerD
192+
193+
194+
195+
3. Install kubectl for windows (optional)
196+
197+
For more information about it : https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/
198+
199+
200+
201+
#### Verifying your installation
202+
203+
204+
205+
You should now be able to view the Windows node in your cluster by running:
206+
207+
208+
209+
```bash
210+
211+
kubectl get nodes -o wide
212+
213+
```
214+
215+
216+
217+
If your new node is in the `NotReady` state it is likely because the flannel image is still downloading. You can check the progress as before by checking on the flannel pods in the `kube-system` namespace:
218+
219+
220+
221+
```shell
222+
223+
kubectl -n kube-system get pods -l app=flannel
224+
225+
```
226+
227+
228+
229+
Once the flannel Pod is running, your node should enter the `Ready` state and then be available to handle workloads.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
kind: ClusterRole
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: flannel
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- pods
11+
verbs:
12+
- get
13+
- apiGroups:
14+
- ""
15+
resources:
16+
- nodes
17+
verbs:
18+
- list
19+
- watch
20+
- apiGroups:
21+
- ""
22+
resources:
23+
- nodes/status
24+
verbs:
25+
- patch
26+
---
27+
kind: ClusterRoleBinding
28+
apiVersion: rbac.authorization.k8s.io/v1
29+
metadata:
30+
name: flannel
31+
roleRef:
32+
apiGroup: rbac.authorization.k8s.io
33+
kind: ClusterRole
34+
name: flannel
35+
subjects:
36+
- kind: ServiceAccount
37+
name: flannel
38+
namespace: kube-system
39+
---
40+
kind: ConfigMap
41+
apiVersion: v1
42+
metadata:
43+
name: kube-flannel-cfg
44+
namespace: kube-system
45+
labels:
46+
tier: node
47+
app: flannel
48+
data:
49+
cni-conf.json: |
50+
{
51+
"name": "cbr0",
52+
"plugins": [
53+
{
54+
"type": "flannel",
55+
"delegate": {
56+
"hairpinMode": true,
57+
"isDefaultGateway": true
58+
}
59+
},
60+
{
61+
"type": "portmap",
62+
"capabilities": {
63+
"portMappings": true
64+
}
65+
}
66+
]
67+
}
68+
net-conf.json: |
69+
{
70+
"Network": "10.244.0.0/16",
71+
"Backend": {
72+
"Type": "vxlan"
73+
}
74+
}
75+
---

0 commit comments

Comments
 (0)