How does the kube-system namesspace get created

12/4/2020

I know that the kube-system pods (API server, etcd, scheduler, controller manager) get created using the static pod deployment method. If you look at the manifests, you will see that in the metadata the namespace is set to kube-system, since you can't create pods in a non existing namespace, how does the kube-system namespace gets created initially and where the definition of this object is persisted since etcd isn't deployed yet.

-- Yassine359
kubernetes
namespaces

1 Answer

12/4/2020

From this GCP blog:

In most Kubernetes distributions, the cluster comes out of the box with a Namespace called “default.” In fact, there are actually three namespaces that Kubernetes ships with: default, kube-system (used for Kubernetes components), and kube-public (used for public resources).

This means that k8s has these 3 namespaces out of the box and that they cannot be deleted (unlike any other namespaces that are created by a user):

$ kubectl delete ns default
Error from server (Forbidden): namespaces "default" is forbidden: this namespace may not be deleted
$ kubectl delete ns kube-system
Error from server (Forbidden): namespaces "kube-system" is forbidden: this namespace may not be deleted
-- Matt
Source: StackOverflow