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: Windows Container Support. Fixes #1507 and #1383 #2747

Merged
merged 8 commits into from
May 1, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ sdks
vendor
ui/dist
ui/node_modules
Dockerfile.windows
lippertmarkus marked this conversation as resolved.
Show resolved Hide resolved
73 changes: 73 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
####################################################################################################
lippertmarkus marked this conversation as resolved.
Show resolved Hide resolved
# Builder image
# Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image
# Also used as the image in CI jobs so needs all dependencies
####################################################################################################
# had issues with official golange image for windows so I'm using plain servercore
FROM mcr.microsoft.com/windows/servercore:ltsc2019 as builder
ENV GOLANG_VERSION=1.13.4
SHELL ["powershell", "-Command"]

ARG IMAGE_OS=windows
ARG IMAGE_ARCH=amd64

# install chocolatey package manager
ENV chocolateyUseWindowsCompression=false
RUN iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')); \
choco feature disable --name showDownloadProgress ; \
choco feature enable -n allowGlobalConfirmation

# install golang, dep and other tools
RUN choco install golang --version=$env:GOLANG_VERSION ; \
choco install make dep docker-cli git.portable

####################################################################################################
# argoexec-base
# Used as the base for both the release and development version of argoexec
####################################################################################################
FROM mcr.microsoft.com/windows/nanoserver:1809 as argoexec-base
COPY --from=builder /windows/system32/netapi32.dll /windows/system32/netapi32.dll

ARG IMAGE_OS=windows
ARG IMAGE_ARCH=amd64

# NOTE: keep the version synced with https://storage.googleapis.com/kubernetes-release/release/stable.txt
ENV KUBECTL_VERSION=1.15.1
ENV JQ_VERSION=1.6

RUN mkdir C:\app && \
curl -L -o C:\app\kubectl.exe "https://storage.googleapis.com/kubernetes-release/release/v%KUBECTL_VERSION%/bin/windows/amd64/kubectl.exe" && \
curl -L -o C:\app\jq.exe "https://github.com/stedolan/jq/releases/download/jq-%JQ_VERSION%/jq-win64.exe"

COPY --from=builder C:/ProgramData/chocolatey/lib/docker-cli/tools/docker.exe C:/app/docker.exe
COPY --from=builder C:/tools/git C:/app/git

# add binaries to path
USER Administrator
RUN SETX /m path C:\app;C:\app\git\bin;%path%

####################################################################################################
# Argo Build stage which performs the actual build of Argo binaries
####################################################################################################
FROM builder as argo-build

ARG IMAGE_OS=windows
ARG IMAGE_ARCH=amd64
ARG DEV=0

# Perform the build
WORKDIR C:/Users/ContainerAdministrator/go/src/github.com/argoproj/argo
COPY . .
# check we can use Git
RUN git rev-parse HEAD
# fail the build if we are "dirty"
RUN if ($env:DEV -eq 0) { git diff --exit-code }
# run in git bash for all the shell commands in Makefile to work
RUN bash -c 'make dist/argoexec-windows-amd64'

####################################################################################################
# argoexec
####################################################################################################
FROM argoexec-base as argoexec
COPY --from=argo-build C:/Users/ContainerAdministrator/go/src/github.com/argoproj/argo/dist/argoexec-windows-amd64 C:/app/argoexec.exe
ENTRYPOINT [ "argoexec" ]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ endif
# argoexec

dist/argoexec-linux-amd64: GOARGS = GOOS=linux GOARCH=amd64
dist/argoexec-windows-amd64: GOARGS = GOOS=windows GOARCH=amd64
dist/argoexec-linux-arm64: GOARGS = GOOS=linux GOARCH=arm64

dist/argoexec-%: $(ARGOEXEC_PKGS)
Expand Down
91 changes: 91 additions & 0 deletions docs/windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Windows Container Support

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
* 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

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:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-windows-
spec:
entrypoint: hello-win
templates:
- name: hello-win
nodeSelector:
kubernetes.io/os: windows # specify the OS your step should run on
container:
image: mcr.microsoft.com/windows/nanoserver:1809
command: ["cmd", "/c"]
args: ["echo", "Hello from Windows Container!"]
```

You can run this example and get the logs:
```
$ argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/hello-windows.yaml
$ argo logs hello-windows-s9kk5
hello-windows-s9kk5: "Hello from Windows Container!"
```

## Bonus: 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.

An example workflow can look like the following:
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-hybrid-
spec:
entrypoint: mytemplate
templates:
- name: mytemplate
steps:
- - name: step1
template: hello-win
- - name: step2
template: hello-linux

- name: hello-win
nodeSelector:
kubernetes.io/os: windows
container:
image: mcr.microsoft.com/windows/nanoserver:1809
command: ["cmd", "/c"]
args: ["echo", "Hello from Windows Container!"]
- name: hello-linux
nodeSelector:
beta.kubernetes.io/os: linux
container:
image: alpine
command: [echo]
args: ["Hello from Linux Container!"]

```

