【问题标题】:Azure Kubernetes Service - Increase Windows disk spaceAzure Kubernetes 服务 - 增加 Windows 磁盘空间
【发布时间】:2022-09-28 18:03:20
【问题描述】:

我想在 Azure Kubernetes 服务实例上托管充当构建代理的 Windows 容器 - 不幸的是,我无法增加默认的 20GB pod 磁盘空间。我需要更多的磁盘空间来在 pod 上运行构建作业。

通过应用描述工作负载的 YAML,使用 ADO 管道部署 pod。

附加 pod 并证明磁盘空间会导致以下结果:

PS: C:\\ Get-PSDrive C

Name           Used (GB)     Free (GB) Provider      Root
----           ---------     --------- --------      ----
C                   0.31         19.57 FileSystem    C:\\

有人知道如何增加磁盘空间吗?

在我们的本地集群中,可以通过添加

--storage-opt 50G

作为修改后的 Docker 服务参数的参数。

但它对 AKS 有什么作用?

非常感谢您!

  • 参数是什么? Docker 运行命令?如何在 AKS 中部署 pod?
  • --> 修改 docker 服务参数并添加 --storage-opt --> 使用 YAML 部署,使用带有专用服务连接的 ADO 管道
  • 编辑您的问题,添加您刚刚在评论中描述的所有步骤。

标签: azure containers azure-aks diskspace podspec


【解决方案1】:

我们可以通过使用持久卷手动创建磁盘来增加 AKS 中的 pod 磁盘大小

默认磁盘大小为 4GiB对我来说是 30 GiB,我增加到 50 GiB

要增加磁盘大小,请按照以下步骤操作

  • 我已经为磁盘创建了存储类

          vi sc.yaml
    
   kind: StorageClass
   apiVersion: storage.k8s.io/v1
metadata:
  name: azuredisk-premium-retain       
provisioner: kubernetes.io/azure-disk  
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters :
  storageaccounttype: Premium_LRS      
  kind: Managed

要部署存储类,请使用以下命令

         kubectl apply -f sc.yaml 
                  

请使用以下命令检查是否创建了存储类

      kubectl get sc 
  • 我已经创建了持久卷来手动创建磁盘

        vi pvc.yaml
    
apiVersion: v1
kind: PersistentVolumeClaim   
metadata:
  name: azure-managed-disk-pvc
spec:
  accessModes:
 - ReadWriteOnce
  storageClassName: azuredisk-premium-retain
  resources:
    requests:
      storage: 50GiB

在 pvc 文件中,我将存储增加到 50GiB

要部署 PVC,请使用以下命令

      kubectl apply -f pvc.yaml
      kubectl get pvc   
  • 我已经创建了用于安装卷的 pod

            vi pod.yaml
    
kind: Pod     
apiVersion: v1
metadata:     
  name: newpod      #pod name
spec:
  containers:
 - name: newpod
    image: nginx:latest      
    volumeMounts:
    - mountPath: "/mnt/azure"   # mounting the volume
      name: volume
  volumes:
 - name: volume
    persistentVolumeClaim:   
      claimName: azure-managed-disk-pvc

部署 pod

     kubectl apply -f pod.yaml
     kubectl get pods
    
  • 部署 pvc_file 后转到>门户网站>磁盘> 使用您创建的 pvc_name 搜索,磁盘将随着创建的增加而增加50GiB
  • 以前是 30GiB 现在增加到 50GiB

笔记:一旦磁盘大小增加,我们就无法减小磁盘大小

参考:MS-DOC

【讨论】:

    猜你喜欢
    • 2020-10-17
    • 1970-01-01
    • 2015-12-05
    • 2017-12-08
    • 1970-01-01
    • 2017-11-18
    • 2021-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多