Replace this template with your information
Describe your question in as much detail as possible:
Dear Gitlab community,
I have 2 local gitlab instances:
- mygitlab.home
- myothergitlab.home
Then I have a k8s cluster with a gitlab runner installed using the official helm chart, I also have a secret volume configured to mount into the runner.
My problem is that when I push to mygitlab.home, the runner works as expected meaning it mounts the secret volume, however, if I push to myothergitlab.home, then the secret volume is not mounted into the gitlab runner.
What is the reason behind this?
imagePullPolicy: IfNotPresent
replicas: 1
gitlabUrl: https://mygitlab.home/
runnerRegistrationToken: "--REDACTED--"
terminationGracePeriodSeconds: 3600
concurrent: 15
checkInterval: 30
rbac:
create: true
rules:
- resources: ["pods", "pods/exec", "secrets", "configmaps", "pods/attach"]
verbs: ["get", "list", "watch", "create", "patch", "delete", "update"]
clusterWideAccess: false
## Use podSecurity Policy
## ref: https://kubernetes.io/docs/concepts/policy/pod-security-policy/
podSecurityPolicy:
enabled: true
resourceNames:
- gitlab-runner
metrics:
enabled: true
runners:
name: "new-runner"
locked: false
config: |
[[runners]]
clone_url = "https://mygitlab.home./"
[runners.kubernetes]
privileged = false
[[runners.kubernetes.volumes.secret]]
name = "mysecrets"
mount_path = "/mysecrets"
read_only = true
[runners.kubernetes.volumes.secret.items]
"username" = "username"
"password" = "password"
[runners.kubernetes.volumes]
[[runners.kubernetes.volumes.empty_dir]]
name = "repo"
mount_path = "/builds"
medium = "Memory"
executor: kubernetes
tags: "test"
And this is my pipeline:
variables:
GIT_SUBMODULE_STRATEGY: recursive
VCS_GIT: myanotheranothergitlab.home/vcs/
stages:
- pre
- build
- test
sync-git-branch:
image: registry.gitlab.com/gitlab-org/gitlab-runner:alpine-v15.2.1
stage: pre
script:
- USER=$(cat /mysecrets/username)
- PASS=$(cat /mysecrets/password)
- git config --local http.sslverify false
- git remote add vcs https://${USER}:${PASS}@${VCS_GIT}/${CI_PROJECT_NAME}
- git fetch origin
- git fetch vcs
- git submodule update --remote
- git push vcs HEAD:refs/heads/${CI_COMMIT_BRANCH}
- git push vcs HEAD:${CI_COMMIT_REF_NAME}
rules:
- if: $CI_COMMIT_BRANCH
tags:
- test
- What are you seeing, and how does that differ from what you expect to see?
The pipeline fails because the secret is not mounted:
$ USER=$(cat /mysecrets/username)
cat: can't open '/mysecrets/username': No such file or directory
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: command terminated with exit code 1
-
Consider including screenshots, error messages, and/or other helpful visuals
-
What version are you on? Are you using self-managed or GitLab.com?
-
GitLab (Hint:
/help
):
myothergitlab.home is version 14.9.2
mygitlab.home is version 15.11.3 -
Runner (Hint:
/admin/runners
):
gitlab runner version is 15.2.1
-
-
Add the CI configuration from
.gitlab-ci.yml
and other configuration if relevant (e.g. docker-compose.yml) -
What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
I have modified the pipeline with a sleep 20m
to keep the container runner running, then I describe the runner and I can verify the secrets volume is not getting mounted
Thanks for taking the time to be thorough in your request, it really helps!