Again, you can run this example and get the logs:
```
$ argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/hello-hybrid.yaml
$ argo logs hello-hybrid-plqpp
hello-hybrid-plqpp-1977432187: "Hello from Windows Container!"
hello-hybrid-plqpp-764774907: Hello from Linux Container!
```
2 changes: 2 additions & 0 deletions docs/workflow-controller-configmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ spec:
image: argoproj/workflow-controller:latest
name: workflow-controller
serviceAccountName: argo
nodeSelector:
kubernetes.io/os: linux
```

## Alternate Structure
Expand Down
28 changes: 28 additions & 0 deletions examples/hello-hybrid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-hybrid-
spec:
entrypoint: mytemplate
templates:
- name: mytemplate
steps:
- - name: step1
template: hello-win
- - name: step2
template: hello-linux

- name: hello-win
nodeSelector:
kubernetes.io/os: windows
container:
image: mcr.microsoft.com/windows/nanoserver:1809
command: ["cmd", "/c"]
args: ["echo", "Hello from Windows Container!"]
- name: hello-linux
nodeSelector:
beta.kubernetes.io/os: linux
container:
image: alpine
command: [echo]
args: ["Hello from Linux Container!"]
14 changes: 14 additions & 0 deletions examples/hello-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-windows-
spec:
entrypoint: hello-win
templates:
- name: hello-win
nodeSelector:
kubernetes.io/os: windows
container:
image: mcr.microsoft.com/windows/nanoserver:1809
command: ["cmd", "/c"]
args: ["echo", "Hello from Windows Container!"]
2 changes: 2 additions & 0 deletions manifests/base/argo-server/argo-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ spec:
path: /
initialDelaySeconds: 10
periodSeconds: 20
nodeSelector:
kubernetes.io/os: linux
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ spec:
- workflow-controller-configmap
- --executor-image
- argoproj/argoexec:latest
nodeSelector:
kubernetes.io/os: linux
4 changes: 4 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ spec:
initialDelaySeconds: 10
periodSeconds: 20
serviceAccountName: argo-server
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -430,3 +432,5 @@ spec:
image: argoproj/workflow-controller:latest
name: workflow-controller
serviceAccountName: argo
nodeSelector:
kubernetes.io/os: linux
4 changes: 4 additions & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ spec:
initialDelaySeconds: 10
periodSeconds: 20
serviceAccountName: argo-server
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -330,3 +332,5 @@ spec:
image: argoproj/workflow-controller:latest
name: workflow-controller
serviceAccountName: argo
nodeSelector:
kubernetes.io/os: linux
6 changes: 6 additions & 0 deletions manifests/quick-start-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ spec:
initialDelaySeconds: 10
periodSeconds: 20
serviceAccountName: argo-server
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -529,6 +531,8 @@ spec:
- SELECT 1
initialDelaySeconds: 15
timeoutSeconds: 2
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -555,6 +559,8 @@ spec:
image: argoproj/workflow-controller:latest
name: workflow-controller
serviceAccountName: argo
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: v1
kind: Pod
Expand Down
4 changes: 4 additions & 0 deletions manifests/quick-start-no-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ spec:
initialDelaySeconds: 10
periodSeconds: 20
serviceAccountName: argo-server
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -470,6 +472,8 @@ spec:
image: argoproj/workflow-controller:latest
name: workflow-controller
serviceAccountName: argo
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: v1
kind: Pod
Expand Down
6 changes: 6 additions & 0 deletions manifests/quick-start-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ spec:
initialDelaySeconds: 10
periodSeconds: 20
serviceAccountName: argo-server
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -521,6 +523,8 @@ spec:
- SELECT 1
initialDelaySeconds: 15
timeoutSeconds: 2
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -547,6 +551,8 @@ spec:
image: argoproj/workflow-controller:latest
name: workflow-controller
serviceAccountName: argo
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: v1
kind: Pod
Expand Down
4 changes: 3 additions & 1 deletion manifests/quick-start/mysql/mysql-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ spec:
exec:
command: ["mysql", "-u", "mysql", "-ppassword", "argo", "-e", "SELECT 1"]
initialDelaySeconds: 15
timeoutSeconds: 2
timeoutSeconds: 2
nodeSelector:
kubernetes.io/os: linux
4 changes: 3 additions & 1 deletion manifests/quick-start/postgres/postgres-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ spec:
exec:
command: ["psql", "-U", "postgres", "-c", "SELECT 1"]
initialDelaySeconds: 15
timeoutSeconds: 2
timeoutSeconds: 2
nodeSelector:
kubernetes.io/os: linux
2 changes: 2 additions & 0 deletions test/e2e/manifests/mixins/argo-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ spec:
value: password
- name: UPPERIO_DB_DEBUG
value: "1"
nodeSelector:
lippertmarkus marked this conversation as resolved.
Show resolved Hide resolved
kubernetes.io/os: linux
2 changes: 2 additions & 0 deletions test/e2e/manifests/mixins/workflow-controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ spec:
value: 30s
- name: UPPERIO_DB_DEBUG
value: "1"
nodeSelector:
lippertmarkus marked this conversation as resolved.
Show resolved Hide resolved
kubernetes.io/os: linux
Loading