Skip to content

Allow service alias from config in Kubernetes executor

What does this MR do?

Allows using service aliases from config.toml.

Are there points in the code the reviewer needs to double check?

You can test with this .gitlab-ci.yaml:

nginx:
    script:
        - wget proxy:80

And this runner-config.toml:

concurrent = 10
check_interval = 3
log_level = "debug"

[session_server]
  session_timeout = 1800

[[runners]]
  name = "name"
  url = "https://gitlab.com/"
  token = "-----"
  executor = "kubernetes"
  [runners.kubernetes]
    image = "alpine"
    [[runners.kubernetes.services]]
        name = "nginx"
        alias = "proxy" 

With alias the job should display:

 echo '$ wget proxy:80'
 wget proxy:80
 Connecting to proxy:80 (127.0.0.1:80)
 saving to 'index.html'
 index.html           100% |********************************|   612  0:00:00 ETA
 'index.html' saved

Using an invalid alias in the runner-config.toml should result in an error when executing a job:

ERROR: Job failed (system failure): provided host alias proxy___% for service nginx is invalid DNS. a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')  duration=29.712182ms job=444848735 project=15339497 runner=efc1edjz

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Added tests for this feature/bug
  • In case of conflicts with master - branch was rebased

What are the relevant issue numbers?

Closes #4829 (closed)

Edited by Georgi N. Georgiev

Merge request reports