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

feat(controller): Add support for Docker workflow executor for Windows nodes #3301

Merged
merged 5 commits into from Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 4 additions & 14 deletions docs/windows.md
Expand Up @@ -2,22 +2,12 @@

The Argo server and the workflow controller currently only run on Linux. The workflow executor however also runs on Windows nodes, meaning you can use Windows containers inside your workflows! Here are the steps to get started.

## 0. Requirements
## Requirements
* Kubernetes 1.14 or later, supporting Windows nodes
* Hybrid cluster containing Linux and Windows nodes like described in the [Kubernetes docs](https://kubernetes.io/docs/setup/production-environment/windows/user-guide-windows-containers/)
* Argo configured and running like described [here](getting-started.md)

## 1. Setting up the workflow executor

Currently the worflow controller configuration doesn't support different configurations for the `dockerSockPath` based on the host OS. This means that the workflow executor, running in a Windows container can't use Docker for now.

You therefore need to use `kubelet` or `k8sapi` instead in your workflow controller configmap:
```yaml
containerRuntimeExecutor: kubelet
kubeletInsecure: true # you can disable TLS verification of the kubelet executor for testing
```

## 2. Schedule workflows with Windows containers
## Schedule workflows with Windows containers

If you're running workflows in your hybrid Kubernetes cluster, always make sure to include a `nodeSelector` to run the steps on the correct host OS:

Expand Down Expand Up @@ -45,7 +35,7 @@ $ argo logs hello-windows-s9kk5
hello-windows-s9kk5: "Hello from Windows Container!"
```

## Bonus: Hybrid workflows
## Schedule hybrid workflows

You can also run different steps on different host OSs. This can for example be very helpful when you need to compile your application on Windows and Linux.

Expand Down Expand Up @@ -74,7 +64,7 @@ spec:
args: ["echo", "Hello from Windows Container!"]
- name: hello-linux
nodeSelector:
beta.kubernetes.io/os: linux
kubernetes.io/os: linux
container:
image: alpine
command: [echo]
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-hybrid.yaml
Expand Up @@ -21,7 +21,7 @@ spec:
args: ["echo", "Hello from Windows Container!"]
- name: hello-linux
nodeSelector:
beta.kubernetes.io/os: linux
kubernetes.io/os: linux
container:
image: alpine
command: [echo]
Expand Down
52 changes: 42 additions & 10 deletions workflow/controller/workflowpod.go
Expand Up @@ -53,16 +53,48 @@ var (
hostPathSocket = apiv1.HostPathSocket
)

func (woc *wfOperationCtx) getVolumeMountDockerSock() apiv1.VolumeMount {
func (woc *wfOperationCtx) getVolumeMountDockerSock(tmpl *wfv1.Template) apiv1.VolumeMount {
return apiv1.VolumeMount{
Name: common.DockerSockVolumeName,
MountPath: "/var/run/docker.sock",
ReadOnly: true,
MountPath: getDockerSockPath(tmpl),
ReadOnly: getDockerSockReadOnly(tmpl),
}
}

func (woc *wfOperationCtx) getVolumeDockerSock() apiv1.Volume {
dockerSockPath := "/var/run/docker.sock"
func getDockerSockReadOnly(tmpl *wfv1.Template) bool {
return !hasWindowsOsNodeSelector(tmpl.NodeSelector)
}

func getDockerSockPath(tmpl *wfv1.Template) string {
if hasWindowsOsNodeSelector(tmpl.NodeSelector) {
lippertmarkus marked this conversation as resolved.
Show resolved Hide resolved
return "\\\\.\\pipe\\docker_engine"
}

return "/var/run/docker.sock"
}

func getVolumeHostPathType(tmpl *wfv1.Template) *apiv1.HostPathType {
if hasWindowsOsNodeSelector(tmpl.NodeSelector) {
return nil
}

return &hostPathSocket
}

func hasWindowsOsNodeSelector(nodeSelector map[string]string) bool {
lippertmarkus marked this conversation as resolved.
Show resolved Hide resolved
if nodeSelector == nil {
return false
}

if os, keyExists := nodeSelector["kubernetes.io/os"]; keyExists && os == "windows" {
return true
}

return false
}

func (woc *wfOperationCtx) getVolumeDockerSock(tmpl *wfv1.Template) apiv1.Volume {
dockerSockPath := getDockerSockPath(tmpl)

if woc.controller.Config.DockerSockPath != "" {
dockerSockPath = woc.controller.Config.DockerSockPath
Expand All @@ -77,7 +109,7 @@ func (woc *wfOperationCtx) getVolumeDockerSock() apiv1.Volume {
VolumeSource: apiv1.VolumeSource{
HostPath: &apiv1.HostPathVolumeSource{
Path: dockerSockPath,
Type: &hostPathSocket,
Type: getVolumeHostPathType(tmpl),
},
},
}
Expand Down Expand Up @@ -132,7 +164,7 @@ func (woc *wfOperationCtx) createWorkflowPod(nodeName string, mainCtr apiv1.Cont
},
Spec: apiv1.PodSpec{
RestartPolicy: apiv1.RestartPolicyNever,
Volumes: woc.createVolumes(),
Volumes: woc.createVolumes(tmpl),
ActiveDeadlineSeconds: activeDeadlineSeconds,
ImagePullSecrets: woc.wfSpec.ImagePullSecrets,
},
Expand Down Expand Up @@ -362,7 +394,7 @@ func (woc *wfOperationCtx) newWaitContainer(tmpl *wfv1.Template) (*apiv1.Contain
ctr.SecurityContext.Privileged = pointer.BoolPtr(true)
}
case "", common.ContainerRuntimeExecutorDocker:
ctr.VolumeMounts = append(ctr.VolumeMounts, woc.getVolumeMountDockerSock())
ctr.VolumeMounts = append(ctr.VolumeMounts, woc.getVolumeMountDockerSock(tmpl))
}
return ctr, nil
}
Expand Down Expand Up @@ -443,7 +475,7 @@ func (woc *wfOperationCtx) createEnvVars() []apiv1.EnvVar {
return execEnvVars
}

func (woc *wfOperationCtx) createVolumes() []apiv1.Volume {
func (woc *wfOperationCtx) createVolumes(tmpl *wfv1.Template) []apiv1.Volume {
volumes := []apiv1.Volume{
volumePodMetadata,
}
Expand All @@ -465,7 +497,7 @@ func (woc *wfOperationCtx) createVolumes() []apiv1.Volume {
case common.ContainerRuntimeExecutorKubelet, common.ContainerRuntimeExecutorK8sAPI, common.ContainerRuntimeExecutorPNS:
return volumes
default:
return append(volumes, woc.getVolumeDockerSock())
return append(volumes, woc.getVolumeDockerSock(tmpl))
}
}

Expand Down