Help us learn about your current experience with the documentation. Take the survey.
在 Google Cloud Compute Engine 中配置 Runner
- 层级:Free, Premium, Ultimate
- 提供方式:GitLab.com
你可以为 GitLab.com 创建项目或组级别的 Runner,并将其部署在你的 Google Cloud 项目中。 创建 Runner 时,GitLab UI 会提供屏幕说明和脚本,用于在 Google Cloud 项目中自动部署 Runner。
创建 Runner 时会为其分配一个认证令牌。GRIT Terraform 脚本使用此令牌来注册 Runner。Runner 在从作业队列获取作业时,会使用此令牌向 GitLab 进行身份验证。
部署后,一组自动扩展的 Runner 已准备好在 Google Cloud 中运行 CI/CD 作业。 Runner 管理器会自动创建临时 Runner。
前置条件:
- 对于组 Runner:组的 Owner 角色。
- 对于项目 Runner:项目的 Maintainer 角色。
- 对于你的 Google Cloud Platform 项目:Owner IAM 角色。
- Google Cloud Platform 项目已启用 计费。
- 一个已通过 Google Cloud 项目上的 IAM 角色进行身份验证的可用
gcloudCLI 工具。 - Terraform v1.5 或更高版本 和 Terraform CLI 工具。
- 一个安装了 Bash 的终端。
要在 Google Cloud 中创建组或项目 Runner 并进行部署:
-
在左侧边栏,选择 Search or go to 并找到你的组。
-
创建新的 Runner。
- 要创建新的组 Runner,选择 Build > Runners > New group runner。
- 要创建新的项目 Runner,选择 Settings > CI/CD > Runners > New project runner。
-
在 Tags 部分,Tags 字段中,输入作业标签以指定 Runner 可以运行的作业。 要让 Runner 同时处理带标签和不带标签的作业,选择 Run untagged。
-
可选。在 Configuration 部分,添加 Runner 描述和其他配置。
-
选择 Create runner。
-
在 Platform 部分,选择 Google Cloud。
-
在 Environment 中,输入以下 Google Cloud 环境详细信息:
- Google Cloud project ID
- Region
- Zone
- Machine type
-
在 Set up GitLab Runner 中,选择 Setup instructions。在对话框中:
- 要启用所需的服务、服务账号和权限,在 Configure Google Cloud project 中为每个 Google Cloud 项目运行一次 Bash 脚本。
- 使用 Install and register GitLab Runner 中的配置创建一个
main.tf文件。 该脚本使用 GitLab Runner Infrastructure Toolkit (GRIT) 在 Google Cloud 项目上部署基础设施来执行你的 Runner 管理器。
执行脚本后,Runner 管理器会使用 Runner 认证令牌进行连接。Runner 管理器可能需要最多一分钟才能显示为在线并开始接收作业。