Powershell shell isn't working with images that includes powershell.
Summary
We can't find a configuration where the Powershell runner would work work with Windows on AKS with many different configurations. Pwsh only with very specific configuration.
Steps to reproduce
- Create an AKS
resource "azurerm_resource_group" "aks_sandbox_rg" {
name = "aks-sandbox-rg"
location = "West Europe"
}
resource "azurerm_kubernetes_cluster" "aks_sandbox" {
name = "aks-sandbox"
location = "westeurope"
resource_group_name = azurerm_resource_group.aks_sandbox_rg.name
dns_prefix = "aks-sandbox"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "azure"
}
windows_profile {
admin_username = "xxxxx"
admin_password = "xxxxxxxx"
}
}
output "client_certificate" {
value = azurerm_kubernetes_cluster.aks_sandbox.kube_config.0.client_certificate
sensitive = true
}
output "kube_config" {
value = azurerm_kubernetes_cluster.aks_sandbox.kube_config_raw
sensitive = true
}
resource "azurerm_kubernetes_cluster_node_pool" "aks_sdbx_win_pool" {
name = "appwin"
kubernetes_cluster_id = azurerm_kubernetes_cluster.aks_sandbox.id
vm_size = "Standard_DS2_v2"
node_count = 1
os_sku = "Windows2022" # we also tested Windows2019
os_type = "Windows"
tags = {
Environment = "Production"
}
}
- Launch a windows runner (GITLAB_RUNNER_HELM_VERSION=0.55.0) with this config:
gitlaburl: https://gitlab.xxxxxxx.io/
runnertoken: $runner_token
concurrent: 10
rbac:
create: true
runners:
config: |
[[runners]]
shell = "powershell" # we also tested "pwsh"
environment = ["ff_use_powershell_path_resolver=1","ff_use_legacy_kubernetes_execution_strategy=1"] # both required
[runners.kubernetes]
namespace = "{{.release.namespace}}"
image = "mcr.microsoft.com/powershell:lts-servercore-ltsc2022"
# image = "mcr.microsoft.com/windows/servercore:ltsc2019"
helper_image = "gitlab/gitlab-runner-helper:x86_64-latest-servercore21H2"
# helper_image = "gitlab/gitlab-runner-helper:x86_64-latest-servercore1809"
pull_policy = "always"
cpu_limit = "1"
[runners.kubernetes.node_tolerations]
"os=windows" = "noschedule"
[runners.kubernetes.node_selector]
"beta.kubernetes.io/os" = "windows"
[runners.kubernetes.pod_annotations]
"linkerd.io/inject" = "disabled"
podannotations:
linkerd.io/inject: disabled
nodeselector:
beta.kubernetes.io/os: linux
.gitlab-ci.yml
check runner is alive:
script:
- powershell "Write-Host "HELLO WORLD""
tags:
- debug-winrunner-aks
Actual behavior
With this configuration, we have an error indicating that the runner can't find the powershell runner The system cannot find the file specified.: unknown.
Expected behavior
Job succeeded
job log
ERROR: Job failed (system failure): prepare environment: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "xxxxxx": hcs::System::CreateProcess xxxxxxx: **The system cannot find the file specified.: unknown**. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
Environment description
Here are our findings regarding the usage of pwsh et powershell runners :
node image | job image | helper image | using pwsh shell | using powershell shell |
---|---|---|---|---|
Windows 2022 | mcr.microsoft.com/powershell:lts-servercore-ltsc2022 | gitlab/gitlab-runner-helper:x86_64-latest-servercore21H2 | works | not_working |
Windows 2022 | mcr.microsoft.com/powershell:lts-server-ltsc2022 | gitlab/gitlab-runner-helper:x86_64-latest-servercore21H2 | working | not_working |
Windows 2022 | mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 | gitlab/gitlab-runner-helper:x86_64-latest-nanoserver21H2 | working | not_working |
Windows 2019 | mcr.microsoft.com/windows/servercore:ltsc2019 | gitlab/gitlab-runner-helper:x86_64-latest-servercore1809 | not_working | not_working |
Used GitLab Runner version
Edited by Godefroy Clair