一.环境信息
存储使用nfs挂载持久化
k8s环境
helm安装 建议helm 3+
二.部署gitlab-runner
1.查看gitlab版本
进入容器可通过执行:gitlab-rake gitlab:env:info
root@gitlab-647f4bd8b4-qz2j9:/# gitlab-rake gitlab:env:info
System information
System:
Current User: git
Using RVM: no
Ruby Version: 2.7.5p203
Gem Version: 3.1.4
Bundler Version:2.1.4
Rake Version: 13.0.6
Redis Version: 6.0.16
Git Version: 2.33.1.
Sidekiq Version:6.3.1
Go Version: unknownGitLab information
Version: 14.6.1
Revision: 661d663ab2b
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 12.7
2.查看gitlab对应的gitl-runner版本
本项目中gitlab是14.6.1通过helm search repo -l gitlab/gitlab-runner 查看对应的gitlab-runner的heml包
3.下载helm包
# 添加 chart 存储库
helm repo add gitlab https://charts.gitlab.io# 查看存储库
helm repo list#获取gitlab-runner可用版本,注意和安装gitlab版本对应,我使用的版本是14.6.0
helm search repo -l gitlab/gitlab-runner
gitlab/gitlab-runner 0.36.0 14.6.0 GitLab Runner#下载helm 安装包
helm fetch gitlab/gitlab-runner --version=0.36.0
4.编辑values.yaml配置
gitlab令牌获取
菜单-->管理员-->runner
下面就是具体的修改的内容
#配置gitlab的地址和注册令牌
gitlabUrl: http://192.168.110.190:31944/runnerRegistrationToken: "gitlab的令牌"#docker的引用环境,reunner打包需要依赖docker环境,必须开通特权
runners:config: |[[runners]][runners.kubernetes]namespace = "{{.Release.Namespace}}"image = "ubuntu:16.04"privileged = true[[runners.kubernetes.volumes.host_path]]name = "docker"mount_path = "/var/run/docker.sock"#增加操作k8s的权限认证
rbac:create: true## Define specific rbac permissions.## DEPRECATED: see .Values.rbac.rulesresources: ["pods", "pods/exec", "secrets","configmaps","pods/attach"]verbs: ["get", "list", "watch", "create", "patch", "delete","update"]#gitlab-runner缓存配置,采用miniocache:cacheType: s3cachePath: "gitlab-runner"cacheShared: trues3ServerAddress: 192.168.110.190:30069s3BucketName: gitlab-caches3BucketLocation:s3CacheInsecure: falsesecretName: s3access
5.gitlab-runner中toml配置修改
三.部署gitlab-runner
安装在gitlab-runner同级别目录执行安装
helm install gitlab-runner --namespace=gitlab ./gitlab-runner
# 更新配置之后执行
helm upgrade gitlab-runner --namespace=gitlab ./gitlab-runner