<p>Is there a <code>kubectl</code> command which returns the API server URL?</p>
<p>What I want is the code I need to put instead of below <code>...</code> :</p>
<pre><code>API_SERVER_URL=$(kubectl ...)
echo $API_SERVER_URL
http://&lt;API_SERVER_IP&gt;:&lt;API_SERVER_PORT&gt;
</code></pre>
<p><code>API_SERVER_IP</code> should be the very same that the one in my <code>.kube/config</code>.</p>

Fabrice Jammes
<p>Try this:</p>
<pre><code>kubectl proxy --port=8090 &amp;
curl http://localhost:8090/api/
</code></pre>
<p>This returns something like this:</p>
<pre><code>{
  &quot;kind&quot;: &quot;APIVersions&quot;,
  &quot;versions&quot;: [
    &quot;v1&quot;
  ],
  &quot;serverAddressByClientCIDRs&quot;: [
    {
      &quot;clientCIDR&quot;: &quot;0.0.0.0/0&quot;,
      &quot;serverAddress&quot;: &quot;10.165.39.165:16443&quot;
    }
  ]
}
</code></pre>
<p>Without proxying you can use:</p>
<pre><code>https://10.165.39.165:16443/api
</code></pre>
<p>but you need to pass authorization in the request.</p>
<p>In the response you see the array with the versions.</p>
<p>From here you can call and inspect the versions or get what is available on that version.</p>
<pre><code>curl http://localhost:8090/api/v1

{
  &quot;kind&quot;: &quot;APIResourceList&quot;,
  &quot;groupVersion&quot;: &quot;v1&quot;,
  &quot;resources&quot;: [
    ....
      &quot;shortNames&quot;: [
        &quot;cs&quot;
      ]
    },
    {
      &quot;name&quot;: &quot;configmaps&quot;,
      &quot;singularName&quot;: &quot;&quot;,
      &quot;namespaced&quot;: true,
      &quot;kind&quot;: &quot;ConfigMap&quot;,
      &quot;verbs&quot;: [
        &quot;create&quot;,
        &quot;delete&quot;,
        &quot;deletecollection&quot;,
        &quot;get&quot;,
        &quot;list&quot;,
        &quot;patch&quot;,
        &quot;update&quot;,
        &quot;watch&quot;
      ],
      &quot;shortNames&quot;: [
        &quot;cm&quot;
      ],
.....
</code></pre>
