3d5bac66b4
IaC 面 (infra/) 与控制面 (server/internal/provision) 双产出,落地 doc/04 §4 「节点是牲口」弹性拓扑与 make-before-break 一键更换。 server/internal/provision: - CloudAdapter 适配层 + Registry(首发 vultr 消耗品池 / hetzner 精品池各一); 厂商凭证仅从 PROVISION_<VENDOR>_* env 注入,不入库不入 git。 - ProvisionService:CreateNode(幂等键重放不重复开机)、DestroyNode(幂等)、 RotateIP(换 IP 不换机 + version bump)、ListProviders。 - Replace 一键更换:先建后拆,新机 up 先于旧机 draining(容量不下降), replacement_uuid 幂等键 + replacements 表分步记录,崩溃可续跑不重复。 - RotatePool:池内滚动轮换,并发度 1–2。 - cmd/nodectl CLI:create/destroy/rotate-ip/replace/rotate-pool/providers。 - 单测(mock 厂商 API + 内存 Store):幂等重放、make-before-break 时序断言、 开机失败/探活超时→destroyed+失败计数+告警钩子、崩溃续跑、RotatePool。 infra/: - terraform/:探针机 + 控制面基线模块化(probe / control-plane)+ README, 低频基线进 state,节点不进 Terraform。 - cloud-init/node.yaml.tmpl:节点引导模板(注入一次性 bootstrap token,task #5)。 - identity-isolation.md:身份隔离登记表(doc/06 §2 红线,无任何凭证)。 migrations/000008:nodes 增 provider_instance_id/elastic_ip_id、node_events 增 ip_rotated、provision_idempotency / replacements 表(附加式,不动现网)。 红线:仅面向新厂商池,绝不纳管现网生产 EC2(deploy/ marzban)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.3 KiB
Terraform
43 lines
1.3 KiB
Terraform
provider "hcloud" {
|
|
token = var.hcloud_token
|
|
}
|
|
|
|
# SSH keys for the management identity (probe + control-plane access).
|
|
resource "hcloud_ssh_key" "mgmt" {
|
|
for_each = { for idx, key in var.ssh_public_keys : idx => key }
|
|
name = "pangolin-mgmt-${each.key}"
|
|
public_key = each.value
|
|
}
|
|
|
|
locals {
|
|
ssh_key_ids = [for k in hcloud_ssh_key.mgmt : k.id]
|
|
}
|
|
|
|
# Overseas reference probe points (low frequency → Terraform-managed).
|
|
# 境内 probe points are serverless / third-party dialing services with strict
|
|
# identity isolation and are intentionally OUT of Terraform scope (registered in
|
|
# ../identity-isolation.md).
|
|
module "probe" {
|
|
source = "./modules/probe"
|
|
for_each = var.probe_overseas
|
|
|
|
name = each.key
|
|
location = each.value.location
|
|
server_type = each.value.server_type
|
|
image = var.probe_image
|
|
ssh_key_ids = local.ssh_key_ids
|
|
}
|
|
|
|
# Control-plane baseline env (API + MySQL + Redis), provisioned once and rarely
|
|
# changed. Disabled by default; flip control_plane_enabled to manage it here.
|
|
module "control_plane" {
|
|
source = "./modules/control-plane"
|
|
count = var.control_plane_enabled ? 1 : 0
|
|
|
|
server_type = var.control_plane_server_type
|
|
location = var.control_plane_location
|
|
image = var.probe_image
|
|
ssh_key_ids = local.ssh_key_ids
|
|
allowlist_cidrs = var.admin_allowlist_cidrs
|
|
}
|