You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to run a Github Actions job on a kubernetes runner. The job relies on some background services which run using a custom image. That image name contains an underscore character.
When the job is translated into a pod, the Kubernetes API rejects it due to the container name containing the underscore from the image name:
Error: failed to create job pod: Pod "mycluster-hw6sk-runner-8hv7x-workflow" is invalid: [spec.containers[3].name: Invalid value: "my_image": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
Setting --name or --hostname in the options field seems to have no effect.
Blindly using the image name as the container name seems problematic for other reasons too.
e.g. what happens if you want to launch two background services that use the same image? Or two services with the same registry but different tags?
I am surprised that the key in the services: section is not used by default as this is the documented behaviour when running background services on the standard docker-based runners:
The text was updated successfully, but these errors were encountered:
LPLabrys99
changed the title
Cannot launch job in k8s runner due to underscore in image tag
Cannot launch job in k8s runner due to underscore in image name
Oct 2, 2024
Hi there,
I am trying to run a Github Actions job on a kubernetes runner. The job relies on some background services which run using a custom image. That image name contains an underscore character.
When the job is translated into a pod, the Kubernetes API rejects it due to the container name containing the underscore from the image name:
Setting
--name
or--hostname
in theoptions
field seems to have no effect.The offending line seems to be here:
https://github.com/actions/runner-container-hooks/blob/main/packages/k8s/src/hooks/prepare-job.ts#L61
Blindly using the image name as the container name seems problematic for other reasons too.
e.g. what happens if you want to launch two background services that use the same image? Or two services with the same registry but different tags?
I am surprised that the key in the
services:
section is not used by default as this is the documented behaviour when running background services on the standard docker-based runners:https://docs.github.com/en/actions/use-cases-and-examples/using-containerized-services/about-service-containers#running-jobs-in-a-container
I propose making a change to use the services key instead of the container registry name as the default container name in the kubernetes runner.
Example:
The text was updated successfully, but these errors were encountered: