Reference Reuse existing Persistent Volume
Background
Prod env upgrade failed, rolled back leads to historical monitoring data lost. The root cause is old PVC was removed accidently thus the corresponding PV got released, thanksfully the PV reclaim policy is retain
so the data on disk was still preserved.
这里和以前遇到的不同的地方是使用了storage class, PV 定义中有claimRef
去做绑定.
Question How to access the historical data on released PV? 显而易见需要重新bound.
Solution
The PV is actually provisioned dynamically by custom storage class gce-regional-ssd
, in its definition, it is preserved for specific PVC by specifying the claimRef
field:
1 | claimRef: |
Since the PVC monitoring-alertmanager
is alreay used another PV, to make this one available, kubectl edit to remove the uid
and resourceVersion
, modify the name
, save and quit:
1 | claimRef: |
For now the PV becomes available only to PVC which is named monitoring-alertmanager-old
. Or if you set claimRef
to empty, PV will open to all PVCs.
Then creating that PVC to consume the PV (binding):
1 | apiVersion: v1 |
Then mount the PVC to your target resource to access the data.
其实如果describe PV, 可以找到在GCE中具体的Persistent Disk (under Compute Engine), 保险起见可以先snapshot 该persistent disk再做其他操作:
1 | Source: |