注:以下操作都用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
獲取對應(yīng)版本的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: #設(shè)置同行運行的runner個數(shù)
checkInterval: #定義檢查gitlab新構(gòu)建的頻率
rbac: #角色設(shè)置
create: true
clusterWideAccess: true
metrics: #prometheus metrics數(shù)據(jù)暴露
enabled: true
runners: #runners配置
image:
imagePullSecrets:
imagePullPolicy:
locked: #是否設(shè)置為特定的runner
tags: #設(shè)置標(biāo)簽
privileged: true
secret:
namespace:
cache: {}
builds: #構(gòu)建資源限制
cpuLimit: 200m
memoryLimit: 256Mi
cpuRequests: 100m
memoryRequests: 128Mi
services: {}
helpers: {}
serviceAccountName:
nodeSelector: #worker調(diào)度選擇器
resources: {} #資源限制
affinity: {} #節(jié)點親和性
nodeSelector: {} #節(jié)點調(diào)度選擇器
tolerations: [] #污點容忍度
envVars: #環(huán)境變量設(shè)置
- name: RUNNER_EXECUTOR
value: kubernetes
我們只需修改以下幾個就行
#以下兩個在gitlab頁面獲取
gitlabUrl: #gitlab地址
runnerRegistrationToken: #gitlab-runner注冊用到的tocken
concurrent: 10 #最大作業(yè)并發(fā)數(shù)
checkInterval: 30 #新作業(yè)檢查間隔
tags: "k8s-runner" #runner的標(biāo)簽
#rbac權(quán)限打開
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"]
部署
#創(chuàng)建部署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已經(jīng)啟動成功
$ 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
如果values.yaml更新烂完,只需執(zhí)行以下命令
helm upgrade gitlab-runner --namespace gitlab-runner ./gitlab-runner