A Gitlab Runner custom executor for running jobs in VMs on kubernetes
Before you begin, make sure that KubeVirt has been installed to the cluster where you want to run these VM jobs.
Add this configuration to your runner:
[[runners]]
name = "kubevirt"
executor = "custom"
[runners.custom]
config_exec = "/bin/gitlab-runner-kubevirt"
config_args = ["config"]
prepare_exec = "/bin/gitlab-runner-kubevirt"
prepare_args = [
"prepare",
<prepare config flags ...>
]
run_exec = "/bin/gitlab-runner-kubevirt"
run_args = [
"run",
"--shell", "bash",
<run config flags ...>
]
cleanup_exec = "/bin/gitlab-runner-kubevirt"
cleanup_args = ["cleanup"]
Various aspects of the virtual machines can be
The gitlab-runner-kubevirt executor can be used with the official gitlab-runner helm chart. Simply add the following to the values:
image: ghcr.io/snaipe/gitlab-runner-kubevirt:main
runners:
executor: custom
config: |
[[runners]]
name = "kubevirt"
executor = "custom"
[runners.custom]
config_exec = "/bin/gitlab-runner-kubevirt"
config_args = ["config"]
prepare_exec = "/bin/gitlab-runner-kubevirt"
prepare_args = ["prepare"]
run_exec = "/bin/gitlab-runner-kubevirt"
run_args = ["run", "--shell", "bash"]
cleanup_exec = "/bin/gitlab-runner-kubevirt"
cleanup_args = ["cleanup"]
[[runners]]
name = "kubernetes-windows-kubevirt"
executor = "custom"
shell = "pwsh"
[runners.custom]
config_exec = "/bin/gitlab-runner-kubevirt"
config_args = ["config"]
prepare_exec = "/bin/gitlab-runner-kubevirt"
prepare_args = [
"prepare",
"--debug",
"--default-image", "gitlab-registry.example.com:5050/ci/windows:v0.0.1"
"--default-memory-request", "4G",
"--default-memory-limit", "4G",
"--default-cpu-request", "2",
"--default-cpu-limit", "2",
"--default-ephemeral-storage-request", "30Gi",
"--default-ephemeral-storage-limit", "60Gi",
"--default-image-pull-secret", "gitlab-registry-credentials",
"--timeout", "1h",
]
run_exec = "/bin/gitlab-runner-kubevirt"
run_args = [
"run",
"--shell", "pwsh",
"--ssh-user", "vagrant",
"--ssh-password", "vagrant",
]
cleanup_exec = "/bin/gitlab-runner-kubevirt"
cleanup_args = ["cleanup"]