一、GitLab简介
二、安装GitLab
添加helm源
helm repo add stable https://charts.helm.sh/stable
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo add apphub https://apphub.aliyuncs.com/
拉取chart
通过helm拉取chart:
helm pull stable/gitlab-ce
查看一下拉取的chart,看到多了一个 tgz
文件:
$ ls
gitlab-ce-0.2.3.tgz
将其解压,并进入目录:
$ tar -zxvf gitlab-ce-0.2.3.tgz
$ ls
gitlab-4.5.3.tgz gitlab-ce gitlab-ce-0.2.3.tgz
$ cd gitlab-ce/
$ ls
charts Chart.yaml README.md requirements.lock requirements.yaml templates values.yaml
修改values
修改 values.yaml
的相关配置:
externalUrl: http://gitlab.vmware.com/
gitlabRootPassword: "123456"
serviceType: ClusterIP
其中:
- externalUrl 为之后需要配置的域名映射
- gitlabRootPassword 为管理员密码,也可以不设置,这样就会在第一次打开gitlab时提示设置
- serviceType 可以设置为NodePort或LoadBalancer,以暴露其内部/外部端口。如果使用Traefik等服务发现,可以设置为ClusterIP,后面不通过端口访问,只通过域名访问
修改apiVersion
由于我的Kubernetes版本为v18.8,需要将 extensions/v1beta1
修改为 extensions/v1
。
在 gitlab-ce
的外层目录执行:
$ grep -irl "extensions/v1beta1" gitlab-ce | grep deployment
gitlab-ce/templates/deployment.yaml
gitlab-ce/charts/postgresql/templates/deployment.yaml
gitlab-ce/charts/redis/templates/deployment.yaml
可以看到有三个文件包含这样的apiVersion,使用下面的命令将其全部替换即可:
$ grep -irl "extensions/v1beta1" gitlab-ce | grep deployment | xargs sed -i 's#extensions/v1beta1#apps/v1#g'
添加selector
同样地,由于Kubernetes版本比较高,还需要添加selector。
xia先找出需要修改的文件:
$ grep -irl "apps/v1" gitlab-ce | grep deployment
gitlab-ce/templates/deployment.yaml
gitlab-ce/charts/postgresql/templates/deployment.yaml
gitlab-ce/charts/redis/templates/deployment.yaml
然后只能一个一个地修改了。将 selector
添加到 template
的同级。gitlab-ce/templates/deployment.yaml
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "gitlab-ce.fullname" . }}
template:
metadata:
labels:
app: {{ template "gitlab-ce.fullname" . }}
gitlab-ce/charts/postgresql/templates/deployment.yaml
spec:
selector:
matchLabels:
app: {{ template "postgresql.fullname" . }}
template:
metadata:
labels:
app: {{ template "postgresql.fullname" . }}
gitlab-ce/charts/redis/templates/deployment.yaml
spec:
selector:
matchLabels:
app: {{ template "redis.fullname" . }}
template:
metadata:
labels:
app: {{ template "redis.fullname" . }}