Running K8s cluster from Gitlab-runner on Openshift

12/6/2017

Currently I have a Kubernetes cluster prepared for using it with Gitlab-runner and its kubernetes executor and I want to use it from a different Openshift cluster, so I have two different and separated clusters.

I am currently running the Gitlab-runner image on an Openshift pod with a config.toml like this, following the docs in https://docs.gitlab.com/runner/executors/kubernetes.html#connecting-to-the-kubernetes-api:

concurrent = 1
check_interval = 10
[[runners]]
  name = "size-XL"
  url = "https://blablabla/ci"
  token = "blablabla"
  executor = "kubernetes"
  [runners.kubernetes]
    namespace = "gitlab"
    privileged = false
    host= "https://blablabla:6443"
    cert_file= "/etc/ssl/certs/cert.pem"
    key_file= "/etc/ssl/certs/key.pem"
    ca_keyfile= "/etc/ssl/certs/ca.pem"
    cpu_limit = "4"
    memory_limit = "6Gi"
    service_cpu_limit = "1"
    service_memory_limit = "2Gi"
    helper_cpu_limit = "2"
    helper_memory_limit = "2Gi"
    cpu_request = "1"
    memory_request = "2Gi"
    service_cpu_request = "250Mi"
    service_memory_request = "512Mi"
    helper_cpu_request = "250Mi"
    helper_memory_request = "512Mi"
    service-account = "test"
    service_account_overwrite_allowed = ".*"
    image = "blablabla"

My problem is that even if it is able to connect to the K8s cluster and start picking jobs, any time it does, I get this:

Checking for jobs... received                       job=17311 repo_url=https://blablabla.git runner=c36ccf98
WARNING: Preparation failed: error connecting to Kubernetes: ca file, cert file and key file must be specified when using file based auth  job=17311 project=3128 runner=c36ccf98
Will be retried in 3s ...                           job=17311 project=3128 runner=c36ccf98
WARNING: Preparation failed: error connecting to Kubernetes: ca file, cert file and key file must be specified when using file based auth  job=17311 project=3128 runner=c36ccf98
Will be retried in 3s ...                           job=17311 project=3128 runner=c36ccf98
WARNING: Preparation failed: error connecting to Kubernetes: ca file, cert file and key file must be specified when using file based auth  job=17311 project=3128 runner=c36ccf98
Will be retried in 3s ...                           job=17311 project=3128 runner=c36ccf98
ERROR: Job failed (system failure): error connecting to Kubernetes: ca file, cert file and key file must be specified when using file based auth job=17311 project=3128 runner=c36ccf98

I had no luck, any idea?

-- djuarez
gitlab
gitlab-ci
gitlab-ci-runner
kubernetes
openshift

1 Answer

12/7/2017
ca_keyfile= "/etc/ssl/certs/ca.pem"

was in fact the problem. because it is just ca_file instead of ca_keyfile

-- djuarez
Source: StackOverflow