Disable delete namespace - Kubernetes

Viewed 4299

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

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.

Related