troubleshoot:PVC动态扩容报错
一.问题描述
动态扩容PVC的时候报错(kubectl edit pvc pvcname):“error: persistentvolumeclaims "pvvolume" could not be patched: persistentvolumeclaims "pvvolume" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize”
二.解决方法
配置一个10M大小的pvc,关于PVC的详细内容,请查看博客《Kubernetes(k8s)存储管理之数据卷volumes(四):持久卷Persistent Volume》https://www.cnblogs.com/renshengdezheli/p/16972289.html
[student@vms20 ~]$ vim 13.yaml
[student@vms20 ~]$ cat 13.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvvolume
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 10Mi
storageClassName: csi-hostpath-sc
创建PVC
[student@vms20 ~]$ kubectl apply -f 13.yaml
persistentvolumeclaim/pvvolume created
[student@vms20 ~]$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvvolume Bound pvc-09b90084-aa96-4e10-a124-79c9af98ccc0 10Mi RWO csi-hostpath-sc 10s
[student@vms20 ~]$ kubectl get pvc -o wide
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE VOLUMEMODE
pvvolume Bound pvc-09b90084-aa96-4e10-a124-79c9af98ccc0 10Mi RWO csi-hostpath-sc 14s Filesystem
把PVC挂载到pod上,并创建pod
[student@vms20 ~]$ vim 13pod.yaml
[student@vms20 ~]$ cat 13pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: web-server
spec:
containers:
- name: myfrontend
image: nginx
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: mypvc
volumes:
- name: mypvc
persistentVolumeClaim:
claimName: pvvolume
[student@vms20 ~]$ kubectl apply -f 13pod.yaml
pod/web-server created
[student@vms20 ~]$ kubectl get pod | grep web-server
web-server 1/1 Running 0 20s
修改pvc的容量为70Mi,PVC动态扩容报错如下:
[student@vms20 ~]$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvvolume Bound pvc-09b90084-aa96-4e10-a124-79c9af98ccc0 10Mi RWO csi-hostpath-sc 14m
#动态扩容PVC报错
[student@vms20 ~]$ kubectl edit pvc pvvolume --record
Flag --record has been deprecated, --record will be removed in the future
error: persistentvolumeclaims "pvvolume" could not be patched: persistentvolumeclaims "pvvolume" 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-857302533.yaml` to try this update again.
解决方法:要支持动态扩容需要满足两个条件:
- 后端底层存储支持卷扩展(后端存储保证足够资源) ;
- 需要在StorageClass对象中设置allowVolumeExpansion为true。
可以看到storageclass此时ALLOWVOLUMEEXPANSION参数为false。
[student@vms20 ~]$ kubectl get storageclass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
csi-hostpath-sc hostpath.csi.k8s.io Delete Immediate false 277d
编辑csi-hostpath-sc,把ALLOWVOLUMEEXPANSION修改为true
#添加参数allowVolumeExpansion: true
#######
# 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.
#
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"csi-hostpath-sc"},"parameters":{"archiveOnDelete":"false"},"provisioner":"hostpath.csi.k8s.io"}
creationTimestamp: "2021-11-04T10:54:48Z"
name: csi-hostpath-sc
resourceVersion: "177035"
uid: a594f8fd-9c3d-49d3-85a4-085c89a7bb1c
parameters:
archiveOnDelete: "false"
provisioner: hostpath.csi.k8s.io
reclaimPolicy: Delete
volumeBindingMode: Immediate
#######
[student@vms20 ~]$ kubectl edit storageclass csi-hostpath-sc
storageclass.storage.k8s.io/csi-hostpath-sc edited
#现在ALLOWVOLUMEEXPANSION变为true了
[student@vms20 ~]$ kubectl get storageclass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
csi-hostpath-sc hostpath.csi.k8s.io Delete Immediate true 277d
再次PVC动态扩容
[student@vms20 ~]$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvvolume Bound pvc-09b90084-aa96-4e10-a124-79c9af98ccc0 10Mi RWO csi-hostpath-sc 25m
#现在pvc动态扩容:将所有位置的capacity:storage:10Mi修改为70Mi
[student@vms20 ~]$ kubectl edit pvc pvvolume --record
Flag --record has been deprecated, --record will be removed in the future
persistentvolumeclaim/pvvolume edited
#PVC动态扩容成功
[student@vms20 ~]$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvvolume Bound pvc-09b90084-aa96-4e10-a124-79c9af98ccc0 70Mi RWO csi-hostpath-sc 27m
自此,PVC动态扩容成功。
troubleshoot:PVC动态扩容报错的更多相关文章
- LVM XFS增加硬盘分区容量最后一步的时候动态扩容报错
在我们lvextend扩容完之后,想动态扩容时出现错误.我们可以用以下命令来进行操作. 若不是xfs我们可以用resize2fs,这里报错了 [root@Mysql01-213-66 ~]# resi ...
- C语言扩展动态内存报错:realloc(): invalid next size: 0x0000000002365010 ***
晚上被这个内存扩展崩溃的问题折腾的有点崩溃,当答案揭晓的那一刻,恍然大悟,原来如此简单. 练习题目:输入一个字符串,根据字母进行排序,说白了就是一个简单的冒泡 #include <stdio.h ...
- Spring Data Solr创建动态域报错:org.springframework.data.solr.UncategorizedSolrException
今天在项目中使用Spring Data Solr导入动态域数据报错, 控制台打印错误信息如下 Exception in thread "main" org.springframew ...
- lvm逻辑卷扩容报错解决
报错: [root@centos21 space]# resize2fs /dev/centos/root resize2fs (-Dec-) resize2fs: Bad magic number ...
- spark on yarn 动态资源分配报错的解决:org.apache.hadoop.yarn.exceptions.InvalidAuxServiceException: The auxService:spark_shuffle does not exist
组件:cdh5.14.0 spark是自己编译的spark2.1.0-cdh5.14.0 第一步:确认spark-defaults.conf中添加了如下配置: spark.shuffle.servic ...
- iOS 加载动态库报错问题
dyld: Library not loaded: @rpath Referenced from: Reason: no suitable image found. Did find: 要么使用静态 ...
- Qt打开外部程序和文件夹需要注意的细节(Qt调用VC写的动态库,VC需要用C的方式输出函数,否则MinGW32编译过程会报错)
下午写程序中遇到几个小细节,需要在这里记录一下. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 QProcess *process = new QProcess(this ...
- eclipse 创建maven 项目 动态web工程报错
Eclipse 创建maven 项目 动态web工程 注:Eclipse版本为(Version: Mars.1 Release (4.5.1))maven版本为(apache-maven-3.3.9) ...
- Struts1应用、实现简单计算器、使用DispatchAction、显示友好的报错信息、使用动态Form简化开发
实现简单的支持加.减.乘.除的计算器 复制一份Struts1Demo修改:Struts1Calc 方案1: Struts1Calc 创建ActionForm: CalcForm extends Act ...
- vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined
vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined 借鉴了该大神的文 ...
随机推荐
- 安装ceph (快速) 步骤一:预检
官网地址:http://docs.ceph.org.cn/start/ 预检 安装一个 ceph-deploy 管理节点和一个三节点的Ceph 存储集群来研究 Ceph 的基本特性.这篇预检会帮你准备 ...
- 在Portainer上管理其他docker主机(这只是其中一种方式),另一种方式看这个文档:使用Portainer管理其他主机的docker应用有两种方式
其他主机开启远程连接docker端口 需要设置一下2375端口的监听.通过修改docker配置文件方式进行监听. 修改配置文件修改监听端口 使用Centos7安装的docker,所以下面的配置是适用于 ...
- 10_SpringBoot更加详细
一. 原理初探 1.1 自动装配 1.1.1 pom.xml spring-boot-dependencies: 核心依赖在父工程中 我们在写入或者引入一些SpringBoot依赖的时候, 不需要指定 ...
- Python实现给图片加水印功能
前言 最近忙得连轴转,很久没更新博客了,代码倒是没啥写,积累了好些东西,接下来一有时间就来更新吧~ 本文记录使用Python实现给图片添加水印的功能实现过程 先看效果 把公众号的封面作为素材 原图是这 ...
- typora基础和计算机五大组成部分
typora typora软件 是一款适合于IT行业文本编辑器,笔记,当下来说,非常火爆,可以使用多种语言,python java... 安装的时候路径选择可以设置一些简单便于后续查找的文件路 ...
- P1099 [NOIP2007 提高组] 树网的核 (树的直径)
题目的意思就是在直径上找一段距离不超过s的路径,使该路径的偏心距最小. 求出直径之后,显然我们可以用双指针扫描一段合法路径.设u1,u2...ut是直径上的点,d[ui]表示从ui出发能到达的最远距离 ...
- MatrixOne从入门到实践02——源码编译
MatrixOne从入门到实践--源码编译 在部署MatrixOne前,我们可能会比较纠结使用哪个版本合适,MatrixOne在github上有各个版本的Releases,包含源码包和适用于Lin ...
- 一天十道Java面试题----第二天(HashMap和hashTable的区别--------》sleep、wait、join)
这里是参考B站上的大佬做的面试题笔记.大家也可以去看视频讲解!!! 文章目录 11.HashMap和HashTable的区别及底层实现 12.ConcurrentHashMap原理简述,jdk7和jd ...
- 如何在IDEA中创建Module、以及怎样在IDEA中删除Module?
文章目录 1.为何要使用Module? 2.Module的创建 3.如何从硬盘上删除module 1.为何要使用Module? 目前主流的大型项目都是分布式部署的,结构类型这种多Module结构.不同 ...
- go-zero docker-compose 搭建课件服务(六):完善jwt鉴权和返回结构
0.转载 go-zero docker-compose 搭建课件服务(六):完善jwt鉴权和返回结构 0.1源码地址 https://github.com/liuyuede123/go-zero-co ...