扩容之前最好先取消挂载,(处于挂载状态能否扩容没试过)
以下配置方法在阿里云/Azure云 验证过

  1. 先查看storageclass是否配置了允许动态扩容,看storageclass是否存在allowVolumeExpansion字段并且值为true。
    一般云厂商提供的storageclass都是允许动态扩容的。

    #kubectl get storageclass default -o yaml  
    allowVolumeExpansion: true
    
  2. 查看谁在使用要扩容的pv,查看pvc的状态

    #kubectl get pv
    #kubectl -n harbor get pvc
    
  3. 获取pvc的yaml(或者直接编辑pvc的配置 kubectl -n harbor edit pvc harbor-harbor-registry 修改storage: 200Gi的大小)

    # kubectl -n harbor get pvc  harbor-harbor-registry  -o yaml > harbor-harbor-registry-pvc.yaml
    
  4. 修改yaml文件,调整pvc大小,比如由原来的50G调整到200Gi

     ```
     spec:
       accessModes:
       - ReadWriteOnce
       resources:
         requests:
           storage: 200Gi
       storageClassName: managed-premium
       volumeMode: Filesystem
       volumeName: pvc-12de06a7-38f0-41d3-a35f-26324a91fc32
     ```
    
  5. 停止使用pvc的pod

    #kubectl  -n harbor scale deployment/harbor-harbor-registry --replicas=0
    
  6. 应用新的调整后的yaml文件

    #kubectl -n harbor apply -f harbor-harbor-registry-pvc.yaml
    
  7. 启动pod

      #kubectl  -n harbor scale deployment/harbor-harbor-registry --replicas=1
    

扩容完成,验证。

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