[registry] Add PersistentVolumeClaim to registry helm chart to allow persistence with an existing PersistentVolume

Summary

I want to use filesystem storage for the registry in my gitlab helm installation. (the reason is that there is a problem with using registry with minio storage and I will create a separate issue for it). For me using filesystem storage in current kubernetes installation would be a good workaround. But currently gitlab container registry helm chart does not work with filesystem storage.

I created a secret (below is helm template):

apiVersion: v1
kind: Secret
metadata:
  name: gitlab-registry-filesystem
  namespace: gitlab
type: Opaque
data:
  config: {{ print "filesystem:" "\n"  "  rootdirectory: /var/lib/registry"  | b64enc }}
$ kubectl get -o yaml secret/gitlab-registry-filesystem | yq .data.config | base64 -d
filesystem:
  rootdirectory: /var/lib/registry/

and my gitlab.values.yaml contains:

registry:
  enabled: true
  hpa:
    minReplicas: 1
    maxReplicas: 1
  storage:
    secret: gitlab-registry-filesystem
    key: config

but the registry deployment log contains messages:

... "detail":"filesystem: mkdir /var/lib/registry: permission denied" ... "go_version":"go1.21.7", ... "version":"v3.88.1-gitlab" ...

kubectl exec deployment.apps/gitlab-xxx-registry -- mkdir /var/lib/registry gives error:

mkdir: cannot create directory ‘/var/lib/registry’: Permission denied

I created a persistent volume:

apiVersion: v1
kind: PersistentVolume
metadata:
  labels:
    app: gitlab-registry
  name: gitlab-persistentvolume-registry
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 12Gi
  hostPath:
    path: /opt/volume/gitlab-registry/
    type: ""
  persistentVolumeReclaimPolicy: Retain
  volumeMode: Filesystem

But there is no option in gitlab container registry helm chart like PersistentVolume or extraVolumeMounts to attach this volume to the registry deployment.

Current behavior

No way to attach existing persistent volume to gitlab container registry.

Expected behavior

Expected to have a commonly used approach having extraVolumeMounts to attach volumes to registry deployment.

Versions

  • Chart: gitlab-7.9.1
  • Platform:
    • Self-hosted: k0s
  • Kubernetes: (kubectl version)
    • Client: v1.29.1
    • Server: v1.29.1+k0s
  • Helm: (helm version)
    • Client: v3.14.0
Edited by susy belle