<p>Below is all replica sets in my kubernetes environments create by <strong>deployments</strong> (when using <strong>deployment</strong>, it will first create <strong>replica sets</strong>): </p>

<pre><code>[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
</code></pre>

<p>For some reason I need to analyze the name of rs and all names of rs contains some random digitals in the end, but the number of digitals is not fixed( it may be 8, 9 or 10). So the question is:</p>

<ol>
<li><p>Does the the number of digitals is always be 8, 9 or 10, or it could be any number like 5 or 15? </p></li>
<li><p>Where do I found the naming rules of this?</p></li>
</ol>

<p><strong>Envrionment</strong>
kubernets 1.6.8</p>

<p>If I found the correct line, then the name of a ReplicaSet is generated here: 
<a href="https://github.com/kubernetes/kubernetes/blob/16670f1a95a61434f8d6c96596a3c541b01fb8aa/pkg/controller/deployment/sync.go#L299" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/blob/16670f1a95a61434f8d6c96596a3c541b01fb8aa/pkg/controller/deployment/sync.go#L299</a></p>

<pre><code>podTemplateSpecHash := fmt.Sprintf("%d", controller.ComputeHash(&amp;newRSTemplate, d.Status.CollisionCount))
//...
Name: d.Name + "-" + rand.SafeEncodeString(podTemplateSpecHash),
</code></pre>

<p>Where <code>d</code> is a deployment.</p>

<p>The random method is implemented like this:</p>

<pre><code>// 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)
}
</code></pre>

<p>It looks to me, that the length of the random is based on the length of the podTemplateSpecHash, which is a value of type <code>uint32</code>. Here is the method signature of the hashing function:</p>

<pre><code>func ComputeHash(template *v1.PodTemplateSpec, collisionCount *int32) uint32 {...}
</code></pre>

<p>Therefore the maximum number of digits should be 10. </p>
