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

相关推荐
容器魔方8 小时前
Volcano v1.12 正式发布!驱动云原生AI与批量计算向智能高效新阶段演进
云原生·容器·云计算
Johny_Zhao9 小时前
CentOS Stream 8 高可用 Kuboard 部署方案
linux·网络·python·网络安全·docker·信息安全·kubernetes·云计算·shell·yum源·系统运维·kuboard
在未来等你11 小时前
互联网大厂Java求职面试:云原生架构与微服务设计中的复杂挑战
java·微服务·ai·云原生·秒杀系统·rag·分布式系统
爱瑞瑞12 小时前
云原生学习笔记(八) Docker 实战:宿主机与容器的信息交互与共享策略
docker·容器
程序员老乔12 小时前
【Dify系列】【一】【安装与部署】【ubuntu22.04安装docker部署dify1.4.2】
运维·docker·容器
exe45216 小时前
使用docker中的ollama
运维·docker·容器
IT成长日记17 小时前
【Docker基础】Docker核心概念:命名空间(Namespace)之NET详解
运维·docker·容器·namespace·net
程序员小潘17 小时前
容器的本质是进程
容器
fdsafwagdagadg657617 小时前
本地部署n8n和MoneyPrintTuro实现一句话自动生成和上传youtube短视频
云原生·eureka
掘金-我是哪吒21 小时前
分布式微服务系统架构第145集:Jeskson文档-微服务分布式系统架构
分布式·微服务·云原生·架构·系统架构