命名空间
一句话解释
命名空间是 Kubernetes feature 那个分组 resources 到 named, isolated 虚拟 cluster 在内 physical cluster.
用大白话说
Namespace 是一种way to divide a single Kubernetes cluster into multiple virtual clusters。 Resources in different namespaces are isolated from each other — you can have a Pod named "my-app" in both the "dev" and "prod" namespaces without conflict.
Namespaces are useful for: environment separation (dev, staging, prod in one cluster), team isolation (team-a, team-b), and resource quotas (limiting how much CPU/memory each namespace can use).
By default, Kubernetes has three namespaces: 默认 (where resources go if no namespace is specified), kube-系统 (Kubernetes internal components), and kube-公共 (publicly readable resources).
示例
# Create a new namespace
kubectl create namespace my-team
# Deploy to a specific namespace
kubectl apply -f deployment.yaml -n my-team
# List pods in a namespace
kubectl get pods -n my-team这些 commands 创建命名空间, 部署 resources 到它, and 列表 pods 在内它.
工作原理
- 你创建命名空间使用
kubectl create namespace. - You specify the namespace in your resource metadata or via the -n flag.
- Resources in different namespaces are isolated and can have the same names.
- You can set ResourceQuotas to limit usage per namespace.
常见混淆
容易混淆的对象: 节点
关键区别: 命名空间是 logical division 的 resources 在内 cluster; 节点是 physical or 虚拟 machine in cluster.
相关术语
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。