简体   繁体   中英

Does kubectl delete namespace command deletes associated storageclasses also?

I am new to Kube.netes, and have a question about it.

When we create a statefulset, it gets associated with its PVC and the PVC will be associated a storageclass.

So when we execute command "kubectl delete namespace", should it delete the storageclasses also?

PS The cluster is running on AWS.

Not All Objects are in a Namespace

Most Kubernetes resources (eg pods, services, replication controllers, and others) are in some namespaces. And low-level resources, such as nodes and persistentVolumes, are not in any namespace. Source.

The storage class is not a namespace object. Try to run $ kubectl get storageclass --all-namespaces and you will notice that there is not even the indication of the namespace:

xxx@xxxxx.xx:~$ kubectl get storageclass --all-namespaces

NAMESPACE   NAME                 PROVISIONER
            slow                 kubernetes.io/gce-pd
            standard (default)   kubernetes.io/gce-pd

Therefore I have never paid attention, but I believe that if you delete a namespace nothing will happen to the Storage class objects.

Update:

I created a namespace class "paolo" the following StorageClass:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: slow
  namespace: paolo
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  zones: us-central1-a, us-central1-b

I didn't received any error, I deleted the namespace paolo and as expected the StorageClass was still there

My test has been performed on Google Cloud Platform.

kubectl api-resources --namespaced=false

Above commnd will list all the resources that are not in namespace. You should see StorageClasses here. 在此处输入图像描述

Deleting any namespace will not delete storageclasses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM