<p>I'm trying to find the above information but I cannot seem to find anything concrete.</p>
<p>I've tried looking at <a href="https://github.com/kubernetes/kubernetes" rel="nofollow noreferrer">k8s source code</a> but it's a bit hard to find relevant bits there and I'm not sure I can rely on such information going forward.</p>
<p>Reason for this is I'd like to extract certain bit of data about pods without calling the API.</p>
<p>So having:</p>
<pre><code>$ kubectl get pods
NAME                                                   READY   STATUS    RESTARTS   AGE
grafana-79dcc6469f-zzgmh                               2/2     Running   2          4d

$ kubectl get rs
NAME                                             DESIRED   CURRENT   READY   AGE
collection-grafana-79dcc6469f                    1         1         1       4d1h

$ kubectl get deployment
NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
collection-grafana                    1/1     1            1           4d1h
</code></pre>
<p>I'd like to exctract <code>zzgmh</code> as pod ID and <code>79dcc6469f</code> as replica set ID.</p>

Patryk
<blockquote>
<p>Where can I find information about kubernetes ID spec i.e. pod suffix ID length?</p>
</blockquote>
<p>The <code>simpleNameGenerator</code> function is used for name generation in many places.</p>
<pre class="lang-golang prettyprint-override"><code>$ cat kubernetes/staging/src/k8s.io/apiserver/pkg/storage/names/generate.go

var SimpleNameGenerator NameGenerator = simpleNameGenerator{}

const (
        // TODO: make this flexible for non-core resources with alternate naming rules.
        maxNameLength          = 63
        randomLength           = 5
        maxGeneratedNameLength = maxNameLength - randomLength
)

func (simpleNameGenerator) GenerateName(base string) string {
        if len(base) &gt; maxGeneratedNameLength {
                base = base[:maxGeneratedNameLength]
        }
        return fmt.Sprintf(&quot;%s%s&quot;, base, utilrand.String(randomLength))
}
</code></pre>
<blockquote>
<p>replicaSet suffix ID length</p>
</blockquote>
<p><a href="https://github.com/kubernetes/kubernetes/pull/51538/files" rel="nofollow noreferrer">Since 1.8+</a>, the names have a 10 runes long <a href="https://github.com/DataDog/dd-agent/pull/3563/files#diff-39e718425aecc2d45eb92af886071ad2R390" rel="nofollow noreferrer">suffix</a> (consonants + numbers).
That is controlled via <code>func ControllerRevisionName</code> from <code>kubernetes/pkg/controller/history/controller_history.go</code> file.</p>
<pre class="lang-golang prettyprint-override"><code>$ cat pkg/controller/history/controller_history.go
// ControllerRevisionName returns the Name for a ControllerRevision in the form prefix-hash. If the length
// of prefix is greater than 223 bytes, it is truncated to allow for a name that is no larger than 253 bytes.
func ControllerRevisionName(prefix string, hash string) string {
        if len(prefix) &gt; 223 {
                prefix = prefix[:223]
        }

        return fmt.Sprintf(&quot;%s-%s&quot;, prefix, rand.SafeEncodeString(strconv.FormatInt(int64(hash), 10)))
}
</code></pre>
<p>Additionally, if you are about introducing your own changes to <code>ReplicaSet</code> and <code>Pod</code> namings you might want looking at least into the <code>pkg/controller/deployment/sync.go</code> file that describes the usage of the <code>podTemplateSpecHash</code>.</p>
<p>Additionally you might want to check <a href="https://github.com/wercker/stern" rel="nofollow noreferrer">Stern</a> and <a href="https://github.com/thecasualcoder/kube-fzf" rel="nofollow noreferrer">kube-fzf</a> tools if all you need is to navigate through pods quickly or to tail logs.</p>
