Skip to content

Commit 9cae715

Browse files
committed
fix: wcow: simplify CNI setup for windows
To enable CNI networking for WCOW, you needed to provide long paths when running the daemon, e.g. ``` buildkitd ` --containerd-cni-config-path="C:\Program Files\containerd\cni\conf\0-containerd-nat.conf" ` --containerd-cni-binary-dir="C:\Program Files\containerd\cni\bin" ``` Fix this so that the default paths are set in appdefaults, instead of the one that had be set previously. Now you can just run: `buildkitd`. Also, refactor the script for setting up CNI binaries and configs, to make it easy to refresh the configs without having to download the binaries afresh. Signed-off-by: Anthony Nandaa <[email protected]>
1 parent 7fbda52 commit 9cae715

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

docs/windows.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ You will be asked to restart your machine, do so, and then continue with the res
9494
--containerd-cni-config-path="C:\Program Files\containerd\cni\conf\0-containerd-nat.conf" `
9595
--containerd-cni-binary-dir="C:\Program Files\containerd\cni\bin"
9696
```
97+
98+
> **NOTE:** the above CNI paths are now set by default, you can now just run `buildkitd`.
9799
98100
You can also run `buildkitd` as a _Windows Service_:
99101
@@ -239,6 +241,20 @@ Below is a simple setup based on the `nat` network that comes by default, with e
239241
_containers_ and _Hyper-V_ features.
240242

241243
```powershell
244+
# get the CNI plugins (binaries)
245+
$cniPluginVersion = "0.3.1"
246+
$cniBinDir = "$env:ProgramFiles\containerd\cni\bin"
247+
mkdir $cniBinDir -Force
248+
curl.exe -LO https://github.com/microsoft/windows-container-networking/releases/download/v$cniPluginVersion/windows-container-networking-cni-amd64-v$cniPluginVersion.zip
249+
tar xvf windows-container-networking-cni-amd64-v$cniPluginVersion.zip -C $cniBinDir
250+
251+
# NOTE: depending on your host setup, the IPs may change after restart
252+
# you can only run this script from here to end for a refresh.
253+
# without downloading the binaries again.
254+
255+
$cniVersion = "1.0.0"
256+
$cniConfPath = "$env:ProgramFiles\containerd\cni\conf\0-containerd-nat.conf"
257+
242258
$networkName = 'nat'
243259
# Get-HnsNetwork is available once you have enabled the 'Hyper-V Host Compute Service' feature
244260
# which must have been done at the Quick setup above
@@ -251,16 +267,6 @@ if ($null -eq $natInfo) {
251267
$gateway = $natInfo.Subnets[0].GatewayAddress
252268
$subnet = $natInfo.Subnets[0].AddressPrefix
253269
254-
$cniConfPath = "$env:ProgramFiles\containerd\cni\conf\0-containerd-nat.conf"
255-
$cniBinDir = "$env:ProgramFiles\containerd\cni\bin"
256-
$cniVersion = "1.0.0"
257-
$cniPluginVersion = "0.3.1"
258-
259-
# get the CNI plugins (binaries)
260-
mkdir $cniBinDir -Force
261-
curl.exe -LO https://github.com/microsoft/windows-container-networking/releases/download/v$cniPluginVersion/windows-container-networking-cni-amd64-v$cniPluginVersion.zip
262-
tar xvf windows-container-networking-cni-amd64-v$cniPluginVersion.zip -C $cniBinDir
263-
264270
$natConfig = @"
265271
{
266272
"cniVersion": "$cniVersion",

util/appdefaults/appdefaults_windows.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ const (
1212
var (
1313
Root = filepath.Join(os.Getenv("ProgramData"), "buildkitd", ".buildstate")
1414
ConfigDir = filepath.Join(os.Getenv("ProgramData"), "buildkitd")
15-
DefaultCNIBinDir = filepath.Join(ConfigDir, "bin")
16-
DefaultCNIConfigPath = filepath.Join(ConfigDir, "cni.json")
15+
defaultContainerdDir = filepath.Join(os.Getenv("ProgramFiles"), "containerd")
16+
DefaultCNIBinDir = filepath.Join(defaultContainerdDir, "cni", "bin")
17+
DefaultCNIConfigPath = filepath.Join(defaultContainerdDir, "cni", "conf", "0-containerd-nat.conf")
1718
)
1819

1920
var (

0 commit comments

Comments
 (0)