What is a namespace in Linux and Kubernetes?
sobes.tech AI
Answer from AI
Namespace in Linux is a resource isolation mechanism of the kernel that allows creating separate name spaces for processes. This means that processes in one namespace see their own resources (e.g., PID, network, filesystem) and do not intersect with processes from other namespaces. This is the basis of containerization.
In Kubernetes, a namespace is a logical isolation of resources within a cluster. It allows dividing objects (pods, services, configs) between different teams or projects to avoid name conflicts and manage access.
In summary:
- Linux namespace — low-level OS resource isolation.
- Kubernetes namespace — high-level resource organization and isolation within a cluster.
Example of Linux namespace: running a process in a separate PID namespace so that it only sees itself as PID 1.
unshare --pid --fork bash
In Kubernetes, a namespace is used in manifests:
apiVersion: v1
kind: Pod
metadata:
name: mypod
namespace: dev
spec:
containers:
- name: app
image: nginx
This helps manage and isolate resources in large systems.