简体   繁体   English

kubectl delete namespace 命令是否也删除关联的存储类?

[英]Does kubectl delete namespace command deletes associated storageclasses also?

I am new to Kube.netes, and have a question about it.我是 Kube.netes 的新手,对此有疑问。

When we create a statefulset, it gets associated with its PVC and the PVC will be associated a storageclass.当我们创建一个有状态集时,它会与其 PVC 相关联,而 PVC 将与一个存储类相关联。

So when we execute command "kubectl delete namespace", should it delete the storageclasses also?那么当我们执行命令“kubectl delete namespace”时,它是否也应该删除存储类?

PS The cluster is running on AWS. PS 集群在 AWS 上运行。

Not All Objects are in a Namespace 并非所有对象都在命名空间中

Most Kubernetes resources (eg pods, services, replication controllers, and others) are in some namespaces. 大多数Kubernetes资源(例如pod,服务,复制控制器和其他资源)都位于某些命名空间中。 And low-level resources, such as nodes and persistentVolumes, are not in any namespace. 而且低级资源(例如节点和persistentVolumes)不在任何命名空间中。 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: 尝试运行$ kubectl get storageclass --all-namespaces ,您会注意到甚至没有名称空间的指示:

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. 因此,我从来没有关注过,但是我相信,如果删除命名空间,则Storage类对象将不会发生任何事情。

Update: 更新:

I created a namespace class "paolo" the following StorageClass: 我在以下StorageClass中创建了一个名称空间类“ paolo”:

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 我没有收到任何错误,我删除了名称空间paolo,并且正如预期的那样,StorageClass仍然存在

My test has been performed on Google Cloud Platform. 我的测试已在Google Cloud Platform上执行。

kubectl api-resources --namespaced=false

Above commnd will list all the resources that are not in namespace.以上 commnd 将列出所有不在命名空间中的资源。 You should see StorageClasses here.您应该在此处看到 StorageClasses。 在此处输入图像描述

Deleting any namespace will not delete storageclasses.删除任何命名空间都不会删除存储类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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