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

Windows support #164

Closed
wants to merge 2 commits into from
Closed

Conversation

jsturtevant
Copy link
Contributor

This refactors to allow building a Windows binary as well as adds nerdctl run support. This a draft to figure out/show the amount of work. This should be broken down into smaller PRs that can be reviewed easier. See #28 for discussion

@jsturtevant jsturtevant mentioned this pull request Apr 11, 2021
@@ -57,19 +57,19 @@ install:
TAR_FLAGS=--transform 's/.*\///g' --owner=0 --group=0

artifacts: clean
GOOS=linux GOARCH=amd64 make -C $(CURDIR) binaries
GOOS=$(GOOS) GOARCH=amd64 make -C $(CURDIR) binaries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This produces nerdctl-$(VERSION_TRIMMED)-linux-amd64.tar.gz, so GOOS has to be hard-coded to linux here.

Instead, we should add GOOS=windows that produces nerdctl-$(VERSION_TRIMMED)-windows-amd64.zip


// getDataStore returns a string like "/var/lib/nerdctl/1935db59".
// "1935db9" is from `$(echo -n "/run/containerd/containerd.sock" | sha256sum | cut -c1-8)``
func getDataStore(clicontext *cli.Context) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this different from Linux implementation?

"github.com/urfave/cli/v2"
)

func newClient(clicontext *cli.Context) (*containerd.Client, context.Context, context.CancelFunc, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not necessarily need to be a separate file.
The containerd address can be changed with if runtime.GOOS == "windows"{}.

const AppArmorProfileName = ""

func DataRoot() string {
return "C:\\ProgramData\\containerd\\root"
Copy link
Member

@AkihiroSuda AkihiroSuda Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should read %ALLUSERSPROFILE (%ProgramData%) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically,

filepath.Join(os.Getenv("ProgramData"), "containerd", "root")

is how containerd.defaults.DefaultRootDir is defined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "data root" of nerdctl has nothing to do with containerd's data root.
So this should be like filepath.Join(os.Getenv("ProgramData"), "nerdctl")

}

func CNIPath() string {
return "C:\\Program Files\\containerd\\cni\\bin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should read %ProgramFiles%?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filepath.Join(os.Getenv("ProgramFiles"), "containerd", "cni", "bin")

is how containerd.pkg.cri.config.DefaultConfig().CniConfig.NetworkPluginBinDir is defined.

}
return s
}

const UnameO = "GNU/Linux"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in infoutil_linux.go

"github.com/sirupsen/logrus"
)

// LockFile from https://github.com/boltdb/bolt/blob/master/bolt_windows.go using MIT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use permalink

const (
DefaultNetworkName = "nat"
DefaultID = 0
DefaultCIDR = "10.1.0.0/24"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this different from Linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it needs to be, I was using the same values that I had manually configured to test

package netutil

const (
DefaultNetworkName = "nat"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this different from Linux?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a "bridge" network type for Windows AFAIK, and the Windows CNI plugins (at least the ones from https://github.com/microsoft/windows-container-networking: nat, sdnoverlay, and sdnbridge) require that the network name equals the network type: microsoft/windows-container-networking#57

sdnoverlay and sdnbridge require extra system setup beyond the CNI config file, so they seem like poor choices for default usage. Third-party CNI plugins are equally likely to require extra system configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The network name is expected to match Docker's default network, not the name of CNI plugin.

Copy link
Contributor

@TBBle TBBle Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I misunderstood. I thought this was what ended up substituted as as .Name in ConfigListTemplate.

Although it's not clear to me why we even have a CNI config if we're going to be using the Docker-provided network setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using Docker the default network on Windows is called nat so I called it that here. Are you saying this should stay bridge?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nat SGTM then

"github.com/sirupsen/logrus"
)

func loadapparmor() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: loadAppArmor

@@ -59,7 +51,7 @@ var runCommand = &cli.Command{
Name: "run",
Usage: "Run a command in a new container",
Action: runAction,
BashComplete: runBashComplete,
BashComplete: runComplete,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

@@ -173,7 +165,7 @@ var runCommand = &cli.Command{
&cli.StringFlag{
Name: "runtime",
Usage: "Runtime to use for this container, e.g. \"crun\", or \"io.containerd.runsc.v1\"",
Value: plugin.RuntimeRuncV2,
Value: "io.containerd.runhcs.v1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux runtime shouldn't change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup! it was just to make it work. This will need to be extracted so when built for Windows it is defaulted correctly.

//if len(args) > 0 {
// opts = append(opts, oci.WithProcessArgs(args...))
//}
if cwd := clicontext.String("cwd"); cwd != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag name looks different from Linux

@jsturtevant
Copy link
Contributor Author

closing in favor of a more iterative approach. I did take much of the feedback here into consideration. Thanks for the early reviews!

@jsturtevant jsturtevant mentioned this pull request Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants