Skip to content

support for windows containers-as-workspaces #6657

Closed as not planned
Closed as not planned

Description

@ericpaulsen

we've received requests for running windows containers as Coder workspaces. in my attempts to POC this use-case, i've run into issues with how containerd executes powershell commands/scripts as part of the entrypoint command in the kubernetes_pod spec in Terraform. related issue: containerd/containerd#5067

versions

  • host: GCP Windows LTSC with containerd (Windows Server 2019 Datacenter)
  • runtime: containerd://1.6.13-gke.1
  • k8s provider: 2.12.1

error

Error: failed to start containerd task "coder-container":
hcs::System::CreateProcess coder-container: The system cannot find the file specified.: unknown

tests

1. execute powershell against the init_script terraform object

resource "kubernetes_pod" "main" {
  container {
    image = "docker.io/stefanscherer/node-windows:latest"
    command = ["powershell.exe", "-NoExit", "-Command", coder_agent.main.init_script]
  }
}

2. mount the init_script as a volume, execute the file via powershell

resource "kubernetes_pod" "main" {
  spec {
    container {
      image = "docker.io/stefanscherer/node-windows:latest"
      command = ["powershell.exe", "-NoExit", "-Command", "C:\\coder_init\\init.ps1"]
    }
    volume_mount {
      mount_path = "C:\\coder_init"
      name       = "coder-init-script"
  }
  volume {
    name = "coder-init-script"
    secret {
      secret_name = "coder-init-script"
    }
  }
}

resource "kubernetes_secret" "init_script" {
  metadata {
    name      = "coder-init-script"
    namespace = "oss"
  }
  type = "Opaque"
  data = {
    "init.ps1" = base64encode(coder_agent.coder.init_script)
  }
}

3. set the SHELL & ENTRYPOINT in the Dockerfile

FROM stefanscherer/node-windows:latest

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 

ENTRYPOINT ["powershell.exe"]
resource "kubernetes_pod" "main" {
  container {
    image = "ericpaulsen/windows-test:latest"
    command = ["C:\\coder_init\\init.ps1"]
  }
}

any feedback, troubleshooting ideas are appreciated.

Activity

  1. added
    use-case
    on Mar 17, 2023
  2. added
    stale
    on Jun 16, 2023
  3. removed
    stale
    on Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    use-case

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions