我正在尝试使用 Helm 将 Gitlab 安装到 OpenShift 3.11 。
为此,我尝试遵循Gitlab文档,并尝试一些示例。
我正在从Ansible剧本中运行Helm。我用来运行Helm命令的任务是:
- 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"
永久卷声明绑定到不正确的永久卷。
运行helm install
之后运行oc get pv
后,我看到以下内容(注意声明未绑定到正确的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
我看到了这个示例-https://gitlab.com/gitlab-org/charts/gitlab/blob/master/examples/storage/use_manual_volumes.yml-通过在Helm值文件中添加以下内容显示,我可以纠正此问题-但它没有任何作用:
gitlab:
gitaly:
persistence:
volumeName: repo-data-gitlab-gitaly-0
postgresql:
persistence:
volumeName: gitlab-postgresql
minio:
persistence:
volumeName: gitlab-minio
redis:
persistence:
volumeName: gitlab-redis
如何安装gitlab,使持久卷绑定到正确的持久卷声明?
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
答案 0 :(得分:0)
我能够使用以下艰巨的任务解决此问题:
- 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']
请注意,使用claimRef
(用于绑定到PVC)
另请参见https://stackoverflow.com/a/34323691/265119以获得很好的解释。