如果您在 Google Kubernetes Engine (GKE) 上執行標準 AI 代理程式基準、開發人員環境或自動化管道工作負載,可以直接搭配 Filestore 代理程式磁碟區使用標準 Kubernetes PersistentVolumeClaim (PVC) 和 Deployment 資源。
這個模式使用熟悉的 Kubernetes 資源定義,不需要自訂沙箱控制器或 DaemonSet 資源。
事前準備
在「為 Filestore 代理程式磁碟區設定 GKE 環境」中,完成叢集和 CSI 驅動程式設定。
建立 PersistentVolumeClaim
建立名為 agent-pvc.yaml 的資訊清單,要求從您稍早建立的 volume-pool-sc StorageClass 取得儲存空間:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: agent-workspace-pvc
namespace: default
spec:
accessModes:
- ReadWriteMany
storageClassName: volume-pool-sc
resources:
requests:
storage: 1Gi
套用資訊清單:
kubectl apply -f agent-pvc.yaml
確認 PVC 轉換為 Bound:
kubectl get pvc agent-workspace-pvc
輸出結果會與下列內容相似:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
agent-workspace-pvc Bound pvc-12345678-abcd-ef01-2345-6789abcdef01 1Gi RWX volume-pool-sc 5s
Filestore CSI 驅動程式會在磁碟區集區中,於不到一秒內佈建新磁碟區,並繫結 PVC。
部署代理程式工作負載
建立名為 agent-deployment.yaml 的 Deployment 資訊清單,裝載已繫結的 PVC:
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent-worker
namespace: default
labels:
app: agent-worker
spec:
replicas: 1
selector:
matchLabels:
app: agent-worker
template:
metadata:
labels:
app: agent-worker
spec:
containers:
- name: worker
image: busybox:latest
command: ["/bin/sh", "-c"]
args:
- |
echo "Agent worker started. Workspace mounted at /workspace:"
ls -la /workspace
echo "Writing benchmark results..."
date > /workspace/run-status.txt
cat /workspace/run-status.txt
sleep infinity
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
volumeMounts:
- name: workspace-storage
mountPath: /workspace
volumes:
- name: workspace-storage
persistentVolumeClaim:
claimName: agent-workspace-pvc
套用資訊清單:
kubectl apply -f agent-deployment.yaml
驗證部署作業和檔案存取權
確認部署 Pod 正在執行:
kubectl get pods -l app=agent-worker
輸出結果會與下列內容相似:
NAME READY STATUS RESTARTS AGE agent-worker-6789bcdef-ghijk 1/1 Running 0 30s檢查容器記錄,確認檔案作業是否成功:
kubectl logs -l app=agent-worker -c worker
輸出結果會與下列內容相似:
Agent worker started. Workspace mounted at /workspace: total 8 drwxr-xr-x 2 root root 4096 Sep 14 12:00 . drwxr-xr-x 1 root root 4096 Sep 14 12:00 .. Writing benchmark results... Mon Sep 14 12:00:05 UTC 2026
由於 Filestore 代理程式磁碟區支援 ReadWriteMany (RWX) 存取權,因此多個副本或不同 Pod 可以同時掛接相同的 PVC,以進行協作代理程式工作流程。
後續步驟
- 探索 Agent Sandbox。
- 設定具有動態儲存空間延遲繫結的 Agent Sandbox。
- 建立及設定磁碟區集區。