Permission denied when using Kubernetes executor and a non-root docker image: mkdir: cannot create directory ‘/builds’: Permission denied
I deployed a gitlab-runner with this helm chart values:
replicas: 3
imagePullPolicy: IfNotPresent
gitlabUrl: https://gitlab.com/
podAnnotations:
reloader.stakater.com/search: "true"
unregisterRunners: true
terminationGracePeriodSeconds: 3600
concurrent: 10
checkInterval: 30
rbac:
create: true
clusterWideAccess: false
rules:
- apiGroups: [""]
resources: ["*"]
verbs: ["*"]
podSecurityPolicy:
enabled: false
resourceNames:
- gitlab-runner
service:
enabled: true
type: ClusterIP
metrics:
enabled: true
portName: metrics
port: 9252
serviceMonitor:
enabled: true
interval: 1h
scheme: http
path: "/metrics"
env:
TZ: America/Santiago
runners:
#name: "gitlab-runner"
secret: gitlab-runner-secret
config: |
[[runners]]
environment = ["FF_GITLAB_REGISTRY_HELPER_IMAGE=true"]
builds_dir = "/builds"
[runners.feature_flags]
FF_USE_ADVANCED_POD_SPEC_CONFIGURATION = true
[runners.kubernetes]
node_selector_overwrite_allowed = ".*"
image = "alpine:latest"
privileged = true
# build container
cpu_limit = "600m"
memory_limit = "1Gi"
# service containers
service_cpu_limit = "600m"
service_memory_limit = "1Gi"
# helper container
helper_cpu_limit = "600m"
helper_memory_limit = "200Mi"
[[runners.kubernetes.volumes.host_path]]
name = "devices"
host_path = "/dev"
mount_path = "/dev"
read_only = true
[[runners.kubernetes.pod_spec]]
name = "ephemeral-builds"
patch_type = "strategic"
patch = '''
containers:
- name: build
volumeMounts:
- name: builds
mountPath: /builds
- name: helper
volumeMounts:
- name: builds
mountPath: /builds
volumes:
- name: builds
ephemeral:
volumeClaimTemplate:
spec:
storageClassName: local-hostpath
accessModes: [ ReadWriteOnce ]
resources:
requests:
storage: 8Gi
'''
[[runners.kubernetes.volumes.empty_dir]]
name = "docker-certs"
mount_path = "/certs/client"
medium = "Memory"I'm using an archlinux-nonroot image, in some builds I receive the following error:
Running with gitlab-runner 16.8.0 (c72a09b6)
on gitlab-runner-76864558c7-lgxvn 1NY2we7xZ, system ID: r_k4agup8CkBqH
feature flags: FF_USE_ADVANCED_POD_SPEC_CONFIGURATION:true
Preparing the "kubernetes" executor 00:00
Using Kubernetes namespace: gitlab-runner-system
Using Kubernetes executor with image [MASKED]/docker-archlinux-nonroot ...
Using attach strategy to execute scripts...
Preparing environment 00:10
Using FF_USE_POD_ACTIVE_DEADLINE_SECONDS, the Pod activeDeadlineSeconds will be set to the job timeout: 1h0m0s...
WARNING: Advanced Pod Spec configuration enabled, merging the provided PodSpec to the generated one. This is a beta feature and is subject to change. Feedback is collected in this issue: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29659 ...
Waiting for pod gitlab-runner-system/runner-1ny2we7xz-project-50969276-concurrent-0-nzd20s0i to be running, status is Pending
Unschedulable: "0/7 nodes are available: waiting for ephemeral volume controller to create the persistentvolumeclaim \"runner-1ny2we7xz-project-50969276-concurrent-0-nzd20s0i-builds\". preemption: 0/7 nodes are available: 7 Preemption is not helpful for scheduling.."
Waiting for pod gitlab-runner-system/runner-1ny2we7xz-project-50969276-concurrent-0-nzd20s0i to be running, status is Pending
ContainersNotInitialized: "containers with incomplete status: [init-permissions]"
ContainersNotReady: "containers with unready status: [build helper]"
ContainersNotReady: "containers with unready status: [build helper]"
Waiting for pod gitlab-runner-system/runner-1ny2we7xz-project-50969276-concurrent-0-nzd20s0i to be running, status is Pending
ContainersNotReady: "containers with unready status: [build helper]"
ContainersNotReady: "containers with unready status: [build helper]"
Running on runner-1ny2we7xz-project-50969276-concurrent-0-nzd20s0i via gitlab-runner-76864558c7-lgxvn...
Getting source from Git repository 00:01
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/mapanare-labs/packages/archlinux/infracost/.git/
Created fresh repository.
Checking out 96e7f970 as detached HEAD (ref is main)...
Skipping Git submodules setup
Executing "step_script" stage of the job script 00:01
mkdir: cannot create directory ‘/builds’: Permission denied
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: command terminated with exit code 1Any ideas?