Kubernetes Namespace 命名规则
Kubernetes 大约 3257 字查看帮助
name
kubectl explain namespaces.metadata.name
namespace
kubectl explain namespaces.metadata.namespace
输出
name
PS C:\Users\fendoudebb> kubectl explain namespaces.metadata.name
KIND: Namespace
VERSION: v1
FIELD: name <string>
DESCRIPTION:
Name must be unique within a namespace. Is required when creating
resources, although some resources may allow a client to request the
generation of an appropriate name automatically. Name is primarily intended
for creation idempotence and configuration definition. Cannot be updated.
More info: http://kubernetes.io/docs/user-guide/identifiers#names
namespace
PS C:\Users\fendoudebb> kubectl explain namespaces.metadata.namespace
KIND: Namespace
VERSION: v1
FIELD: namespace <string>
DESCRIPTION:
Namespace defines the space within which each name must be unique. An empty
namespace is equivalent to the "default" namespace, but "default" is the
canonical representation. Not all objects are required to be scoped to a
namespace - the value of this field for those objects will be empty.
Must be a DNS_LABEL. Cannot be updated. More info:
http://kubernetes.io/docs/user-guide/namespaces
命名规则
Note: Avoid creating namespaces with the prefix kube-, since it is reserved for Kubernetes system namespaces.
- 不能以
kube-
作为前缀。 - 最多
63
个字符。 - 只能是小写字母和数字,或者
-
中划线。 - 首字符必须是字母或数字。
- 尾字符必须是字母或数字。
- 无法更新。
示例
说明:虽然可以创建kube-
为前缀的命名空间,但官方不建议这么做。
备注:命名空间的命名规则可以使用正则[a-z0-9]([-a-z0-9]*[a-z0-9])?
和最大63
字符来约束。
PS C:\Users\fendoudebb> kubectl create namespace kube-test
namespace/kube-test created
PS C:\Users\fendoudebb> kubectl create namespace 123
namespace/123 created
PS C:\Users\fendoudebb> kubectl create namespace 789-
The Namespace "789-" is invalid:
* metadata.name: Invalid value: "789-": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
* metadata.labels: Invalid value: "789-": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
PS C:\Users\fendoudebb> kubectl create namespace 123456789012345678901234567890123456789012345678901234567890123
namespace/123456789012345678901234567890123456789012345678901234567890123 created
PS C:\Users\fendoudebb> kubectl create namespace 1234567890123456789012345678901234567890123456789012345678901234
The Namespace "1234567890123456789012345678901234567890123456789012345678901234" is invalid:
* metadata.name: Invalid value: "1234567890123456789012345678901234567890123456789012345678901234": must be no more than 63 characters
* metadata.labels: Invalid value: "1234567890123456789012345678901234567890123456789012345678901234": must be no more than 63 characters
参考
https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names
阅读 681 · 发布于 2022-11-03
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Prometheus+Grafana+blackbox_exporter 监控 HTTP TCP PING ICMP阅读 2691
-
Linux yum 安装 OpenResty阅读 2458
-
JavaScript 判断 Android 还是 iOS阅读 636
-
Linux zgrep,zcat,zless,zmore 等 zutil 包命令阅读 3862
-
数据结构:哈希表阅读 1737
-
Vue v-once 组件只渲染一次阅读 505
-
Spring Boot @ConfigurationProperties 配置文件映射为对象阅读 686
-
Nginx 负债均衡的几种方式阅读 1774
-
Nginx 解决前端 CORS 跨域问题阅读 9888
-
JavaScript 监听标签页切换阅读 1376