注:以下操作都用helm3完成
配置chart 库
# 添加 chart 存储库
$ helm repo add gitlab https://charts.gitlab.io
# 查看存储库
$ helm repo list
NAME URL
gitlab https://charts.gitlab.io
安装gitlab-runner
查看可以安装的 gitlab-runner chart
$ helm search repo -l gitlab/gitlab-runner
NAME CHART VERSION APP VERSION DESCRIPTION
...
gitlab/gitlab-runner 0.34.0 14.4.0 GitLab Runner
gitlab/gitlab-runner 0.33.3 14.3.4 GitLab Runner
gitlab/gitlab-runner 0.33.2 14.3.3 GitLab Runner
gitlab/gitlab-runner 0.33.1 14.3.2 GitLab Runner
gitlab/gitlab-runner 0.33.0 14.3.0 GitLab Runner
gitlab/gitlab-runner 0.32.0 14.2.0 GitLab Runner
gitlab/gitlab-runner 0.31.0 14.1.0 GitLab Runner
gitlab/gitlab-runner 0.30.0 14.0.0 GitLab Runner
...
因为我的gitlab版本是14.2.3,所以我这里gitlab-runner版本选择0.32.0
获取对应版本的chat包
$ helm fetch gitlab/gitlab-runner --version=0.32.0
$ ls -l
-rw-r--r-- 1 root root 17568 Nov 17 10:25 gitlab-runner-0.32.0.tgz
$ tar xf gitlab-runner-0.32.0.tgz
$ cd gitlab-runner
$ ls
CHANGELOG.md Chart.yaml CONTRIBUTING.md LICENSE Makefile NOTICE README.md templates values.yaml
修改values.yaml 文件
image: #指定gitlab-runner镜像
imagePullPolicy: #镜像拉取策略
gitlabUrl: #gitlab地址
runnerRegistrationToken: #gitlab-runner注册用到的tocken
concurrent: #设置同行运行的runner个数
checkInterval: #定义检查gitlab新构建的频率
rbac: #角色设置
create: true
clusterWideAccess: true
metrics: #prometheus metrics数据暴露
enabled: true
runners: #runners配置
image:
imagePullSecrets:
imagePullPolicy:
locked: #是否设置为特定的runner
tags: #设置标签
privileged: true
secret:
namespace:
cache: {}
builds: #构建资源限制
cpuLimit: 200m
memoryLimit: 256Mi
cpuRequests: 100m
memoryRequests: 128Mi
services: {}
helpers: {}
serviceAccountName:
nodeSelector: #worker调度选择器
resources: {} #资源限制
affinity: {} #节点亲和性
nodeSelector: {} #节点调度选择器
tolerations: [] #污点容忍度
envVars: #环境变量设置
- name: RUNNER_EXECUTOR
value: kubernetes
我们只需修改以下几个就行
#以下两个在gitlab页面获取
gitlabUrl: #gitlab地址
runnerRegistrationToken: #gitlab-runner注册用到的tocken
concurrent: 10 #最大作业并发数
checkInterval: 30 #新作业检查间隔
tags: "k8s-runner" #runner的标签
#rbac权限打开
rbac:
create: true
## Define specific rbac permissions.
## DEPRECATED: see .Values.rbac.rules
resources: ["pods", "pods/exec", "secrets","configmaps"]
verbs: ["get", "list", "watch", "create", "patch", "delete","update"]
部署
#创建部署gitlab-runner的名称空间
$ kubectl create ns gitlab-runner
$ helm install gitlab-runner --namespace gitlab-runner ./gitlab-runner
NAME: gitlab-runner
LAST DEPLOYED: Fri Nov 17 11:16:28 2023
NAMESPACE: gitlab-runner
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Your GitLab Runner should now be registered against the GitLab instance reachable at: "https://gitlab.yundiketang.cn/"
Runner namespace "gitlab-runner" was found in runners.config template.
查看pod已经启动成功
$ kubectl get deploy,svc,po -n gitlab-runner |grep gitlab-runner
deployment.apps/gitlab-runner-gitlab-runner 1/1 1 1 45s
pod/gitlab-runner-gitlab-runner-b75486b98-trgxg 1/1 Running 0 45s
查看gitlab页面也有了我们部署的runner
image.png如果values.yaml更新,只需执行以下命令
helm upgrade gitlab-runner --namespace gitlab-runner ./gitlab-runner
网友评论