Add CI configuration for Kubernetes
PATCH v2 1/5 Remove redundant CI variables
In reply to Camilla ConteThese are not needed when using gitlab.com shared runners.
--- .gitlab-ci.d/opensbi.yml | 3 --- 1 file changed, 3 deletions(-)
.gitlab-ci.d/opensbi.yml +0 -3
@@ -48,9 +48,6 @@ docker-opensbi: variables: GIT_DEPTH: 3 IMAGE_TAG: $CI_REGISTRY_IMAGE:opensbi-cross-build - # We don't use TLS - DOCKER_HOST: tcp://docker:2375 - DOCKER_TLS_CERTDIR: "" before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script:
Signature · 1 line
2.40.1
Here's a second version (v2) of patches to support the Kubernetes runner for Gitlab CI.
You can find the v1 thread here: https://lore.kernel.org/qemu-devel/[email protected]/.
PATCH v2 2/5 Use docker "stable" tag
Use the same tag in all jobs.
--- .gitlab-ci.d/container-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
.gitlab-ci.d/container-template.yml +1 -1
@@ -3,7 +3,7 @@ image: docker:stable stage: containers services: - - docker:dind + - docker:stable-dind before_script: - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest" - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
Signature · 1 line
2.40.1
PATCH v2 5/5 Add Kubernetes runner configuration
In reply to Camilla ConteCustom values for the gitlab-runner Helm chart. See https://wiki.qemu.org/Testing/CI/KubernetesRunners.
--- .../ci/gitlab-kubernetes-runners/values.yaml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/ci/gitlab-kubernetes-runners/values.yaml
scripts/ci/gitlab-kubernetes-runners/values.yaml new file +30 -0
@@ -0,0 +1,30 @@ +gitlabUrl: "https://gitlab.com/" +runnerRegistrationToken: "" +rbac: + create: true +concurrent: 200 +runners: + privileged: true + config: | + [[runners]] + limit = 100 + environment = [ + "DOCKER_HOST=tcp://docker:2376", + "DOCKER_TLS_CERTDIR=/certs", + "DOCKER_TLS_VERIFY=1", + "DOCKER_CERT_PATH=/certs/client" + ] + [runners.kubernetes] + poll_timeout = 1200 + image = "ubuntu:20.04" + cpu_request = "0.5" + service_cpu_request = "0.5" + helper_cpu_request = "0.25" + cpu_request_overwrite_max_allowed = "7" + memory_request_overwrite_max_allowed = "30Gi" + [[runners.kubernetes.volumes.empty_dir]] + name = "docker-certs" + mount_path = "/certs/client" + medium = "Memory" + [runners.kubernetes.node_selector] + agentpool = "jobs"
Signature · 1 line
2.40.1
PATCH v2 3/5 Add loop over docker info
In reply to Camilla ConteWait for docker info to return successfuly to ensure that the docker server (daemon) started.
This is needed for jobs running on Kubernetes. See https://wiki.qemu.org/Testing/CI/KubernetesRunners.
--- .gitlab-ci.d/container-template.yml | 2 +- .gitlab-ci.d/opensbi.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
.gitlab-ci.d/container-template.yml +1 -1
@@ -8,8 +8,8 @@ - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest" - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest" - apk add python3 - - docker info - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" + - until docker info; do sleep 1; done script: - echo "TAG:$TAG" - echo "COMMON_TAG:$COMMON_TAG"
.gitlab-ci.d/opensbi.yml +1 -0
@@ -50,6 +50,7 @@ docker-opensbi: IMAGE_TAG: $CI_REGISTRY_IMAGE:opensbi-cross-build before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - until docker info; do sleep 1; done script: - docker pull $IMAGE_TAG || true - docker build --cache-from $IMAGE_TAG --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
Signature · 1 line
2.40.1
PATCH v2 4/5 Add CI variable RUNNER_TAG
In reply to Camilla ConteThis allows to set a job tag dinamically.
We need this to be able to select the Kubernetes runner. See https://wiki.qemu.org/Testing/CI/KubernetesRunners.
--- .gitlab-ci.d/qemu-project.yml | 7 +++++++ 1 file changed, 7 insertions(+)
.gitlab-ci.d/qemu-project.yml +7 -0
@@ -1,6 +1,13 @@ # This file contains the set of jobs run by the QEMU project: # https://gitlab.com/qemu-project/qemu/-/pipelines +variables: + RUNNER_TAG: "" + +default: + tags: + - $RUNNER_TAG + include: - local: '/.gitlab-ci.d/base.yml' - local: '/.gitlab-ci.d/stages.yml'
Signature · 1 line
2.40.1
Quoted 2 lines · Camilla Conte
Here's a second version (v2) of patches to support the Kubernetes runner for Gitlab CI.
You can find the v1 thread here: https://lore.kernel.org/qemu-devel/[email protected]/.
This does not work:
https://gitlab.com/qemu-project/qemu/-/pipelines/875254290
In particular, most jobs spent 30 minutes (until I cancelled them), e.g.
https://gitlab.com/qemu-project/qemu/-/jobs/4329346855#L7561
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
r~
Quoted 11 lines · Richard Henderson
Quoted 2 lines · Camilla Conte
Here's a second version (v2) of patches to support the Kubernetes runner for Gitlab CI.
You can find the v1 thread here: https://lore.kernel.org/qemu-devel/[email protected]/.This does not work:
https://gitlab.com/qemu-project/qemu/-/pipelines/875254290
In particular, most jobs spent 30 minutes (until I cancelled them), e.g.
Quoted 7 lines
https://gitlab.com/qemu-project/qemu/-/jobs/4329346855#L7561
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Seems the problem is with the launcher for the k8s runner which throws a mass of warnings & errors earlier in the logs about pods not being ready
https://gitlab.com/qemu-project/qemu/-/jobs/4329346855#L12
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 3 lines · Richard Henderson
This does not work:
My bad, sorry. I didn't update the runner with the new values.yaml. The Docker environment variables were missing so it's looking for the Docker server at the wrong place.
Now I updated the runner. You have to add the "k8s" tag to the runner again in the settings:
https://gitlab.com/qemu-project/qemu/-/settings/ci_cd#Runners.
As soon as the "k8s" tag is there the pipeline should be able to run.
Re: [PATCH v2 1/5] Remove redundant CI variables
In reply to Camilla ConteQuoted 6 lines · Camilla Conte
These are not needed when using gitlab.com shared runners.
Signed-off-by Camilla Conte <[email protected]>--- .gitlab-ci.d/opensbi.yml | 3 --- 1 file changed, 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 2/5] Use docker "stable" tag
In reply to Camilla ConteQuoted 6 lines · Camilla Conte
Use the same tag in all jobs.
Signed-off-by Camilla Conte <[email protected]>--- .gitlab-ci.d/container-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 3/5] Add loop over docker info
In reply to Camilla ConteQuoted 10 lines · Camilla Conte
Wait for docker info to return successfuly to ensure that the docker server (daemon) started.
This is needed for jobs running on Kubernetes. See https://wiki.qemu.org/Testing/CI/KubernetesRunners.Signed-off-by Camilla Conte <[email protected]>--- .gitlab-ci.d/container-template.yml | 2 +- .gitlab-ci.d/opensbi.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 4/5] Add CI variable RUNNER_TAG
In reply to Camilla ConteQuoted 1 line · Camilla Conte
This allows to set a job tag dinamically.
typo - s/dinamically/dynamically/
can be fixed when a maintainer queues this, no need to repost just for this typo.
Quoted 7 lines
We need this to be able to select the Kubernetes runner. See https://wiki.qemu.org/Testing/CI/KubernetesRunners.
Signed-off-by Camilla Conte <[email protected]>--- .gitlab-ci.d/qemu-project.yml | 7 +++++++ 1 file changed, 7 insertions(+)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 5/5] Add Kubernetes runner configuration
In reply to Camilla ConteQuoted 8 lines · Camilla Conte
Custom values for the gitlab-runner Helm chart. See https://wiki.qemu.org/Testing/CI/KubernetesRunners.
Signed-off-by Camilla Conte <[email protected]>--- .../ci/gitlab-kubernetes-runners/values.yaml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/ci/gitlab-kubernetes-runners/values.yaml
Can't say I'm massively familiar with this, but there's nothing obviously terrible, so on the basis that you've tested it works
Quoted 16 lines
scripts/ci/gitlab-kubernetes-runners/values.yaml new file +9
-0@@ -0,0 +1,30 @@ +gitlabUrl: "https://gitlab.com/" +runnerRegistrationToken: "" +rbac: + create: true +concurrent: 200 +runners: + privileged: true + config: | + [[runners]]
scripts/ci/gitlab-kubernetes-runners/values.yaml line 19
Quoted 10 lines
scripts/ci/gitlab-kubernetes-runners/values.yaml new file +10
-0+ limit = 100 + environment = [ + "DOCKER_HOST=tcp://docker:2376", + "DOCKER_TLS_CERTDIR=/certs", + "DOCKER_TLS_VERIFY=1", + "DOCKER_CERT_PATH=/certs/client" + ] + [runners.kubernetes] + poll_timeout = 1200 + image = "ubuntu:20.04"
Is it viable to update to 22.04 whic is the current newest LTS release stream ?
scripts/ci/gitlab-kubernetes-runners/values.yaml line 30
Quoted 11 lines
scripts/ci/gitlab-kubernetes-runners/values.yaml new file +11
-0+ cpu_request = "0.5" + service_cpu_request = "0.5" + helper_cpu_request = "0.25" + cpu_request_overwrite_max_allowed = "7" + memory_request_overwrite_max_allowed = "30Gi" + [[runners.kubernetes.volumes.empty_dir]] + name = "docker-certs" + mount_path = "/certs/client" + medium = "Memory" + [runners.kubernetes.node_selector] + agentpool = "jobs"
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v3 5/5 Add Kubernetes runner configuration
In reply to Camilla ConteCustom values for the gitlab-runner Helm chart. See https://wiki.qemu.org/Testing/CI/KubernetesRunners.
---
Changes since previous version (PATCH v2 5/5):
- Update ubuntu tag to 22.04. I tested it and it works.
- Remove concurrent jobs limits (use defaults).
.../ci/gitlab-kubernetes-runners/values.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/ci/gitlab-kubernetes-runners/values.yaml
scripts/ci/gitlab-kubernetes-runners/values.yaml new file +28 -0
@@ -0,0 +1,28 @@ +gitlabUrl: "https://gitlab.com/" +runnerRegistrationToken: "" +rbac: + create: true +runners: + privileged: true + config: | + [[runners]] + environment = [ + "DOCKER_HOST=tcp://docker:2376", + "DOCKER_TLS_CERTDIR=/certs", + "DOCKER_TLS_VERIFY=1", + "DOCKER_CERT_PATH=/certs/client" + ] + [runners.kubernetes] + poll_timeout = 1200 + image = "ubuntu:22.04" + cpu_request = "0.5" + service_cpu_request = "0.5" + helper_cpu_request = "0.25" + cpu_request_overwrite_max_allowed = "7" + memory_request_overwrite_max_allowed = "30Gi" + [[runners.kubernetes.volumes.empty_dir]] + name = "docker-certs" + mount_path = "/certs/client" + medium = "Memory" + [runners.kubernetes.node_selector] + agentpool = "jobs"
Signature · 1 line
2.40.1
Re: [PATCH v2 3/5] Add loop over docker info
In reply to Camilla ConteQuoted 1 line · Camilla Conte
+ - until docker info; do sleep 1; done
How long are you expecting this to have to wait?
Less than 5 seconds?
r~
Quoted 6 lines · Camilla Conte
Quoted 3 lines · Richard Henderson
This does not work:
Quoted 9 lines
My bad, sorry. I didn't update the runner with the new
values.yaml. The Docker environment variables were missing so it's looking for the Docker server at the wrong place.Now I updated the runner. You have to add the "k8s" tag to the runner again in the settings:
https://gitlab.com/qemu-project/qemu/-/settings/ci_cd#Runners.
As soon as the "k8s" tag is there the pipeline should be able to run.
The k8s tag has been there on the runner all along. Did you mean something else?
r~
Re: [PATCH v2 3/5] Add loop over docker info
In reply to Richard HendersonQuoted 6 lines · Richard Henderson
Quoted 1 line · Camilla Conte
+ - until docker info; do sleep 1; done
How long are you expecting this to have to wait?
Less than 5 seconds?
I remember seeing jobs where it took longer than five seconds, but I can't find them at the moment.
I guess you wish the "until" loop to fail sooner, rather than having to wait for the whole job timing out.
What about setting a five seconds timeout for the loop and raise it later if we see
jobs failing?
Quoted 4 lines
r~
Quoted 12 lines · Richard Henderson
Quoted 10 lines · Camilla Conte
Quoted 3 lines · Richard Henderson
This does not work:
My bad, sorry. I didn't update the runner with the new
values.yaml. The Docker environment variables were missing so it's looking for the Docker server at the wrong place.
Quoted 7 lines
Quoted 5 lines
Now I updated the runner. You have to add the "k8s" tag to the runner again in the settings:
https://gitlab.com/qemu-project/qemu/-/settings/ci_cd#Runners.
As soon as the "k8s" tag is there the pipeline should be able to run.The k8s tag has been there on the runner all along. Did you mean something else?
I had Paolo adding it a few hours ago.
Quoted 4 lines
r~
Richard Henderson
AppliedQuoted 2 lines · Camilla Conte
Here's a second version (v2) of patches to support the Kubernetes runner for Gitlab CI.
You can find the v1 thread here: https://lore.kernel.org/qemu-devel/[email protected]/.
Applied to master. With the k8s tag on the azure runner, it seems to work.
r~
Re: [PATCH v2 2/5] Use docker "stable" tag
In reply to Camilla ConteQuoted 12 lines · Camilla Conte
Use the same tag in all jobs.
Signed-off-by Camilla Conte <[email protected]>--- .gitlab-ci.d/container-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-).gitlab-ci.d/container-template.yml +0
-0
.gitlab-ci.d/container-template.yml line 6
Quoted 5 lines
.gitlab-ci.d/container-template.yml +1
-1@@ -3,7 +3,7 @@ image: docker:stable stage: containers services: - - docker:dind + - docker:stable-dind
For reasons I don't understand, this change is responsible for all our failed CI jobs involving Fedora being unable to resolve DNS
Fedora 37 - x86_64 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'fedora':
- Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-37&arch=x86_64&countme=1 [getaddrinfo() thread failed to start]
- Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-37&arch=x86_64 [getaddrinfo() thread failed to start]
Error: Failed to download metadata for repo 'fedora': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-37&arch=x86_64 [getaddrinfo() thread failed to start]
Switching back to ':dind' instead of ':stable-dind' makes it work again.
AFAICT, the ':stable-dind' and ':stable' tags are no longer even supported.
The last published content under these tags dates from 2020, and these tag names are not mentioned on
https://hub.docker.com/_/docker
While reverting this change would fix our Fedora problems, it leaves usage of the 'stable-dind' tag in opensbi.yml, as well as 'stable' tag usage in other places.
Thus I'm going to test a patch to move everything to 'latest' / 'dind'
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 2/5] Use docker "stable" tag
Quoted 22 lines · Daniel P. Berrangé
Quoted 12 lines · Camilla Conte
Use the same tag in all jobs.
Signed-off-by Camilla Conte <[email protected]>--- .gitlab-ci.d/container-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-).gitlab-ci.d/container-template.yml +0
-0.gitlab-ci.d/container-template.yml line 6
Quoted 5 lines
.gitlab-ci.d/container-template.yml +1
-1@@ -3,7 +3,7 @@ image: docker:stable stage: containers services: - - docker:dind + - docker:stable-dindFor reasons I don't understand, this change is responsible for all our failed CI jobs involving Fedora being unable to resolve DNS
Quoted 1 line
AFAICT, the ':stable-dind' and ':stable' tags are no longer even supported.
And I found confirmation of this:
https://github.com/docker-library/docker/commit/606c63960a4845af7077721eb3900c706f5d0c5e
"This will remove the "test" and "stable" aliases for whatever
major release comes after 19.03 (so once the next release comes out, "stable" will become a stale alias).
I'm not 100% sure this is the right answer, but the "stable" alias has definitely been a huge source of confusion very recently (and it doesn't have much meaning anymore anyways given the death of the "edge" channel)."
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 2/5] Use docker "stable" tag
Quoted 29 lines · Daniel P. Berrangé
Quoted 22 lines · Daniel P. Berrangé
Quoted 12 lines · Camilla Conte
Use the same tag in all jobs.
Signed-off-by Camilla Conte <[email protected]>--- .gitlab-ci.d/container-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-).gitlab-ci.d/container-template.yml +0
-0.gitlab-ci.d/container-template.yml line 6
Quoted 5 lines
.gitlab-ci.d/container-template.yml +1
-1@@ -3,7 +3,7 @@ image: docker:stable stage: containers services: - - docker:dind + - docker:stable-dindFor reasons I don't understand, this change is responsible for all our failed CI jobs involving Fedora being unable to resolve DNS
Quoted 1 line
AFAICT, the ':stable-dind' and ':stable' tags are no longer even supported.
And I found confirmation of this:
https://github.com/docker-library/docker/commit/606c63960a4845af7077721eb3900c706f5d0c5e
Quoted 8 lines
"This will remove the "test" and "stable" aliases for whatever
major release comes after 19.03 (so once the next release comes out, "stable" will become a stale alias).I'm not 100% sure this is the right answer, but the "stable" alias has definitely been a huge source of confusion very recently (and it doesn't have much meaning anymore anyways given the death of the "edge" channel)."
Excellent, thanks for the sleuthing.
r~