Skip to content

Commit 37ca088

Browse files
authored
removing nat network from containerd config and pointing to WIP PR for configuring CNI w/ (#254)
containerd Signed-off-by: Mark Rossetti <[email protected]> Signed-off-by: Mark Rossetti <[email protected]>
1 parent f366740 commit 37ca088

File tree

4 files changed

+22
-94
lines changed

4 files changed

+22
-94
lines changed

guides/guide-for-adding-windows-node.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
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.
55

6+
## Warning
7+
8+
> The instructions and scripts in the directory DO NOT configure a CNI solution for Windows nodes running containerd.
9+
There is a work-in-progress PR to assist in this at https://github.com/kubernetes-sigs/sig-windows-tools/pull/239
610

711
## Before you begin
812

@@ -12,21 +16,17 @@ Your Kubernetes server must be at or later than version 1.22. To check the versi
1216

1317
- 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/)).
1418

15-
1619
## Objectives
1720

1821
- Register a Windows node to the cluster
1922
- Configure networking so Pods and Services on Linux and Windows can communicate with each other
2023

21-
2224
## Getting Started: Adding a Windows Node to Your Cluster
2325

24-
2526
### Networking Configuration
2627

2728
Once you have a Linux-based Kubernetes control-plane node you are ready to choose a networking solution.
2829

29-
3030
#### Configuring Flannel with rancher
3131

3232
1. Prepare Kubernetes control plane for Flannel
@@ -61,7 +61,7 @@ net-conf.json: |
6161

6262
> **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.
6363
64-
> **Note:** To use L2Bridge/Host-gateway mode instead change the value of `Type` to `"host-gw"` and omit `VNI` and `Port`.
64+
> **Note:** To use L2Bridge/Host-gateway mode instead change the value of `Type` to `"host-gw"` and omit `VNI` and `Port`.
6565
6666
3. Apply the Flannel manifest and validate
6767

@@ -106,10 +106,9 @@ git clone https://github.com/kubernetes-sigs/sig-windows-tools
106106
kubectl apply -f sig-windows-tools/kubeadm/flannel/kube-flannel-rbac.yml
107107
```
108108

109-
110109
### Joining a Windows worker node
111110

112-
> **Note:** All code snippets in Windows sections are to be run in a PowerShell environment with elevated permissions (Administrator) on the Windows worker node.
111+
> **Note:** All code snippets in Windows sections are to be run in a PowerShell environment with elevated permissions (Administrator) on the Windows worker node.
113112
114113
1. Install ContainerD, wins, kubelet, and kubeadm.
115114

@@ -124,22 +123,21 @@ cd .\sig-windows-tools\kubeadm\scripts\
124123
.\PrepareNode.ps1 -KubernetesVersion v1.24.3 -ContainerRuntime containerD
125124
```
126125

127-
> **Note** If you want to install another version of kubernetes, modify v1.24.3 with the version you want to install
128-
126+
> **Note** If you want to install another version of kubernetes, modify v1.24.3 with the version you want to install
129127
130128
2. Run `kubeadm` to join the node
131-
> **Note** Before joining the node, copy the file from /run/flannel/subnet.env to your windows machine to C:\run\flannel\subnet.env
132-
> You will need to create the folders for it
129+
130+
> **Note** Before joining the node, copy the file from /run/flannel/subnet.env to your windows machine to C:\run\flannel\subnet.env
131+
> You will need to create the folders for it
133132
134133
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.
135134

136-
> **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
135+
> **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
137136
138137
3. Install kubectl for windows (optional)
139138

140139
For more information about it : https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/
141140

142-
143141
#### Verifying your installation
144142

