Sub topic 2
The namespaces every cluster starts with
This chapter assumes you can run kubectl, read simple YAML, and know what Pods, Deployments, and Services are. It covers the four namespaces Kubernetes creates in every new cluster, what each one holds, and which ones you should leave alone.
Listing the starting namespaces
A new cluster is never empty. List its namespaces to see what is there:
kubectl get namespacesTypical output looks like this:
NAME STATUS AGE
default Active 12d
kube-node-lease Active 12d
kube-public Active 12d
kube-system Active 12dManaged services and add-ons may add more, such as ingress-nginx or gatekeeper-system. The four above come from Kubernetes itself.
The four initial namespaces
| Namespace | Purpose | Should you deploy here? |
|---|---|---|
| `default` | Holds objects that are created without a namespace. | Fine for experiments, not for real workloads. |
| `kube-system` | Holds objects created by the Kubernetes system. | No. |
| `kube-public` | Holds data meant to be readable by everyone, including unauthenticated clients. | No. |
| `kube-node-lease` | Holds one Lease object per node. | No. |
default
If you run kubectl apply with no namespace in the manifest and none on the command line, the object lands in default. This is convenient for learning. For real work it is a poor choice, because everything ends up mixed together and nothing signals who owns what. Create your own namespaces for teams or environments instead.
kube-system
This namespace holds the cluster's own components that run as Kubernetes objects. Depending on how the cluster was built, that usually includes CoreDNS, kube-proxy, and the control plane Pods on clusters where they run as static Pods. Deleting or editing objects here can break DNS, networking, or the whole cluster. Look at it freely, and change it only when you know why.
kubectl get pods --namespace kube-systemkube-public
This namespace is readable by all clients, including those that are not authenticated. Its main use is cluster-wide information that must be visible without credentials. A common example is the cluster-info ConfigMap, which holds the cluster's API server address and certificate authority data so new nodes can bootstrap. Do not store anything sensitive here. Most clusters never need you to add anything.
kube-node-lease
Each node has a Lease object in this namespace. The kubelet on the node renews its Lease on a short interval as a heartbeat. The control plane reads the renewals to decide whether a node is still alive. Leases are small, so heartbeats are cheap and do not strain the API server the way frequent updates to the full Node object would. You can see them with:
kubectl get leases --namespace kube-node-leaseYou will see one Lease per node, named after the node.
Common mistakes
- Deploying real workloads to
default. Quotas, access rules, and network policies are easier to apply when each team or environment has its own namespace. - Cleaning up in
kube-system. A Pod that looks unused may be a core component. Deleting it can take down DNS or networking. - Storing secrets in
kube-public. Anyone who can reach the API server may be able to read it. - Trying to delete the initial namespaces. Kubernetes protects some of them from deletion, and removing the ones it allows would harm the cluster. Treat all four as permanent.
Exercise
A teammate says a Pod in kube-system has not been touched in months and asks to delete it to tidy up. Which command would help you find out what it is first, and why is that important?
Show answer
Run kubectl describe pod <name> --namespace kube-system and check its labels, owner, and image. Pods in kube-system are usually cluster components such as CoreDNS or kube-proxy, so deleting one can break DNS or networking for every workload in the cluster.
Exercise
Which initial namespace would you inspect to check whether a node is still sending heartbeats, and which object type would you list?
Show answer
kube-node-lease, listing Lease objects with kubectl get leases --namespace kube-node-lease. Each node has one Lease that its kubelet renews regularly.