Last active
February 21, 2024 06:31
-
-
Save profnandaa/33d65d85964181a42539bfd0b4f9561a to your computer and use it in GitHub Desktop.
Windows container networking [wip]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# this is work in progress | |
# the following script was from Gabriel | |
# will modify it to run with the v1.0.0 CNI spec. | |
# | |
$ErrorActionPreference="Stop" | |
$containerdDir = join-path $env:ProgramFiles containerd | |
if (!(Test-Path $containerdDir)){ | |
mkdir $containerdDir | |
} | |
$downloadPath = Join-Path $env:Tmp "containerd.tar.gz" | |
$downloadLink = "https://github.com/containerd/containerd/releases/download/v1.7.5/containerd-1.7.5-windows-amd64.tar.gz" | |
$cli = [System.Net.WebClient]::new() | |
$cli.DownloadFile($downloadLink, $downloadPath) | |
tar xf $downloadPath -C $containerdDir | |
if ($LASTEXITCODE) { | |
Throw "failed to extract containerd" | |
} | |
$cniDir = Join-Path $containerdDir "cni" | |
$cniConfDir = Join-Path $cniDir "conf" | |
$cniBinDir = Join-Path $cniDir "bin" | |
$cniConfPath = Join-Path $cniConfDir "0-containerd-nat.conf" | |
if (!(Test-Path $cniBinDir)) { | |
mkdir $cniBinDir | |
} | |
$prepareEnvScriptLink = "https://gist.githubusercontent.com/gabriel-samfira/c80ccb1d79be737e5e61214181e48ad8/raw/e393047c93b1755897cf0a1efc786557aba1f428/prepare_env_windows.ps1" | |
$prepareEnvScriptPath = Join-Path $env:TMP "prepare_env_windows.ps1" | |
$cli.DownloadFile($prepareEnvScriptLink, $prepareEnvScriptPath) | |
& $prepareEnvScriptPath | |
git clone https://github.com/Microsoft/windows-container-networking $HOME\windows-container-networking | |
cd $HOME\windows-container-networking | |
git checkout aa10a0b31e9f72937063436454def1760b858ee2 | |
make all | |
cp .\out\*.exe $cniBinDir\ | |
if (!(Test-Path $cniConfDir)) { | |
mkdir $cniConfDir | |
} | |
Set-Content $cniConfPath @" | |
{ | |
"cniVersion": "0.2.0", | |
"name": "nat", | |
"type": "nat", | |
"master": "Ethernet", | |
"ipam": { | |
"subnet": "172.19.208.0/20", | |
"routes": [ | |
{ | |
"GW": "172.19.208.1" | |
} | |
] | |
}, | |
"capabilities": { | |
"portMappings": true, | |
"dns": true | |
} | |
} | |
"@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment