Need an API endpoint to fetch the information of specific workers' nodes from the cluster

As per attatched screenshot of cluster Nodes where on selction of i icon - we see there is an API (check horizontal scrollbar) which displays the metadata of nodes - like labels.

We are not able to consume the same via morpheus API.
Kindly help us with the same

Hi @Khushbu ,

While there is not a direct API endpoint for that information there are a few places you could start.

There is an API endpoint for Get Cluster Workers that will provide perhaps some of the data you are looking for.

Additionally, using the API endpoint for Get API Config you could utilize a task to then query the K8s cluster directly for the data you are looking for. Something along the lines of:

import requests
import pp

morpheus = "https://YOURFQDN"
clusterId = YOURCLUSTERID
morpheusToken = "YOURTOKEN"

url = morpheus + "/api/clusters/" + str(clusterId) + "/api-config"

headers = {
    "accept": "application/json",
    "authorization": "Bearer " + morpheusToken
}

response = requests.get(url, headers=headers, verify=False)

json = response.json()

serviceUrl = json['serviceUrl']
serviceToken = json['serviceToken'].strip()

url = serviceUrl + "/api/v1/nodes"

headers = {
    "Authorization": "Bearer %s" % serviceToken
}

response = requests.get(url, headers=headers, verify=False)

pp(response.json())

That script could be further manipulated to capture the data you are looking for.

2 Likes

I tried above given solution. But no API is giving us lables associated with cluster node.
So, do we have any api for that?

That API-Config endpoint gives you an API key for your K8s cluster to query that directly via an API. We present you Morpheus labels, but not the meta information of the nodes.

I am trying api-config API.
It is not giving me api key.