Support for Shared VPC Networks
Hello,
Being a everyday user of Gitlab(EE), I am aiming to deploy a Fleet of Windows Runners. For that I would like to rely on the executor you've made for it and that you are using for your own fleet.
When trying to utilize a network defined in a Shared VPC on GCP, I run into an issue. It seems it is not something (yet) accepted. Meaning that by default we can't define a "Network" that is defined in a SHDVPC. It automatically take the value specified for the "Project" which correspond to the project in which we want our VMs to be deployed.
Steps to Reproduce:
-
Get 2 GCP projects one in which you have your Gitlab Runner running on a VM (with container deploy inside using this image:
registry.gitlab.com/gitlab-org/ci-cd/custom-executor-drivers/autoscaler:latest
). -
Create the config file for the Gitlab Runner:
concurrent = 10
check_interval = 3
[[runners]]
name = "windows-autoscaler-public"
url = "https://gitlab.com/"
token = "xxxxxxxx"
executor = "custom"
builds_dir = "<path to build_dir>"
cache_dir = "<path to cache_dir>"
shell = "powershell"
[runners.custom]
config_exec = "<path to autoscaler binary>"
config_args = ["--config", "<path to autoscaler config.toml>", "custom", "config"]
prepare_exec = "<path to autoscaler binary>"
prepare_args = ["--config", "<path to autoscaler config.toml>", "custom", "prepare"]
run_exec = "<path to autoscaler binary>"
run_args = ["--config", "<path to autoscaler config.toml>", "custom", "run"]
cleanup_exec = "<path to autoscaler binary>"
cleanup_args = ["--config", "<path to autoscaler config.toml>", "custom", "cleanup"]
- Create the config file for the Autoscaler:
Provider = "gcp"
OS = "windows"
LogLevel = "info"
LogFormat = "json"
LogFile = "<path to autoscaler.log>"
VMTag = "wsrm"
[GCP]
ServiceAccountFile = "<path to service-account.json>"
Project = "my-project"
Zone = "us-east1-c"
MachineType = "n1-standard-2"
Image = "projects/some-project-df9383/global/images/runners-windows-2019-core-containers-beta"
DiskSize = 50
DiskType = "pd-standard"
Subnetwork = "windows-runners"
Network = "shdvpc-network" --> being defined not in "my-project" but in my sharedVPC project "shdvpc-my-project"
Tags = ["windows-autoscaled-runner"]
Username = "gitlab_runner"
[WinRM]
MaximumTimeout = 3600
ExecutionMaxRetries = 4
[ProviderCache]
Enabled = true
Directory = "<path to machines dir>"
Now you can trigger a pipeline if a job using the Gitlab Runner we configured. The Autoscaler will throw errors, as it couldn't find the Network specified. It will be trying to get it not in "shdvpc-my-project" but in "my-project".
Even if you try to specify the value:
- "projects/shdvpc-my-project/global/network/shdvpc-network" --> in the end it will use: "projects/my-project/global/network/shdvpc-networkprojects/shdvpc-my-project/global/network/shdvpc-network"
Expected Behavior: The expected behavior would be for the Autoscaler to successfully use a "Network" from a sharedVPC.
Actual Behavior: The current behavior is that the Autoscaler isn't able to find the "Network" as the GCP API is throwing an error while trying to find this "Network" in the project defined for the VMs to be deployed in.
Thanks for your help !
(I will propose a change through a pull request)