I'm attempting to install Gitlab, using Helm, to OpenShift 3.11.
To do this, I'm trying to follow the Gitlab documentation, and also trying some of the examples.
I'm running Helm from an Ansible playbook. The task that I use to run the Helm commands is:
- name: Install Gitlab using Helm
command: "{{ item }} "
loop:
- "helm repo add gitlab https://gitlab-charts.s3.amazonaws.com/ --ca-file=/etc/ssl/certs/ca-bundle.crt"
- "helm repo update"
- "helm install gitlab/gitlab -f /home/{{ ansible_ssh_user }}/files/gitlab-customize.yaml --name gitlab"
Persistent volume claims are binding to the incorrect Persistent Volumes.
After running helm install
then running oc get pv
I see the following (notice how the claims are not being bound to the correct PV):
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
gitlab-minio 10Gi RWO Retain Bound kube-system/gitlab-prometheus-server 1m
gitlab-postgresql 10Gi RWO Retain Bound kube-system/gitlab-postgresql 1m
gitlab-prometheus-server 10Gi RWO Retain Available 1m
repo-data-gitlab-gitaly-0 50Gi RWO Retain Bound kube-system/repo-data-gitlab-gitaly-0
1m
I saw this example - https://gitlab.com/gitlab-org/charts/gitlab/blob/master/examples/storage/use_manual_volumes.yml - that shows by adding the following in the Helm values file, I could remedy this issue - however it hasnt made any difference:
gitlab:
gitaly:
persistence:
volumeName: repo-data-gitlab-gitaly-0
postgresql:
persistence:
volumeName: gitlab-postgresql
minio:
persistence:
volumeName: gitlab-minio
redis:
persistence:
volumeName: gitlab-redis
How can I install gitlab in such a way that the Persistent volumes bind to the correct Persistent Volume Claims?
Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
oc v3.11.0+62803d0-1
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://wallets-mgnt-master100.mgmt.wallets:8443
openshift v3.11.0+bd0bee4-337
kubernetes v1.11.0+d4cacc0
I was able to solve this using the following, ansible task:
- name: "Create PersistentVolume for each gitlab component"
k8s:
name: "{{ item[0] | lower }}"
state: present
definition:
apiVersion: v1
kind: PersistentVolume
metadata:
namespace: kube-system
name: "{{ item[0] | lower }}"
labels:
app: "{{ item[1] }}"
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: "{{ item[2] }}"
hostPath:
path: "/{{ansible_env.PV_HOST_DIRECTORY}}/{{ item[0] | lower }}"
persistentVolumeReclaimPolicy: Retain
claimRef:
namespace: kube-system
name: "{{ item[0] | lower }}"
loop:
- [ 'gitlab-minio', 'minio', '10Gi' ]
- [ 'gitlab-postgresql', 'postgresql', '10Gi']
- [ 'gitlab-prometheus-server', 'prometheus', '10Gi']
- [ 'repo-data-gitlab-gitaly-0', 'gitlab', '50Gi']
- [ 'gitlab-redis', 'gitlab-redis', '5Gi']
Note, the use of claimRef
, which is used to bind to the PVC.
See also https://stackoverflow.com/a/34323691/265119 for a good explanation.