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注册成功

相关推荐
Sheffield3 小时前
Alpine是什么,为什么是Docker首选?
linux·docker·容器
阿里云云原生19 小时前
零配置部署顶级模型!函数计算一键解锁 Qwen3.5
云原生
AI攻城狮1 天前
Kimi Bot + OpenClaw 完整配置指南:5 步实现本地 AI Agent 集成
人工智能·云原生·aigc
AI攻城狮2 天前
RAG Chunking 为什么这么难?5 大挑战 + 最佳实践指南
人工智能·云原生·aigc
可观测性用观测云3 天前
云原生网关 Ingress-Nginx 链路追踪实战:OpenTelemetry 采集与观测云集成方案
nginx·kubernetes
哈里谢顿4 天前
Kubernetes Operator核心概念、实现原理和实战开发
云原生
阿里云云原生4 天前
你的 OpenClaw 真的在受控运行吗?
云原生
阿里云云原生4 天前
5 分钟零代码改造,让 Go 应用自动获得全链路可观测能力
云原生·go
Shanyoufusu124 天前
RKE2 单节点集群安装 Rancher+ 私有镜像仓库搭建 完整教程
云原生
阿里云云原生4 天前
Dify 官方上架 Higress 插件,轻松接入 AI 网关访问模型服务
云原生