<p>After researching the topic I found <a href="https://cloud.google.com/kubernetes-engine/docs/reference/rest#rest-resource:-v1beta1.projects.locations.clusters" rel="nofollow noreferrer">this</a> documentation for retiring k8 clusters from GCP. However, I could not find any code examples of utilizing those API's and when I import <code>google</code> from <code>googleapis</code> I can't find the function in it that would be used for that purpose. For example, to get SQL data there is sqladmin, but nothing for retrieving k8 data. So what property of <code>google</code> do I need?</p>

<p>This is confusing.</p>
<p>There are 2 distinct APIs that you must use:</p>
<ol>
<li>Google's Kubernetes Engine API (see <a href="https://cloud.google.com/kubernetes-engine/docs/reference/rest/" rel="nofollow noreferrer">link</a>). This API is used to create, read, update and delete Kubernetes clusters. Google provides a Node.js SDK documented <a href="https://cloud.google.com/nodejs/docs/reference/container/latest" rel="nofollow noreferrer">here</a>.</li>
<li>The standard, generic Kubernetes API (see <a href="https://kubernetes.io/docs/concepts/overview/kubernetes-api/" rel="nofollow noreferrer">link</a>). This API is used to create, read, update and delete resources <strong>on</strong> (any) Kubernetes client and, for obvious(ly good) reasons, it is the API that you must use to interact with (an existing) Kubernetes Engine cluster too (because these are just like every other Kubernetes cluster). Kubernetes provides <a href="https://kubernetes.io/docs/reference/using-api/client-libraries/" rel="nofollow noreferrer">official and community-supported libraries</a> that implement the Kubernetes API. You'll need to pick one of the <a href="https://kubernetes.io/docs/reference/using-api/client-libraries/" rel="nofollow noreferrer">community-supported libraries</a> for Node.js (as there's no official library).</li>
</ol>
<p>The general process is to:</p>
<ol>
<li>Use the Kubernetes Engine API to e.g. <a href="https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters/get" rel="nofollow noreferrer"><code>projects.locations.cluster.get</code></a> details of an existing GKE cluster</li>
<li>Use the returned <a href="https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters#Cluster" rel="nofollow noreferrer"><code>Cluster</code></a> object to build a configuration object (the equivalent of building a <code>context</code> object in a kubeconfig file)<sup>go</sup></li>
<li>Use the <code>context</code> object with the Kubernetes API library to authenticate to the cluster and program it e.g. list Deployments, create Services etc.</li>
</ol>
<p><sup>go</sup>-- I have <a href="https://gist.github.com/DazWilkin/9506c0b9677d53a3e11b7457ed21cbe7" rel="nofollow noreferrer">code</a> for this step but it's written in Golang not JavaScript.</p>
