Created
December 8, 2019 02:32
-
-
Save nevermosby/67cba7ced7c9368062ad4cb15750f11a to your computer and use it in GitHub Desktop.
manually update kubernetes PV path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # 1. delete pv, pv会变成terminating状态 | |
| kubectl delete pv [pv-name] | |
| # 2. delete pvc, pvc会变成terminating状态 | |
| kubectl delete pvc [pvc-name-related-to-pv] | |
| # 3. patch pvc to remove protection, 具体可以看这里:https://stackoverflow.com/questions/51358856/kubernetes-cant-delete-persistentvolumeclaim-pvc,然后pv和pvc就被干净删除了 | |
| kubectl patch pvc [pvc-name] -p '{"metadata":{"finalizers": []}}' --type=merge | |
| # 4. update the local path and recreate pv, 因为我用了storageclass+volumeClaimTemplates,所以也会自动创建pvc | |
| kubectl apply -f pv.yaml | |
| # 5. restart pod, 如果你跟我一样用了statefulset,只要delete pod即可 | |
| kubectl delete [pod-name] | |
| # | |
| # do the loop if you have more than 1 pv need to update | |
| # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment