返回资讯中心
外部精选
软件工程
#开发者实时流

开源项目发布 Kubernetes Operator,让 OpenAI 编码代理在集群中运行

来源标题:Show HN: Kubernetes Operator for the OpenAI Managed Agents API

开发者发布 codex-session-operator,可在 Kubernetes 中对 Git 仓库运行 OpenAI 编码代理。OpenAI 负责代理循环与模型推理,集群通过 Agent Sandbox 执行命令并存储仓库文件,网关将消息、结果与审批存入 PostgreSQL。项目目前为 alpha 版本,实际使用需 OpenAI Agents API 访问权限并产生 API 费用。

Hacker News 最新pradeep11772026/11/2 · 2 天前18 分钟阅读

以下正文由 AI 翻译自 Hacker News 最新(原文版权归原站所有),可能存在偏差,重要内容请以原文为准。

在 Kubernetes 中针对 Git 仓库运行 OpenAI 编码代理。给代理一个任务,让它在隔离的工作区中工作,然后通过 HTTP API 或 CLI 读取结果。继续对话即可在同一工作区中继续工作。

OpenAI 负责运行代理循环和模型推理。你的集群通过 Kubernetes Agent Sandbox 运行命令并存储仓库文件。网关将消息、结果和审批保存到 PostgreSQL 中。

该项目处于 alpha 阶段。实际任务需要 OpenAI Agents API 访问权限,并会产生 API 费用。

发布版下载可在无需源码检出、Go 或 Make 的情况下安装 operator 和 CLI。以下命令需要已发布的 release;请将 vX.Y.Z 替换为 Releases 中的一个标签。

最新稳定版:CRD、controller 和 gateway。

kubectl apply -f https://github.com/softcane/codex-session-operator/releases/latest/download/install.yaml

或者为生产和 GitOps 固定一个 release。

export VERSION=vX.Y.Z kubectl apply -f "https://github.com/softcane/codex-session-operator/releases/download/${VERSION}/install.yaml"

请按照测试过的版本单独安装 Agent Sandbox,然后参照安装指南提供 PostgreSQL 和 Secrets。网关默认使用 HTTP。

对于 CLI,请下载适用于你机器的压缩包。例如,在 Apple Silicon 的 macOS 上:

curl -fsSLO https://github.com/softcane/codex-session-operator/releases/latest/download/gateway-client_darwin_arm64.tar.gz tar -xzf gateway-client_darwin_arm64.tar.gz gateway-client sudo install -m 0755 gateway-client /usr/local/bin/gateway-client

压缩包也适用于 darwin_amd64、linux_amd64 和 linux_arm64。要固定 CLI 版本,请将 latest/download 替换为 download/${VERSION}。每个 release 都包含 SHA256SUMS。

按照「运行你的第一个仓库任务」下载匹配的示例 manifest,配置工作区并发送任务。源码构建相关内容见 Contributing。

创建一个 SandboxTemplate 和一个 SandboxWarmPool,然后在同一命名空间中定义 Agent、Environment 和 Profile。这些示例使用 sandbox-v1 进行工作区设置,并且一起放在 examples/repository-task.yaml 中。

安装后,将 sandbox-v1 加入 controller 的 SANDBOX_POOLS 设置中。使用 Secret 设置中的 codex-executor Secret 作为受限环境密钥。

下面的模板会准备公共的 google/uuid 仓库,并为该检出配置一个 Go 执行器。在应用它之前,请替换示例镜像 digest、选择你的节点架构并设置一个可用的 StorageClass。镜像必须包含 codex exec-server、/workspace-bootstrap 和 Go;应用执行器的 Dockerfile 会构建该层。YAML 的 image 锚点让两个容器使用相同的镜像引用。

apiVersion: extensions.agents.x-k8s.io/v1beta1 kind: SandboxTemplate metadata: name: sandbox-v1 namespace: codex-session-operator-system labels: agents.softcane.io/managed: "true" spec: envVarsInjectionPolicy: Allowed service: false podTemplate: spec: automountServiceAccountToken: false restartPolicy: Always terminationGracePeriodSeconds: 10 nodeSelector: kubernetes.io/arch: arm64 securityContext: runAsNonRoot: true runAsUser: 1000 runAsGroup: 1000 fsGroup: 1000 seccompProfile: {type: RuntimeDefault} initContainers:

  • name: repository-prepare image: &executor_image registry.example/executor@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa imagePullPolicy: IfNotPresent command: [/workspace-bootstrap] args:
  • --storage-root
  • /workspace-storage
  • --session-uid
  • $(SESSION_UID)
  • --url
  • https://github.com/google/uuid.git
  • --commit
  • 0f11ee6918f41a04c201eceeadf612a377bc7fbc env:
  • name: TMPDIR value: /tmp securityContext: &restricted allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: {drop: [ALL]} resources: requests: {cpu: 100m, memory: 128Mi} limits: {cpu: "1", memory: 512Mi} volumeMounts:
  • {name: workspace, mountPath: /workspace-storage}
  • {name: tmp, mountPath: /tmp} containers:
  • name: executor image: *executor_image imagePullPolicy: IfNotPresent workingDir: /workspace command: [codex, exec-server] args: [--remote, $(CODEX_REMOTE_URL), --environment-id, $(CODEX_ENVIRONMENT_ID)] env:
  • name: CODEX_API_KEY valueFrom: secretKeyRef: name: codex-executor key: CODEX_API_KEY securityContext: *restricted resources: requests: {cpu: 250m, memory: 256Mi} limits: {cpu: "2", memory: 2Gi} volumeMounts:
  • {name: workspace, mountPath: /workspace, subPath: project}
  • {name: home, mountPath: /home/node}
  • {name: tmp, mountPath: /tmp} volumes:
  • name: home emptyDir: {sizeLimit: 128Mi}
  • name: tmp emptyDir: {sizeLimit: 1Gi} volumeClaimTemplates:
  • metadata: name: workspace spec: accessModes: [ReadWriteOnce] storageClassName: standard resources: requests: {storage: 1Gi}

该池会选择该模板。当 replicas: 0 时,Agent Sandbox 会在 Session 请求时分配一个工作区。

apiVersion: extensions.agents.x-k8s.io/v1beta1 kind: SandboxWarmPool metadata: name: sandbox-v1 namespace: codex-session-operator-system labels: agents.softcane.io/managed: "true" spec: replicas: 0 sandboxTemplateRef: name: sandbox-v1

托管的模板和池规格是不可变的。要更改已安装的配方,请创建新的带版本的一对,并批准新的池。

Environment 选择 sandbox-v1;Profile 将其与 Agent 和支出策略组合在一起。

apiVersion: agents.softcane.io/v1alpha1 kind: Agent metadata: name: sandbox-agent namespace: codex-session-operator-system spec: model: gpt-6-luna instructions: Use the prepared repository and report actual commands and results. deletionPolicy: Delete

apiVersion: agents.softcane.io/v1alpha1 kind: Environment metadata: name: sandbox-environment namespace: codex-session-operator-system spec: mode: SelfHosted deletionPolicy: Delete selfHosted: sandboxPoolRef: name: sandbox-v1 workspace: directory: /workspace deletionPolicy: Delete

(原文较长,此处译出前 6000 字,完整内容请点「打开原文」。)

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →