返回提示词目录第 1323 页

设计自托管 CI 运行器架构

结合团队需求规划自托管运行器的平台、隔离、网络、扩缩容与成本,并提供配置示例和分阶段上线方案。

完整提示词

<context>
Self-hosted runners pay off for heavy, frequent builds, special hardware or access to private networks, but they move security and upkeep onto the team. The serious risk is persistence: a long-lived runner that executes pull request code can be backdoored by one job and then steal secrets from the next. That is why runners should be ephemeral (one job, then destroyed) and why self-hosted runners on public repositories are dangerous. Other usual failures: runner images drift from the hosted ones so builds break mysteriously, caches vanish with ephemeral machines unless an external cache is set up, idle capacity costs more than hosted minutes would have, and runners in a private network get broad access they do not need. Standard autoscalers exist: Actions Runner Controller on Kubernetes or autoscaling groups for GitHub Actions, and GitLab Runner with the Kubernetes or docker-autoscaler executors.
</context>

<task>
Design self-hosted CI runners for:
<needs>
{{needs}}
</needs>
{{#constraints}}
Constraints: {{constraints}}
{{/constraints}}

1. If job volume, CI provider or where the runners must run is unknown, ask and stop. Check first whether larger hosted runners or hosted GPU runners would meet the need, and compare rough monthly costs with assumptions shown.
2. Choose the platform (Kubernetes with the provider's controller, or VM autoscaling) and the scope (organisation, group or repository runner registration).
3. Make runners ephemeral: one job per runner, fresh from an image, auto-registered with short-lived registration tokens or a GitHub App, never a personal token.
4. Define runner groups and labels by trust level and hardware (for example `linux-x64-large`, `gpu`), and restrict which repositories and workflows can use privileged groups.
5. Network: egress limited to what builds need, no inbound access, separate subnets from production, and cloud identity per runner group with least privilege.
6. Build environment: a versioned runner image with the toolchains jobs need, rebuilt on a schedule; external caches (object storage or a registry cache) because local disks are discarded.
7. Autoscaling and cost: minimum warm runners, scale-down delay, maximum count, spot or preemptible capacity for jobs that tolerate it, and a budget alert.
8. Write example configuration for the chosen controller or autoscaler and the workflow changes (`runs-on` labels or tags).
9. Plan the rollout: one low-risk repository first, a metric to compare queue time and duration, then expand.
</task>

<constraints>
- Never recommend persistent self-hosted runners for public repositories or for untrusted pull request code.
- Do not invent controller settings or chart values; mark anything you are unsure of.
- Cost figures are estimates; show the assumptions and tell the reader to check current pricing.
- Never suggest Docker socket mounting or privileged containers without stating the isolation risk and an alternative such as rootless builds or VM isolation.
</constraints>

<output_format>
## Recommendation
Self-hosted or hosted, platform and why, in a short paragraph.

## Architecture
Runner groups, labels, network placement, identity and caches.

## Config
Example controller or autoscaler configuration and workflow changes, with paths.

## Security
A checklist of the isolation controls and who may use each runner group.

## Costs
A table: hosted versus self-hosted estimate with assumptions.

## Rollout
Pilot, metrics and expansion steps, plus image maintenance cadence.
</output_format>

可替换内容

  • {{needs}}
  • {{#constraints}}
  • {{constraints}}
  • {{/constraints}}

分类与标签

编程开发、DevOps、CI运行器、基础设施规划

前往 AI 图片创作