fix(#56): 补齐 k8s 部署产物 —— 编排器镜像装 kubectl、RBAC 加 secrets、Deployment 接拉起 env + workload-identity label
让 k8s 拉起链路在仓内"可部署即可用"(此前线上实测全缺):
- Dockerfile.orchestrator:装 `kubectl`(pin AKS 1.34;linux/amd64)。launcher 靠 shell
`kubectl apply/delete` 建/删 agent Pod + 每-swarm key Secret,镜像无 kubectl 则 k8s 后端必失败。
- k8s/rbac/orchestrator-role.yaml:加 `secrets`(create/delete/list/get)——否则建不了模型 key
Secret、agent keyless。并注明 Role 命名空间须与 AGENT_POD_NAMESPACE 一致。
- k8s/orchestrator-deployment.yaml:
- pod 模板加 `azure.workload.identity/use: "true"`(AKS webhook 注入 token,配合已注解的
SA + UAMI 读 heicode-vault)。
- 接入拉起 env:`AGENT_LAUNCH_BACKEND=kubernetes`、`AGENT_POD_IMAGE=heicode.azurecr.io/swarm-agent:latest`、
`AGENT_POD_NAMESPACE=swarm-system`(同 RBAC ns)、`ORCHESTRATOR_PUBLIC_URL=ws://orchestrator-service...:8000`、
`AGENT_OPENAI_API_BASE=https://code.heicode.cc/v1`、`SECRET_RESOLVER=azkv`。
- image 指向 ACR(`heicode.azurecr.io/swarm-orchestrator`,tag 部署时 pin)。
校验:两个 manifest YAML 解析通过(label/env/secrets 均在);test-agent-launcher / test-swarm-guard /
test-contract-freeze 全绿。无明文密钥。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
207e027fbb
commit
aa4679f610
@@ -1,5 +1,16 @@
|
|||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
# kubectl — the kubernetes launch backend (agent_swarm#16/#56) shells out to `kubectl apply/delete`
|
||||||
|
# to create/teardown agent Pods + per-swarm key Secrets. Without it the k8s backend fails (0 agents).
|
||||||
|
# Pinned to the cluster minor (AKS 1.34) per kubectl skew policy. (linux/amd64 — AKS default node arch.)
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends curl ca-certificates \
|
||||||
|
&& KUBECTL_VERSION="$(curl -fsSL https://dl.k8s.io/release/stable-1.34.txt)" \
|
||||||
|
&& curl -fsSL "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl \
|
||||||
|
&& chmod +x /usr/local/bin/kubectl \
|
||||||
|
&& kubectl version --client=true 2>/dev/null \
|
||||||
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
|||||||
@@ -30,11 +30,15 @@ spec:
|
|||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: orchestrator
|
app: orchestrator
|
||||||
|
# Required for the AKS workload-identity webhook to inject AZURE_FEDERATED_TOKEN_FILE etc.
|
||||||
|
# into the pod, so the orchestrator can read the per-user model key from heicode-vault via
|
||||||
|
# its UAMI (SA swarm-orchestrator is annotated with azure.workload.identity/client-id). #56
|
||||||
|
azure.workload.identity/use: "true"
|
||||||
spec:
|
spec:
|
||||||
serviceAccountName: swarm-orchestrator
|
serviceAccountName: swarm-orchestrator
|
||||||
containers:
|
containers:
|
||||||
- name: orchestrator
|
- name: orchestrator
|
||||||
image: swarm-orchestrator:latest
|
image: heicode.azurecr.io/swarm-orchestrator:latest # deploy pins the tag (e.g. :<gitsha>)
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
@@ -66,6 +70,26 @@ spec:
|
|||||||
# (also set REDIS_CLUSTER=1 for an OSSCluster endpoint).
|
# (also set REDIS_CLUSTER=1 for an OSSCluster endpoint).
|
||||||
- name: LOG_LEVEL
|
- name: LOG_LEVEL
|
||||||
value: "INFO"
|
value: "INFO"
|
||||||
|
# ── Swarm agent launch (agent_swarm#16/#56): make the runtime actually spawn agents ──
|
||||||
|
# Without AGENT_LAUNCH_BACKEND the launcher is a no-op (0 agents → run hangs).
|
||||||
|
- name: AGENT_LAUNCH_BACKEND
|
||||||
|
value: "kubernetes"
|
||||||
|
- name: AGENT_POD_IMAGE
|
||||||
|
value: "heicode.azurecr.io/swarm-agent:latest" # build: az acr build -r heicode -t swarm-agent:latest -f Dockerfile.agent .
|
||||||
|
# Agent Pods + per-swarm key Secrets are created here — MUST match the RBAC Role's ns
|
||||||
|
# (k8s/rbac/orchestrator-role.yaml is in swarm-system).
|
||||||
|
- name: AGENT_POD_NAMESPACE
|
||||||
|
value: "swarm-system"
|
||||||
|
# In-cluster Service DNS the launched agents connect back to (Service: orchestrator-service).
|
||||||
|
- name: ORCHESTRATOR_PUBLIC_URL
|
||||||
|
value: "ws://orchestrator-service.swarm-system.svc.cluster.local:8000"
|
||||||
|
# HM model gateway (OpenAI-compatible). code.heicode.cc is the official address (#56).
|
||||||
|
- name: AGENT_OPENAI_API_BASE
|
||||||
|
value: "https://code.heicode.cc/v1"
|
||||||
|
# Resolve per-user model key from heicode-vault via the pod's workload identity (#56).
|
||||||
|
# (Redundant when AZURE_FEDERATED_TOKEN_FILE is injected, but explicit is clearer.)
|
||||||
|
- name: SECRET_RESOLVER
|
||||||
|
value: "azkv"
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
|
|||||||
@@ -6,12 +6,23 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
app: heicode-swarm
|
app: heicode-swarm
|
||||||
component: orchestrator
|
component: orchestrator
|
||||||
|
# NOTE: a Role is namespaced — these permissions only apply in `swarm-system`. The k8s launch
|
||||||
|
# backend creates agent Pods + per-swarm key Secrets in AGENT_POD_NAMESPACE, so that env MUST equal
|
||||||
|
# this namespace (set AGENT_POD_NAMESPACE=swarm-system), or a matching Role+RoleBinding must exist in
|
||||||
|
# the agent-pod namespace. (agent_swarm#56)
|
||||||
rules:
|
rules:
|
||||||
# Pod management permissions
|
# Pod management permissions
|
||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["pods"]
|
resources: ["pods"]
|
||||||
verbs: ["create", "delete", "list", "watch", "get"]
|
verbs: ["create", "delete", "list", "watch", "get"]
|
||||||
|
|
||||||
|
# Per-swarm model-key Secret: the launcher applies a Secret (build_secret_manifest) referenced by
|
||||||
|
# the agent Pod via secretKeyRef, and deletes it on teardown (`kubectl delete pod,secret`).
|
||||||
|
# Without `secrets` create/delete the key Secret can't be made → agents start keyless. (#56)
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["secrets"]
|
||||||
|
verbs: ["create", "delete", "list", "get"]
|
||||||
|
|
||||||
# Pod log access
|
# Pod log access
|
||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["pods/log"]
|
resources: ["pods/log"]
|
||||||
|
|||||||
Reference in New Issue
Block a user