145143
You should now be able to view the Windows node in your cluster by running:
@@ -154,4 +152,4 @@ If your new node is in the `NotReady` state it is likely because the flannel ima
154152
kubectl -n kube-system get pods -l app=flannel
155153
```
156154

157-
Once the flannel Pod is running, your node should enter the `Ready` state and then be available to handle workloads.
155+
Once the flannel Pod is running, your node should enter the `Ready` state and then be available to handle workloads.

hostprocess/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
# HostProcess examples
22

33
This contains examples of services running as [HostProcess](https://kubernetes.io/docs/tasks/configure-pod-container/create-hostprocess-pod/)
4-
containers. HostProcess is an alpha feature in Kubernetes 1.22.
4+
containers. HostProcess went beta in Kubernetes v1.23 and stable in Kubernetes v1.26.
55

6-
The eventual goal is to move many of these examples to the corresponding repositories.
6+
The eventual goal is to move many of these examples to the corresponding repositories.
77

88
## Requirements
99

10-
The CNI examples currently require the containerd 1.6+: https://github.com/containerd/containerd/releases/tag/v1.6.0-beta.1
10+
HostProcess containers require containerd v1.6 or later.
1111

12-
For convenience there is a nightly job in the repository that builds the required components: https://github.com/kubernetes-sigs/sig-windows-tools/releases/tag/windows-containerd-nightly
12+
For convenience there is a nightly job in the repository that builds the required components: https://github.com/kubernetes-sigs/sig-windows-tools/releases/tag/windows-containerd-nightly.
1313

1414
> Docker does not support HostProcess containers. These images will not work with Docker.
1515
16-
## Future Improvements
17-
18-
These scripts are based off the initial Docker implementation in https://github.com/kubernetes-sigs/sig-windows-tools/tree/master/kubeadm.
19-
Ideally these should use init containers (possible written in golang) to install and configure the binaries as is done with Linux. Then the
20-
main container can run the required components for a given CNI.
16+
## Future Improvements
2117

2218
kube-proxy has slightly different configurations (sourcevip as example) across cni's so they are split into separate folder for each. Kubeadm should create and configure kube-proxy for windows appropriately during node initialization.
2319

kubeadm/scripts/Install-Containerd.ps1

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ This script
77
- Verifies that Windows Features requried for running contianers are enabled (and enables then if they are not)
88
- Downloads ContainerD binaries from from at the version specified.
99
- Downloads Windows SND CNI plugins.
10-
- Sets up a basic nat networking config for ContainerD to use until another CNI is configured
1110
- Registers ContainerD as a windows service.
1211
1312
.PARAMETER ContainerDVersion
@@ -23,7 +22,7 @@ PS> .\Install-Conatinerd.ps1
2322

2423
Param(
2524
[parameter(HelpMessage = "ContainerD version to use")]
26-
[string] $ContainerDVersion = "1.4.1",
25+
[string] $ContainerDVersion = "1.6.8",
2726
[parameter(HelpMessage = "Name of network adapter to use when configuring basic nat network")]
2827
[string] $netAdapterName = "Ethernet"
2928
)
@@ -40,48 +39,6 @@ function DownloadFile($destination, $source) {
4039
}
4140
}
4241

43-
<#
44-
.DESCRIPTION
45-
Computes a subnet for a gateway from the IPv4 IPAddress and PrefixLength properties
46-
for a given network adapter. This value is used for IPAM in a nat CNI config required for
47-
containerd.
48-
49-
.NOTES
50-
This logic is adapted from
51-
https://github.com/containerd/containerd/blob/4a6b47d470d9f2dfc3d49f2819b968861dfa123e/script/setup/install-cni-windows
52-
53-
.EXAMPLE
54-
PS> CalculateSubNet -gateway 172.16.5.8 -prefixLength 24
55-
172.16.5.0/8
56-
#>
57-
function CalculateSubNet {
58-
param (
59-
[string]$gateway,
60-
[int]$prefixLength
61-
)
62-
$len = $prefixLength
63-
$parts = $gateway.Split('.')
64-
$result = @()
65-
for ($i = 0; $i -le 3; $i++) {
66-
if ($len -ge 8) {
67-
$mask = 255
68-
69-
}
70-
elseif ($len -gt 0) {
71-
$mask = ((256 - 2 * (8 - $len)))
72-
}
73-
else {
74-
$mask = 0
75-
}
76-
$len -= 8
77-
$result += ([int]$parts[$i] -band $mask)
78-
}
79-
80-
$subnetIp = [string]::Join('.', $result)
81-
$cidr = 32 - $prefixLength
82-
return "${subnetIp}/$cidr"
83-
}
84-
8542
$requiredWindowsFeatures = @(
8643
"Containers",
8744
"Hyper-V",
@@ -131,33 +88,6 @@ Write-Output "Getting SDN CNI binaries"
13188
DownloadFile "c:\opt\cni\cni-plugins.zip" https://github.com/microsoft/windows-container-networking/releases/download/v0.2.0/windows-container-networking-cni-amd64-v0.2.0.zip
13289
Expand-Archive -Path "c:\opt\cni\cni-plugins.zip" -DestinationPath "c:\opt\cni\bin" -Force
13390

134-
Write-Output "Creating network config for nat network"
135-
$gateway = (Get-NetIPAddress -InterfaceAlias $netAdapterName -AddressFamily IPv4).IPAddress
136-
$prefixLength = (Get-NetIPAddress -InterfaceAlias $netAdapterName -AddressFamily IPv4).PrefixLength
137-
138-
$subnet = CalculateSubNet -gateway $gateway -prefixLength $prefixLength
139-
140-
@"
141-
{
142-
"cniVersion": "0.2.0",
143-
"name": "nat",
144-
"type": "nat",
145-
"master": "Ethernet",
146-
"ipam": {
147-
"subnet": "$subnet",
148-
"routes": [
149-
{
150-
"GW": "$gateway"
151-
}
152-
]
153-
},
154-
"capabilities": {
155-
"portMappings": true,
156-
"dns": true
157-
}
158-
}
159-
"@ | Set-Content "c:\etc\cni\net.d\0-containerd-nat.json" -Force
160-
16191
Write-Output "Registering ContainerD as a service"
16292
containerd.exe --register-service
16393

kubeadm/scripts/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Warning
2+
3+
The instructions and scripts in the directory DO NOT configure a CNI solution for Windows nodes running containerd.
4+
There is a work-in-progress PR to assist in this at https://github.com/kubernetes-sigs/sig-windows-tools/pull/239

0 commit comments

Comments
 (0)