如何增大Azure Kubernetes Service中Windows容器的Pod磁盘空间?
在AKS中增大Windows构建代理容器的磁盘空间
方案一:挂载持久卷到构建工作目录(推荐)
无需修改容器根磁盘大小,将构建作业的工作目录挂载到独立的Azure磁盘,避免占用容器根分区,同时支持数据持久化。
1. 创建PersistentVolumeClaim(PVC)
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: build-agent-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 50Gi # 按需设置磁盘容量 storageClassName: managed-csi # 使用AKS默认托管磁盘存储类
2. 修改Pod YAML挂载PVC
将PVC挂载到构建代理的工作目录(示例为C:\agent\_work,请替换为实际路径):
apiVersion: v1 kind: Pod metadata: name: windows-build-agent spec: containers: - name: build-agent image: your-windows-build-agent-image:tag volumeMounts: - name: build-storage mountPath: C:\agent\_work volumes: - name: build-storage persistentVolumeClaim: claimName: build-agent-pvc nodeSelector: kubernetes.io/os: windows
方案二:增大容器根文件系统(C盘)大小
若需直接扩容容器的根磁盘(C盘),可通过Pod的securityContext配置实现,适用于Windows Server 2022及以上版本的AKS节点池:
apiVersion: v1 kind: Pod metadata: name: windows-build-agent spec: containers: - name: build-agent image: your-windows-build-agent-image:tag securityContext: windowsOptions: storageOpt: size: "50Gi" # 设置目标根磁盘容量 nodeSelector: kubernetes.io/os: windows
方案三:使用节点临时磁盘(emptyDir)
如果不需要持久化构建数据,可挂载节点的临时磁盘,空间大小取决于节点VM类型,通常比默认容器根磁盘更大:
apiVersion: v1 kind: Pod metadata: name: windows-build-agent spec: containers: - name: build-agent image: your-windows-build-agent-image:tag volumeMounts: - name: build-storage mountPath: C:\agent\_work volumes: - name: build-storage emptyDir: {} nodeSelector: kubernetes.io/os: windows
内容的提问来源于stack exchange,提问作者bianconero
相关产品推荐
相关产品推荐

