首页 > 解决方案 > Kubernetes Pod 命名规则

问题描述

在我的 kubernetes 集群的安装过程中,我遇到了命名 pod 的问题。
如何将部署它的节点的名称添加到容器的名称中?

我的守护程序集 yaml 的示例:

.... 
spec:
  template:
    spec:
      name: CONTAINER-NAME-HOST-NAME
....

标签: kuberneteskubernetes-pod

解决方案


命名约定属于 DNS 标签的RFC 1123 定义

Starting from v1.4 names must not be longer than 253 characters.

Name should be expressed by the regular expression: [a-z0-9]([-a-z0-9]*[a-z0-9])?

Underscore "_" is not allowed.

您可以在 GitHub 中查看适用的代码,用于检查容器名称定义可接受的名称


推荐阅读