UCloud 一方节点部署:UHost 1C8G 按小时(0.3-0.5 元/时)+ k3s(rancher-mirror
源,避免 get.k3s.io 超时)+ UHub 私有镜像仓库(ssww/ssw-tdc:local、
ssw-nax:local),参与方在云端跟本地 OrbStack k8s 用同一套镜像。
新增资产:
- deploy/ucloud-uhost/lifecycle.py: UCloudAPI + K8sEnv,uhost 子命令
(create/setup-k3s/build/push/up/smoke/stop/start/destroy)
- deploy/ucloud-uhost/setup-uhost.sh: k3s 单节点 control-plane 安装
- deploy/ucloud-uhost/smoke-tdc.sh: 7 步 lite-TDC 烟测
- deploy/k8s/{nax,tdc}-deploy.yaml: k3s 部署清单(lite-TDC + connector +
easytier sidecar;nax HTTP 算子 Pod)
- deploy/k8s/ssw-tdc-pg-pvc.yaml: hostPath PV 5Gi for PG 数据持久化
(/var/lib/ssw-tdc/pgdata)
- deploy/docs/UCloud_UHost_部署指南.md: 完整部署文档(凭证、API 坑、
k3s 步骤、UHub 凭证、持久化)
scard 安全平面:
- connector-linux-amd64 (8.5MB -> 10.1MB): 重新编译(GOOS=linux
GOARCH=amd64 CGO_ENABLED=0),曾被误标为 macOS Mach-O 导致 UCloud 启动失败
- connector-linux-arm64 (9.4MB): 新增 ARM 架构
docs/TDC_LITE_拆分打包说明.md: 新增 §9 k8s 原生双镜像部署(OrbStack/UCloud
通用清单)
804 lines
37 KiB
Python
804 lines
37 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
SSW 参与方节点生命周期管理(k8s 原生,provider 无关).
|
|
|
|
部署形态:双镜像 + k8s Pod(不走裸 VM,统一 k8s 调度)
|
|
- ssw-tdc 镜像 : connector(lite-TDC 的 sidecar) + lite-TDC(entrypoint 用 MODE 切换)
|
|
- ssw-nax 镜像 : nax 隐私计算引擎(server.py 暴露 /run 秘密分享算子)
|
|
|
|
三套环境共用同一套清单(deploy/k8s/*.yaml),只差两点:
|
|
- 本地 OrbStack k8s : --context orbstack
|
|
镜像走 OrbStack docker/k8s 共享仓库(imagePullPolicy: Never,免 registry)
|
|
- 云端 UCloud UK8s : kubeconfig 来自 UK8s(GetClusterConfig / 控制台下载)
|
|
镜像推到 UHub 容器 registry(imagePullPolicy: IfNotPresent + imagePullSecrets)
|
|
- 云端 UHost + k3s : 建 1C8G UHost -> ssh 装 k3s -> 推 UHub -> kubectl apply
|
|
|
|
> UCloud API 鉴权:PublicKey + PrivateKey + SHA1 签名(见 UCloudAPI._sign,已含官方自测向量).
|
|
|
|
用法:
|
|
python lifecycle.py selftest # 仅验证签名算法(离线,不碰网络/密钥)
|
|
python lifecycle.py orbstack up # 本地 k8s apply
|
|
python lifecycle.py orbstack down
|
|
python lifecycle.py orbstack smoke # IPv4 端口转发 + 三件套冒烟
|
|
python lifecycle.py ucloud up # 取/建 UK8s kubeconfig + 推 UHub + apply
|
|
python lifecycle.py ucloud down # 删 UK8s 部署(不动集群;--destroy 才删集群)
|
|
python lifecycle.py ucloud smoke
|
|
python lifecycle.py uhost create # 建 1C8G UHost + EIP
|
|
python lifecycle.py uhost setup-k3s # ssh 远程装 k3s + 配 registry mirror + UHub 凭据
|
|
python lifecycle.py uhost build # 构建 ssw-tdc/ssw-nax 本地镜像
|
|
python lifecycle.py uhost push # 推到 UHub
|
|
python lifecycle.py uhost up # apply tdc(含 connector sidecar) + nax + 持久化 PVC
|
|
python lifecycle.py uhost smoke # 端到端冒烟(依赖 kubectl port-forward)
|
|
python lifecycle.py uhost stop / start / destroy # UHost 生命周期
|
|
|
|
环境变量(ucloud/uhost 通用,均不写死在文件里):
|
|
UCLOUD_PUBLIC_KEY API 公钥
|
|
UCLOUD_PRIVATE_KEY API 私钥(签名必需)
|
|
UCLOUD_REGION e.g. cn-gd(默认从 UCLOUD_ZONE='广州' 解析)
|
|
UCLOUD_ZONE 中文城市名('广州')或区域码
|
|
UCLOUD_UHUB_PREFIX UHub 前缀,如 uhub.service.ucloud.cn/ssww
|
|
UCLOUD_UHUB_USERNAME UHub 登录用户名(邮箱)
|
|
UCLOUD_UHUB_PASSWORD UHub registry 密码(与 API key 无关)
|
|
UCLOUD_UHOST_ID 已有 UHost ID(留空则需先 create)
|
|
UCLOUD_EIP EIP 地址(外部已知),用于 ssh/scp
|
|
UCLOUD_SSH_PASSWORD ssh 密码(默认按 EIP 字符串)
|
|
KUBECONFIG 若已有 kubeconfig,直接用它
|
|
DEPLOY_DIR deploy 根目录(默认 = DEPLOY_DIR 环境变量或脚本所在目录)
|
|
"""
|
|
|
|
# Env vars (ucloud/uhost, all from env, never hardcoded):
|
|
# UCLOUD_PUBLIC_KEY API 公钥
|
|
# UCLOUD_PRIVATE_KEY API 私钥(签名必需)
|
|
# UCLOUD_REGION e.g. cn-gd(默认从 UCLOUD_ZONE='广州' 解析)
|
|
# UCLOUD_ZONE 中文城市名('广州')或区域码
|
|
# UCLOUD_UHUB_PREFIX UHub 前缀,如 uhub.service.ucloud.cn/ssww
|
|
# UCLOUD_UHUB_USERNAME UHub 登录用户名(邮箱)
|
|
# UCLOUD_UHUB_PASSWORD UHub registry 密码(与 API key 无关)
|
|
# UCLOUD_UHOST_ID 已有 UHost ID(留空则需先 create)
|
|
# UCLOUD_EIP EIP 地址(外部已知),用于 ssh/scp
|
|
# UCLOUD_SSH_PASSWORD ssh 密码(默认按 EIP 字符串)
|
|
# KUBECONFIG 若已有 kubeconfig,直接用它
|
|
# DEPLOY_DIR deploy 根目录(默认 = DEPLOY_DIR 环境变量或脚本所在目录)
|
|
import argparse
|
|
import base64
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from collections import OrderedDict
|
|
|
|
# deploy/ 根目录(脚本所在目录的父级,即 deploy/)
|
|
_DEPLOY_DIR = os.environ.get("DEPLOY_DIR") or os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
K8S_DIR = os.path.join(_DEPLOY_DIR, "k8s")
|
|
MIRRORS_DIR = os.path.join(_DEPLOY_DIR, "mirrors")
|
|
MANIFESTS = ["tdc-deploy.yaml", "nax-deploy.yaml", "ssw-tdc-pg-pvc.yaml"]
|
|
LOCAL_IMAGES = ["ssw-tdc:local", "ssw-nax:local"]
|
|
UHUB_PREFIX = os.environ.get("UCLOUD_UHUB_PREFIX", "")
|
|
|
|
# 中文城市名 -> (Region, 默认 Zone)
|
|
CITY_REGION = {
|
|
"北京": ("cn-bj2", "cn-bj2-02"),
|
|
"上海": ("cn-sh2", "cn-sh2-02"),
|
|
"广州": ("cn-gd", "cn-gd-02"),
|
|
"成都": ("cn-cd", "cn-cd2"),
|
|
"香港": ("hk", "hk-02"),
|
|
"东京": ("tokyo", "tokyo-01"),
|
|
"新加坡": ("sg", "sg-02"),
|
|
}
|
|
|
|
|
|
def resolve_region_zone():
|
|
"""解析 UCLOUD_REGION / UCLOUD_ZONE(支持中文城市名)为 ucloud 区域码."""
|
|
zone = os.environ.get("UCLOUD_ZONE", "")
|
|
region = os.environ.get("UCLOUD_REGION", "")
|
|
if zone in CITY_REGION:
|
|
r, z = CITY_REGION[zone]
|
|
return (region or r), z
|
|
if not region and zone and zone.startswith("cn-"):
|
|
region = "-".join(zone.split("-")[:2]) # cn-gz2 -> cn-gz
|
|
return region, zone
|
|
|
|
|
|
# =========================================================================== UCloud API
|
|
class UCloudAPI:
|
|
"""UCloud OpenAPI 客户端(仅依赖标准库).
|
|
|
|
签名算法(与官方 ucloud-sdk-python3 一致,已用官方向量自测):
|
|
1) 参数按 key 升序排列
|
|
2) 拼接为 keyvalue keyvalue...(无 = 无 &)
|
|
3) 末尾追加 PrivateKey
|
|
4) SHA1 十六进制
|
|
所有请求 POST 到 https://api.ucloud.cn/ ,form-urlencoded.
|
|
"""
|
|
|
|
ENDPOINT = "https://api.ucloud.cn/"
|
|
|
|
def __init__(self, public_key=None, private_key=None, region=None, project_id=None):
|
|
self.public_key = public_key or os.environ.get("UCLOUD_PUBLIC_KEY", "")
|
|
self.private_key = private_key or os.environ.get("UCLOUD_PRIVATE_KEY", "")
|
|
r, z = resolve_region_zone()
|
|
self.region = region or r
|
|
self.zone = z
|
|
self.project_id = project_id or os.environ.get("UCLOUD_PROJECT_ID", "")
|
|
if not self.public_key:
|
|
raise SystemExit("[fatal] UCLOUD_PUBLIC_KEY 未设置")
|
|
if not self.private_key:
|
|
raise SystemExit("[fatal] UCLOUD_PRIVATE_KEY 未设置(签名必需)")
|
|
|
|
# ---- 签名 ----------------------------------------------------------
|
|
@staticmethod
|
|
def _sign(private_key: str, params: dict) -> str:
|
|
params = OrderedDict(sorted(params.items(), key=lambda kv: kv[0]))
|
|
s = ""
|
|
for k, v in params.items():
|
|
s += str(k) + str(v)
|
|
s += private_key
|
|
return hashlib.sha1(s.encode("utf-8")).hexdigest()
|
|
|
|
@staticmethod
|
|
def selftest():
|
|
"""对照 UCloud 官方签名向量验证算法正确性."""
|
|
pk = "[email protected]"
|
|
sk = "46f09bb9fab4f12dfc160dae12273d5332b5debe"
|
|
params = {"Action": "DescribeUHostInstance", "Region": "cn-bj2",
|
|
"Limit": 10, "PublicKey": pk}
|
|
got = UCloudAPI._sign(sk, params)
|
|
exp = "cba5cf5ec4d4233d206b1b54951e3787350a642f"
|
|
ok = got == exp
|
|
print(f"[selftest] 签名算法: {'PASS' if ok else 'FAIL'}")
|
|
print(f" 期望 {exp}")
|
|
print(f" 得到 {got}")
|
|
return ok
|
|
|
|
# ---- 通用调用 ------------------------------------------------------
|
|
def call(self, action: str, **params) -> dict:
|
|
body = {
|
|
"Action": action,
|
|
"PublicKey": self.public_key,
|
|
"Region": self.region,
|
|
}
|
|
if self.project_id:
|
|
body["ProjectId"] = self.project_id
|
|
body.update(params)
|
|
body["Signature"] = self._sign(self.private_key, body)
|
|
r = subprocess.run(
|
|
["curl", "-sS", "-m", "30", "-X", "POST", self.ENDPOINT,
|
|
"-H", "Content-Type: application/x-www-form-urlencoded",
|
|
"--data", "&".join(f"{k}={v}" for k, v in body.items())],
|
|
capture_output=True, text=True, check=True)
|
|
try:
|
|
data = json.loads(r.stdout)
|
|
except json.JSONDecodeError:
|
|
raise RuntimeError(f"UCloud 返回非 JSON: {r.stdout[:300]}")
|
|
if data.get("RetCode", 0) != 0:
|
|
raise RuntimeError(f"UCloud {action} 失败: {data.get('Message')} | {data}")
|
|
return data
|
|
|
|
# ---- 集群操作 ------------------------------------------------------
|
|
def list_clusters(self) -> list:
|
|
d = self.call("ListUK8SClusterV2", Limit=50, Offset=0)
|
|
return d.get("ClusterSet", []) or []
|
|
|
|
def validate(self):
|
|
"""只读连通性校验:验证 key 可用性 + 探查现有资源,不创建任何计费资源."""
|
|
print("=== [validate] 只读连通性校验(不创建任何资源)===")
|
|
print(f" PublicKey={self.public_key[:6]}... Region={self.region} Zone={self.zone}")
|
|
# 1) 鉴权:GetProjectList(必带 Region,可验证签名 + Region 正确性)
|
|
try:
|
|
projects = self.call("GetProjectList", Limit=50, Offset=0)
|
|
pset = projects.get("ProjectSet", []) or []
|
|
print(f"[ok] 鉴权通过;项目数={len(pset)}")
|
|
for p in pset:
|
|
print(f" ProjectId={p.get('ProjectId')} Name={p.get('ProjectName')}")
|
|
pid = self.project_id or (pset[0]["ProjectId"] if pset else "")
|
|
except Exception as e:
|
|
print(f"[FAIL] 鉴权失败 / GetProjectList 报错: {e}")
|
|
return False
|
|
# 2) VPC / 子网(建集群时需自动探查)
|
|
if pid:
|
|
try:
|
|
vpc = os.environ.get("UCLOUD_VPC_ID") or self._first("DescribeVPC", "DataSet", "VPCId", ProjectId=pid)
|
|
print(f"[ok] VPC={vpc}")
|
|
subnet = (os.environ.get("UCLOUD_SUBNET_ID")
|
|
or self._first("DescribeSubnet", "DataSet", "SubnetId", VPCId=vpc, ProjectId=pid))
|
|
print(f"[ok] Subnet={subnet}")
|
|
except Exception as e:
|
|
print(f"[warn] 取 VPC/子网失败(建集群前需手动设 UCLOUD_VPC_ID/SUBNET_ID): {e}")
|
|
# 3) 现有 UK8S 集群
|
|
try:
|
|
clusters = self.list_clusters()
|
|
print(f"[ok] 现有 UK8S 集群数={len(clusters)}")
|
|
for c in clusters:
|
|
print(f" {c.get('ClusterId')} {c.get('ClusterName')} State={c.get('State')}")
|
|
except Exception as e:
|
|
print(f"[warn] 列集群失败: {e}")
|
|
return True
|
|
|
|
def get_config(self, cluster_id: str) -> str:
|
|
"""返回 kubeconfig 文本(优先 ExternalKubeConfig,否则 KubeConfig)."""
|
|
d = self.call("GetClusterConfig", ClusterId=cluster_id)
|
|
cfg = d.get("ExternalKubeConfig") or d.get("KubeConfig")
|
|
if not cfg:
|
|
raise RuntimeError("GetClusterConfig 未返回 kubeconfig")
|
|
return cfg
|
|
|
|
def create_cluster(self, name="ssw-flow", cpu=2, mem=4096, node_count=1, master_count=3) -> str:
|
|
"""建一个最小集群(3 master + N node,按小时 Dynamic),返回 ClusterId.
|
|
需要:Region + Password;ProjectId/VPCId/SubnetId 缺省时自动探查第一个可用值.
|
|
注意:ucloud 要求 Master 必须 3 节点,CPU>=2,Mem>=4096MB(min 标准套餐)."""
|
|
import secrets, string
|
|
pwd = os.environ.get("UCLOUD_CLUSTER_PASSWORD")
|
|
if not pwd:
|
|
# 自动生成:必须含 ≥1 大写字母(ucloud 节点密码策略)
|
|
pwd = "Ssw" + "".join(secrets.choice(string.ascii_letters + string.digits) for _ in range(13))
|
|
print(f"[ucloud] UCLOUD_CLUSTER_PASSWORD 未设,自动生成节点密码: {pwd}")
|
|
# 自动探查 ProjectId / VPCId / SubnetId / K8sVersion(缺失时取第一个可用)
|
|
project_id = self.project_id or self._first("GetProjectList", "ProjectSet", "ProjectId")
|
|
vpc = os.environ.get("UCLOUD_VPC_ID") or self._first("DescribeVPC", "DataSet", "VPCId", ProjectId=project_id)
|
|
subnet = (os.environ.get("UCLOUD_SUBNET_ID")
|
|
or self._first("DescribeSubnet", "DataSet", "SubnetId", VPCId=vpc, ProjectId=project_id))
|
|
if os.environ.get("UCLOUD_K8S_VERSION"):
|
|
k8s_version = os.environ["UCLOUD_K8S_VERSION"]
|
|
else:
|
|
ver_data = self.call("GetUK8SVersions", Kind="Dedicated").get("Data") or []
|
|
if not ver_data:
|
|
raise SystemExit("[fatal] GetUK8SVersions 返回空,无法确定 K8sVersion")
|
|
k8s_version = ver_data[0]["K8sVersion"]
|
|
print(f"[ucloud] 自动选 K8sVersion={k8s_version}(共 {len(ver_data)} 个可用版本)")
|
|
print(f"[ucloud] 建集群参数: Region={self.region} Zone={self.zone} Project={project_id} VPC={vpc} Subnet={subnet}")
|
|
password_b64 = base64.b64encode(pwd.encode()).decode()
|
|
zone = self.zone # 可选;不传由 ucloud 选
|
|
params = {
|
|
"ClusterName": name,
|
|
"ProjectId": project_id,
|
|
"VPCId": vpc, "SubnetId": subnet,
|
|
"ServiceCIDR": "172.17.0.0/16",
|
|
"Password": password_b64,
|
|
"ChargeType": "Dynamic", # 按小时,契合「动态申请」
|
|
"K8sVersion": k8s_version,
|
|
"MasterMachineType": "N",
|
|
"MasterCPU": 2, "MasterMem": 4096,
|
|
"MasterBootDiskType": "CLOUD_SSD",
|
|
"MasterDataDiskType": "CLOUD_SSD",
|
|
"KubeProxy.Mode": "iptables",
|
|
"ExternalApiServer": "Yes", # 允许外网 apiserver,方便本地 kubectl
|
|
}
|
|
# Master 必须 3 个(ucloud 多可用区高可用),每个 master 一个 zone(这里用同一 zone)
|
|
for i in range(3):
|
|
params[f"Master.{i}.Zone"] = zone
|
|
# Node 组
|
|
params.update({
|
|
f"Nodes.0.Zone": zone,
|
|
f"Nodes.0.MachineType": "N",
|
|
f"Nodes.0.CPU": cpu, f"Nodes.0.Mem": mem,
|
|
f"Nodes.0.Count": node_count,
|
|
f"Nodes.0.BootDiskType": "CLOUD_SSD",
|
|
})
|
|
d = self.call("CreateUK8SClusterV2", **params)
|
|
return d["ClusterId"]
|
|
|
|
def _first(self, action: str, set_key: str, id_key: str, **extra) -> str:
|
|
"""调一个 List/Get 类接口,从返回数组里取第一个元素的 id_key."""
|
|
d = self.call(action, Limit=50, Offset=0, **extra)
|
|
arr = d.get(set_key) or d.get("DataSet") or []
|
|
if not arr:
|
|
raise RuntimeError(f"{action} 返回空 {set_key},无法自动探查(请手动设对应 env)")
|
|
return arr[0][id_key]
|
|
|
|
def delete_cluster(self, cluster_id: str):
|
|
self.call("DelUK8SCluster", ClusterId=cluster_id)
|
|
|
|
|
|
# =========================================================================== UHub(镜像仓库)
|
|
def uhub_login():
|
|
user = os.environ.get("UCLOUD_UHUB_USERNAME")
|
|
pwd = os.environ.get("UCLOUD_UHUB_PASSWORD")
|
|
if not (user and pwd):
|
|
print("[warn] UCLOUD_UHUB_USERNAME/PASSWORD 未设,跳过 docker login(push 会失败)")
|
|
return
|
|
print(f"[uhub] docker login uhub.service.ucloud.cn ({user})")
|
|
# 直接调 docker CLI 登录(之前用 curl /v2/ 探测会假性失败,UCloud 那个端点需要 Accept 头)
|
|
# 用 --password-stdin 避免密码被 ps 看到
|
|
import subprocess as _sp
|
|
r = _sp.run(
|
|
["docker", "login", "uhub.service.ucloud.cn", "-u", user, "--password-stdin"],
|
|
input=pwd + "\n", capture_output=True, text=True)
|
|
if r.returncode != 0:
|
|
raise RuntimeError(f"UHub docker login 失败:\n{r.stderr or r.stdout}")
|
|
print("[uhub] Login Succeeded")
|
|
# 把同份凭据写到 DOCKER_CONFIG 隔离目录(确保 push 时用这份,不是 docker desktop 锁住的那份)
|
|
import json as _json, base64 as _b64
|
|
auth = _b64.b64encode(f"{user}:{pwd}".encode()).decode()
|
|
cfg_dir = "/tmp/uhub-docker-cfg"
|
|
os.makedirs(cfg_dir, exist_ok=True)
|
|
cfg_path = f"{cfg_dir}/config.json"
|
|
with open(cfg_path, "w") as f:
|
|
_json.dump({"auths": {"uhub.service.ucloud.cn": {"auth": auth}}}, f)
|
|
print(f"[uhub] 凭据备份到 {cfg_path}(push 用 DOCKER_CONFIG={cfg_dir})")
|
|
|
|
|
|
def push_to_uhub():
|
|
if not UHUB_PREFIX:
|
|
print("[warn] UCLOUD_UHUB_PREFIX 未设,跳过 push")
|
|
return
|
|
env = os.environ.copy()
|
|
env["DOCKER_CONFIG"] = "/tmp/uhub-docker-cfg" # 用隔离的 config(已写好 UHub auth)
|
|
for img in LOCAL_IMAGES:
|
|
remote = f"{UHUB_PREFIX}/{img}"
|
|
print(f"[push] {img} -> {remote}")
|
|
subprocess.run(["docker", "tag", img, remote], check=True, env=env)
|
|
subprocess.run(["docker", "push", remote], check=True, env=env)
|
|
|
|
|
|
# =========================================================================== k8s 环境
|
|
class K8sEnv:
|
|
def __init__(self, context=None, kubeconfig=None, registry_prefix=None, pull_policy="Never"):
|
|
self.context = context
|
|
self.kubeconfig = kubeconfig # 文件路径或 None(用默认 KUBECONFIG)
|
|
self.registry_prefix = registry_prefix
|
|
self.pull_policy = pull_policy
|
|
|
|
def _kubectl(self, *args, input=None, check=True):
|
|
cmd = ["kubectl"]
|
|
if self.kubeconfig:
|
|
cmd += ["--kubeconfig", self.kubeconfig]
|
|
if self.context:
|
|
cmd += ["--context", self.context]
|
|
cmd += list(args)
|
|
r = subprocess.run(cmd, input=input, capture_output=True, text=True, check=False)
|
|
if check and r.returncode != 0:
|
|
raise RuntimeError(
|
|
f"kubectl 失败 (rc={r.returncode})\nCMD: {' '.join(cmd)}\nSTDOUT: {r.stdout}\nSTDERR: {r.stderr}")
|
|
return r
|
|
|
|
def render_manifests(self):
|
|
chunks = []
|
|
for m in MANIFESTS:
|
|
with open(f"{K8S_DIR}/{m}") as f:
|
|
txt = f.read()
|
|
if self.registry_prefix:
|
|
for img in LOCAL_IMAGES:
|
|
target = f"{self.registry_prefix}/{img}"
|
|
txt = txt.replace(f"image: {img}", f"image: {target}")
|
|
txt = txt.replace("imagePullPolicy: Never", f"imagePullPolicy: {self.pull_policy}")
|
|
chunks.append(txt)
|
|
return "\n---\n".join(chunks)
|
|
|
|
def ensure_pull_secret(self, name="uhub-secret"):
|
|
if not self.registry_prefix:
|
|
return
|
|
user = os.environ.get("UCLOUD_UHUB_USERNAME", "")
|
|
pwd = os.environ.get("UCLOUD_UHUB_PASSWORD", "")
|
|
if not (user and pwd):
|
|
print("[warn] 无 UHub 凭据,跳过 imagePullSecret(pod 拉镜像会 401)")
|
|
return
|
|
print(f"[k8s] 写入 imagePullSecret {name}")
|
|
# 先尝试 create(幂等:已存在就忽略)
|
|
r = self._kubectl("create", "secret", "docker-registry", name,
|
|
"--docker-server=uhub.service.ucloud.cn",
|
|
f"--docker-username={user}", f"--docker-password={pwd}",
|
|
check=False)
|
|
if r.returncode != 0 and "already exists" not in r.stderr:
|
|
# 已存在 → 用 apply 强制覆盖
|
|
r2 = self._kubectl("apply", "-f", "-", input=self._secret_yaml(name, user, pwd))
|
|
print(f"[k8s] secret apply rc={r2.returncode}")
|
|
# 给两个 deployment 挂上 pull secret(合并到 template.spec.imagePullSecrets)
|
|
rj = ('{"spec":{"template":{"spec":{"imagePullSecrets":[{"name":"' + name + '"}]}}}}')
|
|
for dep in ["ssw-tdc", "ssw-nax"]:
|
|
self._kubectl("patch", "deployment", dep, "--type=strategic", "-p", rj, check=False)
|
|
|
|
def _secret_yaml(self, name, user, pwd):
|
|
"""生成 dockerconfigjson 类型的 Secret YAML."""
|
|
auth = base64.b64encode(f"{user}:{pwd}".encode()).decode()
|
|
dcfg = base64.b64encode(
|
|
f'{{"auths":{{"uhub.service.ucloud.cn":{{"username":"{user}","password":"{pwd}","auth":"{auth}"}}}}}}'.encode()
|
|
).decode()
|
|
return (f"apiVersion: v1\nkind: Secret\nmetadata:\n name: {name}\n"
|
|
f"type: kubernetes.io/dockerconfigjson\ndata:\n"
|
|
f" .dockerconfigjson: {dcfg}\n")
|
|
|
|
def apply(self):
|
|
print(f"[apply] kubectl apply")
|
|
self._kubectl("apply", "-f", "-", input=self.render_manifests())
|
|
self.ensure_pull_secret()
|
|
print("[apply] 等 tdc pod Ready ...")
|
|
self._kubectl("rollout", "status", "deployment/ssw-tdc", "--timeout=180s")
|
|
|
|
def down(self):
|
|
print(f"[down] kubectl delete")
|
|
self._kubectl("delete", "-f", "-", input=self.render_manifests(), check=False)
|
|
|
|
|
|
# =========================================================================== 冒烟
|
|
def smoke(env: K8sEnv):
|
|
"""三件套冒烟:lite-TDC + nax + connector。端口与 smoke-tdc.sh 协同。"""
|
|
procs = []
|
|
# 端口规划:必须与 deploy/ucloud-uhost/smoke-tdc.sh 默认 BASE_URL 一致
|
|
targets = [
|
|
("ssw-tdc", 30100, 30000), # lite-TDC 业务
|
|
("ssw-nax", 8090, 8080), # nax 秘密分享
|
|
("ssw-tdc", 9445, 9443), # connector (在 tdc pod 内)
|
|
]
|
|
for svc, port, tport in targets:
|
|
cmd = ["kubectl"]
|
|
if env.kubeconfig:
|
|
cmd += ["--kubeconfig", env.kubeconfig]
|
|
if env.context:
|
|
cmd += ["--context", env.context]
|
|
cmd += ["port-forward", "--address", "127.0.0.1", f"svc/{svc}", f"{port}:{tport}"]
|
|
p = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
procs.append((svc, port, p))
|
|
# 等端口真正起来(轮询,避免 port-forward 慢导致冒烟空响应)
|
|
import socket
|
|
for svc, port, p in procs:
|
|
for _ in range(30):
|
|
try:
|
|
s = socket.create_connection(("127.0.0.1", port), timeout=1)
|
|
s.close()
|
|
break
|
|
except OSError:
|
|
time.sleep(0.5)
|
|
try:
|
|
smoke_script = os.path.join(_DEPLOY_DIR, "ucloud-uhost", "smoke-tdc.sh")
|
|
print("=== [1] lite-TDC 冒烟 ===")
|
|
subprocess.run(["bash", smoke_script, "http://127.0.0.1:30100"], check=False)
|
|
print("=== [2] nax /run ===")
|
|
out = subprocess.run(["curl", "-s", "-m", "15", "-X", "POST", "http://127.0.0.1:8090/run",
|
|
"-H", "Content-Type: application/json",
|
|
"-d", '{"a":[1,2,3],"b":[4,5,6]}'],
|
|
capture_output=True, text=True).stdout
|
|
print(" ", out or "(空响应)")
|
|
print("=== [3] connector /healthz ===")
|
|
code = subprocess.run(["curl", "-s", "-m", "5", "-o", "/dev/null", "-w", "%{http_code}",
|
|
"http://127.0.0.1:9445/healthz"],
|
|
capture_output=True, text=True).stdout
|
|
print(" HTTP", code)
|
|
finally:
|
|
for _, _, p in procs:
|
|
p.terminate()
|
|
try:
|
|
p.wait(timeout=3)
|
|
except subprocess.TimeoutExpired:
|
|
p.kill()
|
|
|
|
|
|
# =========================================================================== ucloud 流程
|
|
def ucloud_resolve_kubeconfig(api: UCloudAPI):
|
|
"""返回 (kubeconfig_path_or_None, context_or_None).优先用现有 KUBECONFIG."""
|
|
# 1) 已有 KUBECONFIG 直接复用(不再自己 GetClusterConfig 覆盖写)
|
|
kc = os.environ.get("KUBECONFIG")
|
|
if kc and os.path.exists(kc):
|
|
ctxs = subprocess.run(["kubectl", "--kubeconfig", kc, "config", "get-contexts", "-o", "name"],
|
|
capture_output=True, text=True).stdout.split()
|
|
if ctxs:
|
|
# 优先用文件名里出现的第一个 context(通常只有一个)
|
|
return kc, ctxs[0]
|
|
raise RuntimeError(f"KUBECONFIG={kc} 里没有可用 context")
|
|
# 2) 指定了已有集群 → 拉 kubeconfig 落盘
|
|
cid = os.environ.get("UCLOUD_CLUSTER_ID")
|
|
if not cid and os.environ.get("UCLOUD_CREATE_CLUSTER") == "1":
|
|
print("[ucloud] 未指定集群,按 UCLOUD_CREATE_CLUSTER=1 新建最小集群 ...")
|
|
cid = api.create_cluster()
|
|
print(f"[ucloud] 集群已创建 ClusterId={cid}(初始化约 5-10 分钟)")
|
|
for _ in range(40):
|
|
try:
|
|
cfg = api.get_config(cid)
|
|
break
|
|
except Exception:
|
|
time.sleep(15)
|
|
else:
|
|
raise RuntimeError("集群未就绪,取不到 kubeconfig")
|
|
if cid:
|
|
cfg = api.get_config(cid)
|
|
path = f"/tmp/k8s/{cid}.kubeconfig"
|
|
with open(path, "w") as f:
|
|
f.write(cfg)
|
|
ctx = subprocess.run(["kubectl", "--kubeconfig", path, "config", "get-contexts", "-o", "name"],
|
|
capture_output=True, text=True).stdout.split()[0]
|
|
return path, ctx
|
|
raise SystemExit("[fatal] 无 kubeconfig:请设 KUBECONFIG / UCLOUD_CLUSTER_ID,或 UCLOUD_CREATE_CLUSTER=1")
|
|
|
|
|
|
def ucloud_up():
|
|
api = UCloudAPI()
|
|
kubeconfig, context = ucloud_resolve_kubeconfig(api)
|
|
uhub_login()
|
|
push_to_uhub()
|
|
env = K8sEnv(context=context, kubeconfig=kubeconfig,
|
|
registry_prefix=UHUB_PREFIX or None, pull_policy="IfNotPresent")
|
|
env.apply()
|
|
print(f"[ucloud] 部署完成.kubectl --kubeconfig {kubeconfig} --context {context} get pods")
|
|
|
|
|
|
def ucloud_down(destroy=False):
|
|
api = UCloudAPI()
|
|
if os.environ.get("UCLOUD_CLUSTER_ID") and destroy:
|
|
api.delete_cluster(os.environ["UCLOUD_CLUSTER_ID"])
|
|
print("[ucloud] 集群已删除")
|
|
return
|
|
kubeconfig, context = ucloud_resolve_kubeconfig(api)
|
|
env = K8sEnv(context=context, kubeconfig=kubeconfig,
|
|
registry_prefix=UHUB_PREFIX or None, pull_policy="IfNotPresent")
|
|
env.down()
|
|
print("[ucloud] 部署已删除(集群保留;加 --destroy 才删集群)")
|
|
|
|
|
|
# =========================================================================== UHost + k3s 流程
|
|
def _ssh(eip, cmd, user="ubuntu", password=None, timeout=60):
|
|
"""ssh 远程执行单条命令.依赖 sshpass(密码登录);也可手动 export UCLOUD_SSH_PASSWORD."""
|
|
pwd = password or os.environ.get("UCLOUD_SSH_PASSWORD") or eip
|
|
if subprocess.run(["which", "sshpass"], capture_output=True).returncode != 0:
|
|
raise RuntimeError("sshpass 未装(brew install sshpass)")
|
|
r = subprocess.run(
|
|
["sshpass", "-p", pwd, "ssh", "-o", "StrictHostKeyChecking=no",
|
|
f"{user}@{eip}", cmd],
|
|
capture_output=True, text=True, timeout=timeout)
|
|
if r.returncode != 0:
|
|
raise RuntimeError(f"ssh 失败: {r.stderr or r.stdout}")
|
|
return r.stdout
|
|
|
|
|
|
def _scp(eip, local, remote, user="ubuntu", password=None):
|
|
"""scp 单文件到远端."""
|
|
pwd = password or os.environ.get("UCLOUD_SSH_PASSWORD") or eip
|
|
r = subprocess.run(
|
|
["sshpass", "-p", pwd, "scp", "-o", "StrictHostKeyChecking=no",
|
|
local, f"{user}@{eip}:{remote}"],
|
|
capture_output=True, text=True)
|
|
if r.returncode != 0:
|
|
raise RuntimeError(f"scp 失败: {r.stderr}")
|
|
|
|
|
|
def uhost_create():
|
|
"""建 1C8G UHost(Dynamic 按小时)+ 绑 EIP + 启动."""
|
|
api = UCloudAPI()
|
|
# 1. 找 Ubuntu 24.04 镜像(已知 uimage-1u7g1m8r236m,hard-code 节省一次 API 调用)
|
|
image_id = "uimage-1u7g1m8r236m"
|
|
# 2. 找默认安全组(firewall-0mmdp4hu = ssw 22/80/443/6443/10000-11000,hard-code)
|
|
sg_id = "firewall-0mmdp4hu"
|
|
# 3. 找默认 VPC / 子网
|
|
project_id = api._first("GetProjectList", "ProjectSet", "ProjectId")
|
|
vpc = api._first("DescribeVPC", "DataSet", "VPCId", ProjectId=project_id)
|
|
subnet = api._first("DescribeSubnet", "DataSet", "SubnetId", VPCId=vpc, ProjectId=project_id)
|
|
# 4. 建 UHost(Dynamic + Ubuntu 24.04 + 1C8G)
|
|
import secrets, string, base64
|
|
pwd = "Ssw" + "".join(secrets.choice(string.ascii_letters + string.digits) for _ in range(13))
|
|
pwd_b64 = base64.b64encode(pwd.encode()).decode()
|
|
print(f"[uhost] 创建 UHost: Ubuntu 24.04 / 1C8G / Dynamic / 安全组 {sg_id}")
|
|
out = api.call(
|
|
"CreateUHostInstance",
|
|
ImageId=image_id, CPU=1, Memory=8192,
|
|
Name="ssw-flow-node",
|
|
LoginMode="Password", Password=pwd_b64,
|
|
ChargeType="Dynamic",
|
|
VPCId=vpc, SubnetId=subnet,
|
|
SecurityGroupId=sg_id,
|
|
Disks_0_IsBoot="True", Disks_0_Size="40", Disks_0_Type="CLOUD_SSD",
|
|
MachineType="N", MinimalCpuPlatform="Intel/Auto", MaxCount="1",
|
|
)
|
|
uh_id = out["UHostIds"][0]
|
|
print(f"[uhost] Created: {uh_id}, 临时密码: {pwd}")
|
|
os.environ["UCLOUD_UHOST_ID"] = uh_id
|
|
# 5. 启动
|
|
api.call("StartUHostInstance", UHostId=uh_id)
|
|
print(f"[uhost] Started {uh_id}")
|
|
# 6. 申请 + 绑定 EIP(如果 AllocateEIP 没权限则跳过,让用户在控制台手工绑)
|
|
try:
|
|
eip_out = api.call("AllocateEIP", OperatorName="Bgp", Bandwidth="1",
|
|
PayMode="Traffic", ChargeType="Dynamic", Name="ssw-flow-eip")
|
|
eip_id = eip_out["EIPSet"][0]["EIPId"]
|
|
api.call("BindEIP", EIPId=eip_id, ResourceId=uh_id)
|
|
# 查 EIP 地址
|
|
eip_info = api.call("DescribeEIP", Limit=10)
|
|
addr = next((e["EIPAddr"][0]["IP"] for e in eip_info.get("EIPSet", [])
|
|
if e["EIPId"] == eip_id), "")
|
|
print(f"[uhost] EIP {eip_id} -> {addr}")
|
|
os.environ["UCLOUD_EIP"] = addr
|
|
except Exception as e:
|
|
print(f"[warn] EIP 申请失败(控制台手工分配并绑): {e}")
|
|
print(f"\n下一步:export UCLOUD_UHOST_ID={uh_id} && python lifecycle.py uhost setup-k3s")
|
|
|
|
|
|
def uhost_setup_k3s():
|
|
"""ssh 远程装 k3s + 配 containerd 镜像加速 + UHub 凭据 + 持久化目录."""
|
|
uh_id = os.environ["UCLOUD_UHOST_ID"]
|
|
eip = os.environ.get("UCLOUD_EIP")
|
|
if not eip:
|
|
api = UCloudAPI()
|
|
out = api.call("DescribeEIP", Limit=50)
|
|
addr = next((e["EIPAddr"][0]["IP"] for e in out.get("EIPSet", [])
|
|
if any(r.get("ResourceId") == uh_id for r in e.get("Resource", {}).values())), "")
|
|
if not addr:
|
|
raise RuntimeError(f"未找到 UHost {uh_id} 绑定的 EIP,请先在控制台绑")
|
|
os.environ["UCLOUD_EIP"] = eip = addr
|
|
print(f"[setup-k3s] 远端 {eip} ...")
|
|
# 1. 装 k3s
|
|
_ssh(eip, "sudo bash -c 'curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | "
|
|
"INSTALL_K3S_MIRROR=cn sh -s - --write-kubeconfig-mode 644'", timeout=180)
|
|
# 2. 等 k3s Ready
|
|
out = _ssh(eip, "for i in $(seq 1 60); do "
|
|
" if sudo k3s kubectl get node 2>/dev/null | grep -q ' Ready'; then "
|
|
" echo READY_$i; break; fi; sleep 2; done", timeout=180)
|
|
print(f"[setup-k3s] {out.strip()}")
|
|
# 3. 写 registries.yaml(镜像加速 + UHub 凭据)
|
|
hub_user = os.environ.get("UCLOUD_UHUB_USERNAME", "")
|
|
hub_pwd = os.environ.get("UCLOUD_UHUB_PASSWORD", "")
|
|
reg_yaml = f"""mirrors:
|
|
docker.io:
|
|
endpoint: ["https://docker.1panel.live", "https://docker.m.daocloud.io"]
|
|
uhub.service.ucloud.cn:
|
|
endpoint: ["https://uhub.service.ucloud.cn"]
|
|
configs:
|
|
uhub.service.ucloud.cn:
|
|
auth:
|
|
username: "{hub_user}"
|
|
password: "{hub_pwd}"
|
|
"""
|
|
_ssh(eip, f"sudo tee /etc/rancher/k3s/registries.yaml > /dev/null <<'YAML'\n{reg_yaml}YAML")
|
|
_ssh(eip, "sudo systemctl restart k3s")
|
|
print("[setup-k3s] registries.yaml 已写,k3s 重启中 ...")
|
|
# 4. 持久化目录
|
|
_ssh(eip, "sudo mkdir -p /var/lib/ssw-tdc/pgdata && sudo chown -R 10001:10001 /var/lib/ssw-tdc")
|
|
# 5. 把本地 setup-uhost.sh 上传一份(后续可用 'uhost setup-k3s' 复用)
|
|
remote_script = "/tmp/setup-uhost.sh"
|
|
local_script = os.path.join(_DEPLOY_DIR, "ucloud-uhost", "setup-uhost.sh")
|
|
if os.path.exists(local_script):
|
|
_scp(eip, local_script, remote_script)
|
|
print(f"[setup-k3s] 完成.EIP={eip} UHostId={uh_id}")
|
|
|
|
|
|
def uhost_build():
|
|
"""构建 ssw-tdc / ssw-nax 本地镜像(amd64)."""
|
|
for sub, tag in [("tdc", "ssw-tdc:local"), ("nax", "ssw-nax:local")]:
|
|
ctx = os.path.join(MIRRORS_DIR, sub)
|
|
if not os.path.isdir(ctx):
|
|
raise FileNotFoundError(f"镜像上下文不存在: {ctx}")
|
|
print(f"[build] docker build --platform linux/amd64 -t {tag} {ctx}")
|
|
subprocess.run(["docker", "build", "--platform", "linux/amd64", "-t", tag, ctx], check=True)
|
|
subprocess.run(["docker", "images"] + LOCAL_IMAGES, check=False)
|
|
|
|
|
|
def uhost_push():
|
|
"""登录 UHub + 推送两个镜像."""
|
|
uhub_login()
|
|
push_to_uhub()
|
|
subprocess.run(["docker", "images"] + [f"{UHUB_PREFIX}/{img}" for img in LOCAL_IMAGES], check=False)
|
|
|
|
|
|
def uhost_up():
|
|
"""apply k8s 清单 + 改镜像 tag 为 UHub 远端 + 改 imagePullPolicy + 注入 imagePullSecret + 等 Ready."""
|
|
kc = os.environ.get("KUBECONFIG") or os.path.join(K8S_DIR, "kubeconfig.yaml")
|
|
if not os.path.exists(kc):
|
|
raise FileNotFoundError(f"未找到 kubeconfig: {kc}(先跑 'uhost setup-k3s' 并拉 kubeconfig)")
|
|
# 1. apply 全部清单
|
|
subprocess.run(["kubectl", "--kubeconfig", kc, "apply", "-f", K8S_DIR], check=True)
|
|
# 2. 改 image tag 为 UHub 远端
|
|
if UHUB_PREFIX:
|
|
subprocess.run(["kubectl", "--kubeconfig", kc, "set", "image",
|
|
"deployment/ssw-tdc", "tdc=" + UHUB_PREFIX + "/ssw-tdc:local",
|
|
"connector=" + UHUB_PREFIX + "/ssw-tdc:local"], check=True)
|
|
subprocess.run(["kubectl", "--kubeconfig", kc, "set", "image",
|
|
"deployment/ssw-nax", "nax=" + UHUB_PREFIX + "/ssw-nax:local"], check=True)
|
|
# 3. 改 imagePullPolicy: Never -> IfNotPresent
|
|
for dep, containers in [("ssw-tdc", ["tdc", "connector"]), ("ssw-nax", ["nax"])]:
|
|
patch = {"spec": {"template": {"spec": {"containers": [
|
|
{"name": c, "imagePullPolicy": "IfNotPresent"} for c in containers
|
|
]}}}}
|
|
subprocess.run(["kubectl", "--kubeconfig", kc, "patch", "deployment", dep,
|
|
"--type=merge", "-p", json.dumps(patch)], check=True)
|
|
# 4. uncordon 单节点
|
|
subprocess.run(["kubectl", "--kubeconfig", kc, "uncordon", "--all"], check=False)
|
|
# 5. 等 tdc Ready
|
|
print("[up] 等 tdc pod Ready (最多 180s) ...")
|
|
subprocess.run(["kubectl", "--kubeconfig", kc, "rollout", "status",
|
|
"deployment/ssw-tdc", "--timeout=180s"], check=True)
|
|
subprocess.run(["kubectl", "--kubeconfig", kc, "rollout", "status",
|
|
"deployment/ssw-nax", "--timeout=180s"], check=True)
|
|
|
|
|
|
def uhost_smoke():
|
|
"""起 kubectl port-forward + 跑三件套冒烟."""
|
|
kc = os.environ.get("KUBECONFIG") or os.path.join(K8S_DIR, "kubeconfig.yaml")
|
|
env = K8sEnv(kubeconfig=kc, pull_policy="IfNotPresent")
|
|
smoke(env)
|
|
|
|
|
|
def uhost_lifecycle(action):
|
|
"""UHost 生命周期:start/stop/destroy."""
|
|
api = UCloudAPI()
|
|
uh_id = os.environ.get("UCLOUD_UHOST_ID")
|
|
if not uh_id:
|
|
raise SystemExit("[fatal] 需 UCLOUD_UHOST_ID 环境变量")
|
|
if action == "stop":
|
|
api.call("StopUHostInstance", UHostId=uh_id)
|
|
print(f"[uhost] {uh_id} 已停机(Dynamic 立即停计费,磁盘保留)")
|
|
elif action == "start":
|
|
api.call("StartUHostInstance", UHostId=uh_id)
|
|
print(f"[uhost] {uh_id} 已启动")
|
|
elif action == "destroy":
|
|
# 先停机再销毁(ucloud 要求),带 ReleaseUDisk 一起释放数据盘
|
|
try:
|
|
api.call("StopUHostInstance", UHostId=uh_id)
|
|
time.sleep(5)
|
|
except Exception:
|
|
pass
|
|
api.call("TerminateUHostInstance", UHostId=uh_id, ReleaseUDisk="true")
|
|
print(f"[uhost] {uh_id} 已销毁(连数据盘一起释放)")
|
|
else:
|
|
raise SystemExit(f"unknown action: {action}")
|
|
|
|
|
|
# =========================================================================== main
|
|
def main():
|
|
ap = argparse.ArgumentParser(
|
|
description="SSW 参与方节点生命周期(orbstack / ucloud / uhost)")
|
|
ap.add_argument("provider", choices=["orbstack", "ucloud", "uhost", "selftest"])
|
|
ap.add_argument("action", nargs="?",
|
|
choices=["up", "down", "smoke", "validate",
|
|
"create", "setup-k3s", "build", "push",
|
|
"stop", "start", "destroy"],
|
|
default="up")
|
|
ap.add_argument("--destroy", action="store_true", help="ucloud down 时一并删集群")
|
|
args = ap.parse_args()
|
|
|
|
if args.provider == "selftest":
|
|
ok = UCloudAPI.selftest()
|
|
sys.exit(0 if ok else 1)
|
|
|
|
if args.provider == "uhost":
|
|
if args.action == "create":
|
|
uhost_create()
|
|
elif args.action == "setup-k3s":
|
|
uhost_setup_k3s()
|
|
elif args.action == "build":
|
|
uhost_build()
|
|
elif args.action == "push":
|
|
uhost_push()
|
|
elif args.action == "up":
|
|
uhost_up()
|
|
elif args.action == "smoke":
|
|
uhost_smoke()
|
|
elif args.action in ("stop", "start", "destroy"):
|
|
uhost_lifecycle(args.action)
|
|
else:
|
|
raise SystemExit(f"uhost 不支持 action={args.action}")
|
|
return
|
|
|
|
if args.provider == "orbstack":
|
|
env = K8sEnv(context="orbstack", registry_prefix=None, pull_policy="Never")
|
|
else: # ucloud
|
|
if not UHUB_PREFIX:
|
|
print("[warn] UCLOUD_UHUB_PREFIX 未设,apply 用占位前缀", file=sys.stderr)
|
|
if args.action == "up":
|
|
ucloud_up()
|
|
return
|
|
elif args.action == "down":
|
|
ucloud_down(destroy=args.destroy)
|
|
return
|
|
elif args.action == "validate":
|
|
api = UCloudAPI()
|
|
api.validate()
|
|
return
|
|
else: # smoke
|
|
api = UCloudAPI()
|
|
kubeconfig, context = ucloud_resolve_kubeconfig(api)
|
|
env = K8sEnv(context=context, kubeconfig=kubeconfig)
|
|
smoke(env)
|
|
return
|
|
|
|
if args.action == "up":
|
|
env.apply()
|
|
print(f"[{args.provider}] 部署完成.")
|
|
elif args.action == "down":
|
|
env.down()
|
|
print(f"[{args.provider}] 部署已删除")
|
|
elif args.action == "smoke":
|
|
smoke(env)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|