Extend Metadata and Version REST API endpoints to include KAS Kubernetes API proxy URL

Problem

As a GitLab user how do you find out what the URL of the KAS Kubernetes API proxy is?

Status quo

You most likely browse to /api/v4/version or /api/v4/metadata which includes the KAS external URL and with some knowledge of the setup you can wrangle it into a Kubernetes API proxy URL.

For GitLab.com this would be:

curl https://gitlab.com/api/v4/metadata -X 'PRIVATE-TOKEN: ...'
{"version":"16.5.0-pre","revision":"30176ecca12","kas":{"enabled":true,"externalUrl":"wss://kas.gitlab.com","version":"v16.5.0-rc2"},"enterprise":true}                                           

Now look at the kas.externalUrl field and change it (with knowledge) to a k8s proxy path:

wss://kas.gitlab.com ==> https://kas.gitlab.com/k8s-proxy

Fun fact: in GDK for example the URI is /-/k8s-proxy instead of just /k8s-proxy - something the end user of the instance has to "know". Also, this path is configurable and it might theoretically be anything.

Solution

The /version and /metadata REST API endpoints responses should include an additional proxyUrl field. A response would look like this:

 {
   "version": "16.5.0-pre",
   "revision": "30176ecca12",
   "kas": {
     "enabled": true,
     "externalUrl": "wss://kas.gitlab.com",
+    "proxyUrl": "https://kas.gitlab.com/k8s-proxy",
     "version": "v16.5.0-rc2"
   },
   "enterprise": true
 }                     
Edited by Timo Furrer