首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在kubernetes状态中设置pod的自定义原始编号设置非默认值0

在kubernetes状态中设置pod的自定义原始编号设置非默认值0
EN

Stack Overflow用户
提问于 2019-07-26 14:11:23
回答 2查看 133关注 0票数 0

在Kubernetes statefulset中,序数以0 --> N开头。是否可以将起始序数设置为自定义数字。

代码语言:javascript
复制
redis-cluster-10   1/1     Running   0          12h
redis-cluster-11   1/1     Running   2          17h
redis-cluster-12   1/1     Running   0          17h
redis-cluster-13   1/1     Running   0          17h
redis-cluster-14   1/1     Running   2          17h
redis-cluster-15   1/1     Running   0          17h
EN

回答 2

Stack Overflow用户

发布于 2019-07-26 14:42:03

不是的。它不支持box.you之外的可能必须自定义状态集控制器。

票数 0
EN

Stack Overflow用户

发布于 2019-07-26 16:26:10

我想这是你可能会感兴趣的部分:

https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/statefulset/stateful_set_utils.go

代码语言:javascript
复制
// getParentNameAndOrdinal gets the name of pod's parent StatefulSet and pod's ordinal as extracted from its Name. If
// the Pod was not created by a StatefulSet, its parent is considered to be empty string, and its ordinal is considered
// to be -1.
func getParentNameAndOrdinal(pod *v1.Pod) (string, int) {
    parent := ""
    ordinal := -1
    subMatches := statefulPodRegex.FindStringSubmatch(pod.Name)
    if len(subMatches) < 3 {
        return parent, ordinal
    }
    parent = subMatches[1]
    if i, err := strconv.ParseInt(subMatches[2], 10, 32); err == nil {
        ordinal = int(i)
    }
    return parent, ordinal
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57214090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档