Skip to content

Configuring S3 cache with k8 s3 secret doesn't work (using helm 0.23.0)

Summary

Steps to reproduce

Hi, We have gitlab 13.12 and are trying to use s3 bucket for maven (.m2) repository cache since we are using Kubernetes and docker containers to run the runners. I followed the docs in order to set S3: https://docs.gitlab.com/runner/install/kubernetes.html#s3

NOTE: I use Helm chart 0.23.0 to install runners

After creating a secret in K8:

kubectl create secret generic s3access \
    --from-literal=accesskey="xxxxx" \
    --from-literal=secretkey="xxxx" \
    -n my-namespace

and later configuring my values.yml:

runners:
  config: |
    [[runners]]
      [runners.kubernetes]
        image = "registry.com:5040/maven:3.6-jdk-11"
        [[runners.kubernetes.volumes.host_path]]
          name = "docker-socket"
          mount_path = "/var/run/docker.sock"
          path = "/var/run/docker.sock"
        [runners.cache]
          Type = "s3"
          Path = "maven"
          Shared = true
          [runners.cache.s3]
            ServerAddress = "mydns.com:8082"
            BucketName = "my-bucket-cache"
            BucketLocation = "ESH"
            Insecure = false
  cache:
      secretName: s3access

I get error:

No URL provided, cache will be not uploaded to shared cache server. which is open issue at: #16097 (closed)

I found out that cache: secretName: s3access is completely ignored. I know this because when I remove the secret and instead, manually adding the following configuration to [runners.cache.s3] it worked:

            AccessKey = "xxxx"
            SecretKey = "xxxxx"

To runner config and it worked!

I still want to use kubernetes secret instead. How can I solve this issue? I think maybe something is wrong with what I'm doing.

.gitlab-ci.yml
runners:
  config: |
    [[runners]]
      [runners.kubernetes]
        image = "registry.com:5040/maven:3.6-jdk-11"
        [[runners.kubernetes.volumes.host_path]]
          name = "docker-socket"
          mount_path = "/var/run/docker.sock"
          path = "/var/run/docker.sock"
        [runners.cache]
          Type = "s3"
          Path = "maven"
          Shared = true
          [runners.cache.s3]
            ServerAddress = "mydns.com:8082"
            BucketName = "my-bucket-cache"
            BucketLocation = "ESH"
            Insecure = false
  cache:
      secretName: s3access```
</details>

## Actual behavior
No URL provided, cache will be not uploaded to shared cache server

## Expected behavior
the cache is used

## Relevant logs and/or screenshots


<details>
<summary> job log </summary>
</details>

## Environment description

### Used GitLab Runner version

## Possible fixes
Edited by Ghost User