PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 20, 2022

[FIXED] How to retrieve kubernetes cluster data with googleapis in node?

 October 20, 2022     google-api, google-cloud-platform, google-kubernetes-engine, kubernetes, node.js     No comments   

Issue

After researching the topic I found this documentation for retiring k8 clusters from GCP. However, I could not find any code examples of utilizing those API's and when I import google from googleapis 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 google do I need?


Solution

This is confusing.

There are 2 distinct APIs that you must use:

  1. Google's Kubernetes Engine API (see link). This API is used to create, read, update and delete Kubernetes clusters. Google provides a Node.js SDK documented here.
  2. The standard, generic Kubernetes API (see link). This API is used to create, read, update and delete resources on (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 official and community-supported libraries that implement the Kubernetes API. You'll need to pick one of the community-supported libraries for Node.js (as there's no official library).

The general process is to:

  1. Use the Kubernetes Engine API to e.g. projects.locations.cluster.get details of an existing GKE cluster
  2. Use the returned Cluster object to build a configuration object (the equivalent of building a context object in a kubeconfig file)go
  3. Use the context object with the Kubernetes API library to authenticate to the cluster and program it e.g. list Deployments, create Services etc.

go-- I have code for this step but it's written in Golang not JavaScript.



Answered By - DazWilkin
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,204,703

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing