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

CNI support for Windows #1585

Merged
merged 4 commits into from
Jul 21, 2020
Merged

CNI support for Windows #1585

merged 4 commits into from
Jul 21, 2020

Conversation

TBBle
Copy link
Collaborator

@TBBle TBBle commented Jul 20, 2020

These changes get the CNI integration working on Windows:

  • Refactored NetNS handling to fully abstract the Linux codepath from common code, and implement a Windows codepath
  • Disabled the 'loopback' CNI config on Windows, as it doesn't appear to exist, nor be needed.
  • Disabled host network mode in Windows, because it doesn't appear to exist either, nor is it supported.
  • Fixed a bug that would cause the --containerd-cni-binary-dir option to be ignored when reading the config provided by --containerd-cni-config-path.

Tested using a hack-bug-fixed version of the nat plugin from https://github.com/microsoft/windows-container-networking (see microsoft/windows-container-networking#57), with the following config from their examples.

{
    "cniVersion": "0.2.0",
    "name": "natNetwork",
    "type": "nat",
    "master": "Ethernet",
    "ipam": {
        "subnet": "192.168.100.0/24",
        "routes": [
            {
                "gateway": "192.168.100.1"
            }
        ]
    }
}

This is only used by the containerd worker on on Windows, which is not currently activated. I'm locally using a heavily-hacked-upon GenerateSpec to get an OCI spec that doesn't trigger LCOW support.

That's the last problem to solve, once the various underlying pieces are in-place and working.

Tested with the following Dockerfile:

FROM mcr.microsoft.com/windows/servercore:2004

LABEL Description="Python" Vendor="Python Software Foundation" Version="3.7.3"

RUN powershell.exe -Command \
    $ErrorActionPreference = 'Stop'; \
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
    wget https://www.python.org/ftp/python/3.7.3/python-3.7.3.exe -OutFile c:\python-3.7.3.exe ; \
    Start-Process c:\python-3.7.3.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait ; \
    Remove-Item c:\python-3.7.3.exe -Force

and confirmed that Python had been installed in the resulting image.

Contributes towards #616

@TBBle TBBle force-pushed the windows_cni_support branch 2 times, most recently from 05dbf97 to 8a16c0c Compare July 20, 2020 15:20
@TBBle TBBle force-pushed the windows_cni_support branch 2 times, most recently from a3f2193 to 502f1e8 Compare July 20, 2020 16:05
@TBBle TBBle force-pushed the windows_cni_support branch 2 times, most recently from 9a752c3 to 53a3b18 Compare July 21, 2020 06:18
This enforces the lack of host networking support on Windows.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
The Windows API is completely different, so the common code cannot
create the unique identifier, but must accept what the OS-specific code
does.

For Linux, it's a pathname. In Windows, it's a GUID string.

This pulls in direct usage of Microsoft/hcsshim, which previously was
only an indirect usage via containerd calls from, e.g., localMounter on
Windows.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
The `WithLoNetwork` and `WithConfFile` options consume the
`WithPluginDir` and `WithInterfacePrefix` settings, so they must come
first.

This fixes the issue that the provided plugin directory was not used for
the provided configuration file. This would have been more visible, but
the default `InterfacePrefix` is already "eth".

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
There's no Loopback CNI plugin for Windows as far as I can see, so I'm
assuming it's not needed.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants