以下是我的kubernetes环境中由部署创建的所有副本集(使用部署时,它将首先创建副本集):< / p>
[root@master24 004-prometheus]# kubectl get rs --all-namespaces
NAMESPACE NAME DESIRED CURRENT READY AGE
dev test-ddd-1-0-4129700023 3 3 3 6d
dev test111-1-0-2606576459 3 3 3 6d
dev test2-1-0-568340644 3 3 0 6d
kube-system alertmanager-2876254624 0 0 0 12d
kube-system alertmanager-34609585 0 0 0 31d
kube-system alertmanager-646055916 1 1 1 12d
kube-system container-terminal-2048074043 1 1 1 26d
kube-system container-terminal-2798068035 0 0 0 26d
kube-system default-http-backend-2282004791 1 1 1 99d
kube-system elastic-hq-1088064035 0 0 0 62d
kube-system elastic-hq-143297398 1 1 1 32d
kube-system elastic-hq-2334099411 0 0 0 62d
kube-system elastic-hq-2453506004 0 0 0 62d
kube-system elastic-hq-963545625 0 0 0 35d
kube-system grafana-2729867605 1 1 1 32d
kube-system kibana-logging-2271207004 1 1 1 39d
kube-system kibana-logging-3117667162 0 0 0 65d
kube-system kube-dns-1277622866 1 1 1 103d
kube-system kube-dns-418314620 0 0 0 103d
kube-system kube-ops-view-2627512969 1 1 1 62d
kube-system kube-state-metrics-290271031 2 2 2 31d
kube-system kubernetes-dashboard-102631441 0 0 0 103d
kube-system kubernetes-dashboard-2251164715 0 0 0 102d
kube-system kubernetes-dashboard-2628062973 1 1 1 25d
kube-system kubernetes-dashboard-3038119623 0 0 0 102d
kube-system kubernetes-dashboard-4259055596 0 0 0 40d
kube-system kubernetes-dashboard-849151901 0 0 0 103d
kube-system nginx-ingress-controller-1663470174 0 0 0 65d
kube-system nginx-ingress-controller-2772479350 0 0 0 64d
kube-system nginx-ingress-controller-3812017923 4 4 4 32d
kube-system nginx-ingress-controller-878021172 0 0 0 99d
kube-system prometheus-core-1049380509 0 0 0 11d
kube-system prometheus-core-1057044748 0 0 0 11d
kube-system prometheus-core-124082880 0 0 0 12d
kube-system prometheus-core-1274300653 0 0 0 32d
kube-system prometheus-core-1496270586 0 0 0 10d
kube-system prometheus-core-2953594474 0 0 0 10d
kube-system prometheus-core-3816572233 1 1 1 10d
kube-system prometheus-core-87115933 0 0 0 22d
kube-system prometheus-core-87378077 0 0 0 31d
kube-system redmine-sqlite-1134748302 0 0 0 31d
kube-system redmine-sqlite-1236657579 1 1 1 31d
kube-system redmine-sqlite-2005852822 0 0 0 31d
kube-system redmine-sqlite-3063145196 0 0 0 31d
kube-system sonarqube-3729821934 0 0 0 31d
kube-system sonarqube-3857878650 0 0 0 31d
kube-system sonarqube-3908538607 1 1 1 30d
出于某种原因,我需要分析rs的名称,rs的所有名称最后都包含一些随机数字,但数字的数量不固定(可能是8,9或10)。所以问题是:
数字的数量总是8,9或10,还是5或15之类的数字?
我在哪里找到了这个的命名规则?
管环境 kubernets 1.6.8
答案 0 :(得分:0)
如果找到了正确的行,则会在此处生成ReplicaSet的名称: https://github.com/kubernetes/kubernetes/blob/16670f1a95a61434f8d6c96596a3c541b01fb8aa/pkg/controller/deployment/sync.go#L299
d
// SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and
// ensures that strings generated from hash functions appear consistent throughout the API.
func SafeEncodeString(s string) string {
r := make([]rune, len(s))
for i, b := range []rune(s) {
r[i] = alphanums[(int(b) % len(alphanums))]
}
return string(r)
}
是部署的地方。
随机方法的实现如下:
uint32
在我看来,random的长度是基于podTemplateSpecHash的长度,它是类型func ComputeHash(template *v1.PodTemplateSpec, collisionCount *int32) uint32 {...}
的值。这是散列函数的方法签名:
set ff?
因此,最大位数应为10.