Services don't seem to start on GitLab Runner (Kubernetes executor)
Summary
We are using GitLab-runner in our own Kubernetes Environment. Whenever we try to use the services option in Gitlab CI, it doesn't seem to be started, and we cannot connect to it.
Note that everything else on our GitLab EE and GitLab-runner is working perfectly. I also tried this for a Redis service.
Steps to reproduce
Using the following .gitlab-ci-.yaml:
image: docker:latest
variables:
DOCKER_DRIVER: overlay2
NAME: mysql-test
stages:
- build
mysql_build:
stage: build
variables:
MYSQL_DATABASE: hello_world_test
MYSQL_ROOT_PASSWORD: mysql
services:
- mysql
image: mysql
before_script:
- mysql --version
script:
- echo "SELECT 'OK';" | mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" --host=mysql "${MYSQL_DATABASE}"
Actual behavior
As seen below, it can't connect to MySQL. It also doesn't say it started the MySQL service at the top, so it seems that the services part is completely ignored.
Job output:
Running with gitlab-ci-multi-runner 9.1.0 (0118d89)
on gitlab-runner-docker-848662861-471kp (e38867b8)
Using Kubernetes namespace: default
Using Kubernetes executor with image mysql ...
Waiting for pod default/runner-e38867b8-project-11-concurrent-0zn1mf to be running, status is Pending
Running on runner-e38867b8-project-11-concurrent-0zn1mf via gitlab-runner-docker-848662861-471kp...
Cloning repository...
Cloning into '/test/mysql-test'...
Checking out 373e04b1 as gitlab...
Skipping Git submodules setup
$ mysql --version
mysql Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper
$ echo "SELECT 'OK';" | mysql --user=root --password="${MYSQL_ROOT_PASSWORD}" --host=mysql "${MYSQL_DATABASE}"
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host 'mysql' (0)
ERROR: Job failed: error executing remote command: command terminated with non-zero exit code: Error executing in Docker Container: 1
GitLab runner debug mode output:
Checking for jobs... received job=1800 repo_url=https://******* runner=9f3ea113
Requeued the runner builds=1 runner=9f3ea113
Running with gitlab-ci-multi-runner 9.1.0 (0118d89)
on gitlab-runner-docker-848662861-x7nvq (9f3ea113) job=1800 project=11 runner=9f3ea113
Shell configuration: environment: []
dockercommand:
- sh
- -c
- "if [ -x /usr/local/bin/bash ]; thenntexec /usr/local/bin/bash nelif [ -x /usr/bin/bash
]; thenntexec /usr/bin/bash nelif [ -x /bin/bash ]; thenntexec /bin/bash nelif
[ -x /usr/local/bin/sh ]; thenntexec /usr/local/bin/sh nelif [ -x /usr/bin/sh
]; thenntexec /usr/bin/sh nelif [ -x /bin/sh ]; thenntexec /bin/sh nelsentecho
shell not foundntexit 1nfinn"
command: bash
arguments: []
passfile: false
extension: ""
job=1800 project=11 runner=9f3ea113
Configuration entry 'namespace_overwrite_allowed' is empty, using configured namespace. job=1800 project=11 runner=9f3ea113
WARNING: Namespace is empty, therefore assuming 'default'. job=1800 project=11 runner=9f3ea113
Using Kubernetes namespace: default job=1800 project=11 runner=9f3ea113
Using Kubernetes executor with image mysql ... job=1800 project=11 runner=9f3ea113
Waiting for signals... job=1800 project=11 runner=9f3ea113
Starting Kubernetes command... job=1800 project=11 runner=9f3ea113
Submitting job to coordinator... ok job=1800 runner=9f3ea113
Appending trace to coordinator... ok code=202 job=1800 job-log=0-388 job-status=running runner=9f3ea113 sent-log=0-388 status=202 Accepted
Appending trace to coordinator... ok code=202 job=1800 job-log=0-490 job-status=running runner=9f3ea113 sent-log=388-490 status=202 Accepted
Dialing: tcp gitlab.gitlab:8005 ...
Appending trace to coordinator... ok code=202 job=1800 job-log=0-592 job-status=running runner=9f3ea113 sent-log=490-592 status=202 Accepted
Appending trace to coordinator... ok code=202 job=1800 job-log=0-694 job-status=running runner=9f3ea113 sent-log=592-694 status=202 Accepted
Starting Kubernetes command... job=1800 project=11 runner=9f3ea113
Starting Kubernetes command... job=1800 project=11 runner=9f3ea113
Starting Kubernetes command... job=1800 project=11 runner=9f3ea113
Starting Kubernetes command... job=1800 project=11 runner=9f3ea113
Starting Kubernetes command... job=1800 project=11 runner=9f3ea113
WARNING: Job failed: error executing remote command: command terminated with non-zero exit code: Error executing in Docker Container: 1 job=1800 project=11 runner=9f3ea113
Submitting job to coordinator... ok job=1800 runner=9f3ea113
Expected behavior
A successful connection to the started(?) mysql service.
Environment description
Running GitLab (and the runner) in Kubernetes 1.6.
Used GitLab Runner version
Running GitLab runner: gitlab/gitlab-runner:alpine-v9.1.0.