我是靠谱客的博主 鲤鱼大地,这篇文章主要介绍K8S 扩容storageclass类型的PVC,现在分享给大家,希望可以做个参考。

扩容之前最好先取消挂载,(处于挂载状态能否扩容没试过)
以下配置方法在阿里云/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
    

扩容完成,验证。

最后

以上就是鲤鱼大地最近收集整理的关于K8S 扩容storageclass类型的PVC的全部内容,更多相关K8S内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(134)

评论列表共有 0 条评论

立即
投稿
返回
顶部