Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable delete namespace - Kubernetes

I created a namespace called qc for qc environment.

apiVersion: v1
kind: Namespace
metadata:
  name: {{ .Values.namespace.name | quote }}

kubectl create -f namespace.yaml

But I can delete this namespace anytime by running kubectl delete namespace qc.

How can I disable to delete user created namespaces?

Thank you

like image 358
Gayan Avatar asked Sep 27 '17 00:09

Gayan


People also ask

How do I permanently delete namespace in Kubernetes?

To force delete a Kubernetes namespace, remove the finalizer from the namespace's configuration. The finalizer is a Kubernetes resource whose purpose is to prohibit the force removal of an object.

What happens when you delete namespace in Kubernetes?

There's an optional field finalizers , which allows observables to purge resources whenever the namespace is deleted. Keep in mind that if you specify a nonexistent finalizer, the namespace will be created but will get stuck in the Terminating state if the user tries to delete it.

Does deleting namespace delete pods?

Deleting a namespace sometimes leaves orphaned deployment and pods which can't be deleted #36891. area/api. area/apiserver area/HA lifecycle/rotten.


1 Answers

You do not want disable deletion of Namespaces for your kubernetes-admin user, although it could be possible. If there are other people or services interacting with your cluster, you need to define Users and/or Service Accounts for them and bind Cluster Roles to them, whitelisting their permissions. Have a look at Users in Kubernetes and Using RBAC Authorization in the official Kubernetes Documentation.

like image 70
Simon Tesar Avatar answered Oct 04 '22 12:10

Simon Tesar