惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 勤劳の洗碗机

pyinstaller打包exe故障解析 curl 访问k8s api k8s 之HPA应用 statefulset 及storageclass hadoop 伪分布式 完全分布式 及HA部署 LDAP部署及实践 docker 制作自己的mysql镜像 k8s 压测工具之perf-test mysql相关(三)、主从复制 shell执行mysql脚本 分布式minio image-syncer 误删libc.so.6文件补救 docker 使用bind k8s备份工具之velero jmeter使用 docker 制作ssh镜像 docker 制作自定义的nginx镜像 docker部署sharding-proxy
动态扩容pvc
勤劳の洗碗机 · 2020-07-17 · via 博客园 - 勤劳の洗碗机

 最开始的10g太小了,现在想扩容pv空间

1、kubernetes 1.11版本中开始支持pvc创建后的扩容

先查看storageclass是否配置了动态扩容,主要看storageclass是否存在allowVolumeExpansion字段

[root@192 ~]# kubectl  get storageclass default -oyaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: default
parameters:
  archiveOnDelete: "false"
provisioner: nfs-client-provisioner-default
reclaimPolicy: Delete
volumeBindingMode: Immediate
[root@192 ~]# 

可以看到并没有allowVolumeExpansion,此时是不支持动态扩容的,可以扩一下测试看看

[root@192 ~]# kubectl edit pvc -n leijun-mysql comom-store-column-03-24 
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: comom-store-column-03-24
  namespace: default
spec:
  accessModes:
  - ReadWriteMany
  dataSource: null
  resources:
    requests:
      storage: 50Gi
  volumeName: pvc-24fc01a0-6d9b-11ea-9107-b8ca3a62236c
status:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 10Gi
  phase: Bound
"/tmp/kubectl-edit-fkm33.yaml" 38L, 1180C written
error: persistentvolumeclaims "comom-store-column-03-24" could not be patched: persistentvolumeclaims "comom-store-column-03-24" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize
You can run `kubectl replace -f /tmp/kubectl-edit-fkm33.yaml` to try this update again.
[root@192 ~]# 
kubectl edit pvc -n leijun-mysql comom-store-column-03-24
修改storage 字段再保存,报错了,表示不支持动态扩容

2、给storageclass添加allowVolumeExpansion字段

[root@192 ~]# kubectl  edit  storageclass default    

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: default
parameters:
  archiveOnDelete: "false"
provisioner: nfs-client-provisioner-default
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true   #增加该字段表示允许动态扩容
~                                                                                                                                                
~                                                                                                                                                
~                                                                                                                                                
~                                                                                                                                                
~                                                                                                                                                
~                                                                                                                                                
~                                                                                                                                                
"/tmp/kubectl-edit-x0fyj.yaml" 24L, 738C written
storageclass.storage.k8s.io/default edited
[root@192 ~]# 

3、再次修改pvc   spec.resources.requests.storage字段

[root@192 ~]# kubectl edit pvc comom-store-column-03-24
spec:
  accessModes:
  - ReadWriteMany
  dataSource: null
  resources:
    requests:
      storage: 30Gi
  volumeName: pvc-24fc01a0-6d9b-11ea-9107-b8ca3a62236c
status:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 10Gi
  phase: Bound
"/tmp/kubectl-edit-mibh7.yaml" 38L, 1180C written
persistentvolumeclaim/comom-store-column-03-24 edited
[root@192 ~]#