kubernetes基于helm部署gitlab-runner

kubernetes基于helm部署gitlab-runner

这篇博文介绍如何在 Kubernetes 中使用helm部署 GitLab-runner。

先决条件:

  • 已运行的 Kubernetes 集群
  • 已运行的 gitlab 实例

项目地址:https://gitlab.com/gitlab-org/charts/gitlab-runner

官方文档:https://docs.gitlab.com/runner/install/kubernetes.html

创建gitlab-runner实例

1、登陆UI创建新的runner

选择Your work--> Admin Area

2、选择CI/CD-->Runners--> New instance runner

3、配置runner信息

4、点击Create runner

5、获取runner token

前置配置

说明:gitlab实例使用自签名证书并且使用本地域名时,需执行以下配置。

1、配置gitlab url在pod中的域名解析

gitlab-runner pod启用时需要从pod内部使用 gitlab 外部域名https://gitlab.example.com注册到gitlab,修改coredns配置,提供本地域名解析。

yaml 复制代码
root@ubuntu:~# kubectl -n kube-system edit cm coredns
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        hosts {
            192.168.72.210 gitlab.example.com
            fallthrough
        }
        ......
    }

重启coredns pods

bash 复制代码
kubectl -n kube-system rollout restart deployment.apps/coredns

2、导出gitlab自签名证书

bash 复制代码
kubectl -n gitlab get secret gitlab-gitlab-tls --template='{{ index .data "tls.crt" }}' | base64 -d > gitlab.crt

3、基于自签名证书创建secrets

bash 复制代码
kubectl create ns gitlab-runner
kubectl -n gitlab-runner create secret generic gitlab-runner-certs \
  --from-file=gitlab.example.com.crt=gitlab.crt \
  --from-file=registry.example.com.crt=gitlab.crt \
  --from-file=minio.example.com.crt=gitlab.crt

部署gitlab-runner

添加gitlab helm 仓库

basg 复制代码
helm repo add gitlab https://charts.gitlab.io

使用helm部署gitlab-runner

bash 复制代码
helm install gitlab-runner \
  --namespace=gitlab-runner \
  --create-namespace \
  --set gitlabUrl=https://gitlab.example.com \
  --set runnerToken=glrt-p3LfPnBwy6pdVjnj1Mmx \
  --set certsSecretName=gitlab-runner-certs \
  --set rbac.create=true \
  --set rbac.clusterWideAccess=true \
  gitlab/gitlab-runner

查看运行的gitlab-runner pods

bash 复制代码
root@ubuntu:~# kubectl -n gitlab-runner get pods 
NAME                             READY   STATUS    RESTARTS   AGE
gitlab-runner-5db97476f9-2mnsz   1/1     Running   0          3h30m

登陆UI确认runner注册成功

相关推荐
打工仔折腾 AI2 小时前
Changedetection.io 网页变动监控:Docker 部署、通知配置与公网暴露实践
运维·人工智能·后端·python·docker·容器·性能优化
fengkai45452 小时前
Prometheus+K8s弹性伸缩综合项目
运维·kubernetes·k8s·prometheus·hpa·vpa
分布式存储与RustFS4 小时前
镜像仓库的层别只堆本地盘:用 RustFS 给 Harbor 当 S3 后端
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
分布式存储与RustFS6 小时前
工作流脚本和依赖 JAR 散在各节点本地盘:用 DolphinScheduler 资源中心接到 RustFS
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
Eyfcom7 小时前
〖物流云原生实战 01〗K8s Operator 在物流定时任务中的实践:从“裸 CronJob”到“声明式任务编排”
云原生·物流管理系统·物流云原生实战
阿里云云原生20 小时前
阿里云智能体白皮书开源进展
云原生
阿里云云原生21 小时前
万联智策基于 AgentCore 构建数字员工团队,800+智能体规模化落地
云原生
分布式存储与RustFS1 天前
群晖 NAS 被 C3RB3R 锁了:本地备份一起被加密,RustFS 对象锁为什么删不掉
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
东风微鸣1 天前
把 DeepSeek Harness 装进 K8s
kubernetes·deepseek·harness
江华森1 天前
4 台华为云 ECS 从零到一:我用 AI Agent 搭了一套 K3s 多节点集群,全自动、免运维、翻车实录
云原生