copyright | lastupdated | keywords | subcollection | ||
---|---|---|---|---|---|
|
2019-09-27 |
kubernetes, iks |
containers |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:pre: .pre} {:table: .aria-labeledby="caption"} {:codeblock: .codeblock} {:tip: .tip} {:note: .note} {:important: .important} {:deprecated: .deprecated} {:download: .download} {:preview: .preview}
{: #cleanup}
When you set up persistent storage in your cluster, you have three main components: the Kubernetes persistent volume claim (PVC) that requests storage, the Kubernetes persistent volume (PV) that is mounted to a pod and described in the PVC, and the IBM Cloud infrastructure instance, such as classic file or block storage. Depending on how you created your storage, you might need to delete all three components separately. {:shortdesc}
{: #storage_delete_options}
Removing persistent storage from your {{site.data.keyword.cloud_notm}} account varies depending on how you provisioned the storage and what components you already removed. {: shortdesc}
Is my persistent storage deleted when I delete my cluster?
During cluster deletion, you have the option to remove your persistent storage. However, depending on how your storage was provisioned, the removal of your storage might not include all storage components.
If you dynamically provisioned storage with a storage class that sets reclaimPolicy: Delete
, your PVC, PV, and the storage instance are automatically deleted when you delete the cluster. For storage that was statically provisioned, VPC Block Storage, or storage that you provisioned with a storage class that sets reclaimPolicy: Retain
, the PVC and the PV are removed when you delete the cluster, but your storage instance and your data remain. You are still charged for your storage instance. Also, if you deleted your cluster in an unhealthy state, the storage might still exist even if you chose to remove it.
How do I delete the storage when I want to keep my cluster?
When you dynamically provisioned the storage with a storage class that sets reclaimPolicy: Delete
, you can remove the PVC to start the deletion process of your persistent storage. Your PVC, PV, and storage instance are automatically removed.
For storage that was statically provisioned, VPC Block Storage, or storage that you provisioned with a storage class that sets reclaimPolicy: Retain
, you must manually remove the PVC, PV, and the storage instance to avoid further charges.
How does the billing stop after I delete my storage?
Depending on what storage components you delete and when, the billing cycle might not stop immediately. If you delete the PVC and PV, but not the storage instance in your {{site.data.keyword.cloud_notm}} account, that instance still exists and you are charged for it.
If you delete the PVC, PV, and the storage instance, the billing cycle stops depending on the billingType
that you chose when you provisioned your storage and how you chose to delete the storage.
-
When you manually cancel the persistent storage instance from the {{site.data.keyword.cloud_notm}} console or the
ibmcloud sl
CLI, billing stops as follows:- Hourly storage: Billing stops immediately. After your storage is canceled, you might still see your storage instance in the console for up to 72 hours.
- Monthly storage: You can choose between immediate cancellation or cancellation on the anniversary date. In both cases, you are billed until the end of the current billing cycle, and billing stops for the next billing cycle. After your storage is canceled, you might still see your storage instance in the console or the CLI for up to 72 hours.
- Immediate cancellation: Choose this option to immediately remove your storage. Neither you nor your users can use the storage anymore or recover the data.
- Anniversary date: Choose this option to cancel your storage on the next anniversary date. Your storage instances remain active until the next anniversary date and you can continue to use them until this date, such as to give your team time to make backups of your data.
-
When you dynamically provisioned the storage with a storage class that sets
reclaimPolicy: Delete
and you choose to remove the PVC, the PV and the storage instance are immediately removed. For hourly billed storage, billing stops immediately. For monthly billed storage, you are still charged for the remainder of the month. After your storage is removed and billing stops, you might still see your storage instance in the console or the CLI for up to 72 hours.
What do I need to be aware of before I delete persistent storage?
When you clean up persistent storage, you delete all the data that is stored in it. If you need a copy of the data, make a backup for file storage or block storage.
I deleted my storage instance. Why can I still see my instance?
After you remove persistent storage, it can take up to 72 hours for the removal to be fully processed and for the storage to disappear from your {{site.data.keyword.cloud_notm}} console or CLI.
{: #storage_remove}
Remove the PVC, PV, and the storage instance from your {{site.data.keyword.cloud_notm}} account to avoid further charges for your persistent storage. {: shortdesc}
Before you begin:
- Make sure that you backed up any data that you want to keep.
- Log in to your account. If applicable, target the appropriate resource group. Set the context for your cluster.
To clean up persistent data:
-
List the PVCs in your cluster and note the
NAME
of the PVC, theSTORAGECLASS
, and the name of the PV that is bound to the PVC and shown asVOLUME
.kubectl get pvc
{: pre}
Example output:
NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE claim1-block-bronze Bound pvc-06886b77-102b-11e8-968a-f6612bb731fb 20Gi RWO ibmc-block-bronze 78d claim-file-bronze Bound pvc-457a2b96-fafc-11e7-8ff9-b6c8f770356c 4Gi RWX ibmc-file-bronze-retain 105d claim-file-silve Bound pvc-1efef0ba-0c48-11e8-968a-f6612bb731fb 24Gi RWX ibmc-file-silver 83d
{: screen}
-
Review the
ReclaimPolicy
andbillingType
for the storage class.kubectl describe storageclass <storageclass_name>
{: pre}
If the reclaim policy says
Delete
, your PV and the physical storage are removed when you remove the PVC. Note that VPC Block Storage is not removed automatically, even if you used aDelete
storage class to provision the storage. If the reclaim policy saysRetain
, or if you provisioned your storage without a storage class, then your PV and physical storage are not removed when you remove the PVC. You must remove the PVC, PV, and the physical storage separately.If your storage is charged monthly, you still get charged for the entire month, even if you remove the storage before the end of the billing cycle. {: important}
-
Remove any pods that mount the PVC.
-
List the pods that mount the PVC.
kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.volumes[*]}{.persistentVolumeClaim.claimName}{" "}{end}{end}' | grep "<pvc_name>"
{: pre}
Example output:
blockdepl-12345-prz7b: claim1-block-bronze
{: screen}
If no pod is returned in your CLI output, you do not have a pod that uses the PVC.
-
Remove the pod that uses the PVC. If the pod is part of a deployment, remove the deployment.
kubectl delete pod <pod_name>
{: pre}
-
Verify that the pod is removed.
kubectl get pods
{: pre}
-
-
Remove the PVC.
kubectl delete pvc <pvc_name>
{: pre}
-
Review the status of your PV. Use the name of the PV that you retrieved earlier as
VOLUME
.kubectl get pv <pv_name>
{: pre}
When you remove the PVC, the PV that is bound to the PVC is released. Depending on how you provisioned your storage, your PV goes into a
Deleting
state if the PV is deleted automatically, or into aReleased
state, if you must manually delete the PV. Note: For PVs that are automatically deleted, the status might briefly sayReleased
before it is deleted. Rerun the command after a few minutes to see whether the PV is removed. -
If your PV is not deleted, manually remove the PV.
kubectl delete pv <pv_name>
{: pre}
-
Verify that the PV is removed.
kubectl get pv
{: pre}
-
{: #sl_delete_storage}List the physical storage instance that your PV pointed to and note the
id
of the physical storage instance.Classic File Storage:
ibmcloud sl file volume-list --columns id --columns notes | grep <pv_name>
{: pre} Classic Block Storage:
ibmcloud sl block volume-list --columns id --columns notes | grep <pv_name>
{: pre} VPC Block Storage:
ibmcloud is volumes | grep <pv_name>
{: pre}
Example output for file storage:
id notes 12345678 {"plugin":"ibm-file-plugin-5b55b7b77b-55bb7","region":"us-south","cluster":"aa1a11a1a11b2b2bb22b22222c3c3333","type":"Endurance","ns":"default","pvc":"mypvc","pv":"pvc-d979977d-d79d-77d9-9d7d-d7d97ddd99d7","storageclass":"ibmc-file-gold"}
{: screen}
Understanding the Notes field information:
"plugin":"ibm-file-plugin-5b55b7b77b-55bb7"
: The storage plug-in that the cluster uses."region":"us-south"
: The region that your cluster is in."cluster":"aa1a11a1a11b2b2bb22b22222c3c3333"
: The cluster ID that is associated with the storage instance."type":"Endurance"
: The type of file or block storage, eitherEndurance
orPerformance
."ns":"default"
: The namespace that the storage instance is deployed to."pvc":"mypvc"
: The name of the PVC that is associated with the storage instance."pv":"pvc-d979977d-d79d-77d9-9d7d-d7d97ddd99d7"
: The PV that is associated with the storage instance."storageclass":"ibmc-file-gold"
: The type of storage class: bronze, silver, gold, or custom.
-
Remove the physical storage instance.
Classic File Storage:
ibmcloud sl file volume-cancel <classic_file_id>
{: pre}
Classic Block Storage:
ibmcloud sl block volume-cancel <classic_block_id>
{: pre}
VPC Block Storage:
ibmcloud is volume-delete <vpc_block_id>
{: pre}
-
Verify that the physical storage instance is removed.
The deletion process might take up to 72 hours to complete. {: important}
Classic File Storage:
ibmcloud sl file volume-list
{: pre} Classic Block Storage:
ibmcloud sl block volume-list
{: pre} VPC Block Storage:
ibmcloud is volumes
{: pre}