<p>Due to Kubernetes removing deprecated API I am trying to figure out an apiVersion of resources in a cluster and came across the following behavior.</p>

<p>When requesting definition for specific deployment, it reports an old api version:</p>

<pre><code>&gt; kubectl get deployment/some-deployment -o yaml
apiVersion: extensions/v1beta1
kind: Deployment
...
</code></pre>

<p>Bud when requesting it for all resources api version reported as new for the same resource:</p>

<pre><code>&gt; kubectl get all -o yaml
...
- apiVersion: apps/v1
  kind: Deployment
...
</code></pre>

<p>Same goes when checking <code>selfLink</code> in metadata:</p>

<pre><code>kubectl get all -o=custom-columns=NAME:.metadata.name,API-version:.metadata.selfLink
and
kubectl get deployment/some-deployment -o=custom-columns=NAME:.metadata.name,API-version:.metadata.selfLink
</code></pre>

<p>How should this be interpreted?</p>

<p>Kubernetes version is 1.15.7.</p>

Aleksandr Erokhin
<p>Quoted from <a href="https://github.com/kubernetes/kubernetes/issues/58131#issuecomment-356823588" rel="nofollow noreferrer">here</a></p>
<blockquote>
<p><code>kubectl get deployment foo</code> is ambiguous, since the server has deployments in multiple api groups. When a resource exists in multiple api groups, kubectl uses the first group listed in discovery docs published by the server which contains the resource. For backwards compatibility, that is the <strong>extensions</strong> api group.</p>
<p>If you want to ensure you get a deployment in the apps api group, fully qualify the resource you are requesting by running <code>kubectl get deployments.apps test-nginx</code></p>
<p>If you want a specific version, like v1, in the apps api group, include that as well: <code>kubectl get deployments.v1.apps test-nginx</code></p>
</blockquote>
<p>Also from <a href="https://github.com/kubernetes/kubernetes/issues/58131#issuecomment-404466779" rel="nofollow noreferrer">here</a></p>
<blockquote>
<p>What stored version is used for?</p>
<p>It is the serialized version in etcd. Whenever you fetch an object, the api server reads it from etcd, converts it into an internal version, then converts it to the version you requested.</p>
</blockquote>
<p>So, If you run</p>
<pre><code>$ kubectl get deployments nginx -o name
deployment.extensions/nginx
</code></pre>
<p>As you can see  requested version for above command is <code>deployment.extensions</code></p>
<p>And If you run</p>
<pre><code>$ kubectl get all -o name
...
deployment.apps/nginx
</code></pre>
<p>The requested version is <code>deployment.apps</code>. so, it returns the version with <code>apps/v1</code></p>
<p>Ref: <a href="https://github.com/kubernetes/kubernetes/issues/58131" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/58131</a></p>
