Asking for help? Comment out what you need so we can get more information to help you!
Cluster information:
Kubernetes version: 1.18.20
Cloud being used: put bare-metal
Installation method: Self-developed tools
Host OS: Centos7
CNI and version: Calico 3.18.4
CRI and version: docker
You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.
Because of the company’s needs, I need to change the reclaimpolicy
attribute value of the storage class in the online k8s cluster from Delete
to Retain
.
But when I update and save it through kubectl edit
, it shows that updating this field is prohibited.
Some sample information is as follows
# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 1y
# kubectl get pvc -n localtest
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
redis-data-drc-redis-cluster-0-0 Bound pvc-ba672bea-f80b-4f3f-a536-2975e24bbd13 5Gi RWO local-path 30d
redis-data-drc-redis-cluster-0-1 Bound pvc-8cbfc2d3-60e8-46d0-85c2-e8ba3de428fd 5Gi RWO local-path 30d
redis-data-drc-redis-cluster-1-0 Bound pvc-72c9f23b-bf11-4b6e-87d3-f67e52a7ed51 5Gi RWO local-path 30d
redis-data-drc-redis-cluster-1-1 Bound pvc-6c850fca-cd19-4e39-ba89-6a8f08ca0b24 5Gi RWO local-path 30d
redis-data-drc-redis-cluster-2-0 Bound pvc-a2b4430d-74b2-494a-a849-2ae34b792fb7 5Gi RWO local-path 30d
redis-data-drc-redis-cluster-2-1 Bound pvc-14e1021c-c3af-4870-a7d7-89b39b3ab691 5Gi RWO local-path 30d
# kubectl get pv | grep redis
pvc-14e1021c-c3af-4870-a7d7-89b39b3ab691 5Gi RWO Delete Bound localtest/redis-data-drc-redis-cluster-2-1 local-path 30d
pvc-53d9d22b-cd17-4e6a-b4fa-260524c1993e 1Gi RWO Delete Bound default/redis-standalone-redis-standalone-0 local-path 657d
pvc-6c850fca-cd19-4e39-ba89-6a8f08ca0b24 5Gi RWO Delete Bound localtest/redis-data-drc-redis-cluster-1-1 local-path 30d
pvc-72c9f23b-bf11-4b6e-87d3-f67e52a7ed51 5Gi RWO Delete Bound localtest/redis-data-drc-redis-cluster-1-0 local-path 30d
pvc-8cbfc2d3-60e8-46d0-85c2-e8ba3de428fd 5Gi RWO Delete Bound localtest/redis-data-drc-redis-cluster-0-1 local-path 30d
pvc-a2b4430d-74b2-494a-a849-2ae34b792fb7 5Gi RWO Delete Bound localtest/redis-data-drc-redis-cluster-2-0 local-path 30d
pvc-ba672bea-f80b-4f3f-a536-2975e24bbd13 5Gi RWO Delete Bound localtest/redis-data-drc-redis-cluster-0-0 local-path 30d
How can I update the reclaimpolicy
attribute value without affecting the service.
I searched for resources and found that it was said to force replacement through the resource list file. The example is as follows
kubectl replace -f new-sc.yaml --force
Is this the best solution? If so, do I need to modify some of the configurations of both pvc and pv? If not, please provide your proposal. looking forward to your help.