Describe:
What I want to do:
I used KubernetesClient library to get the information in K8s, now I want to get some information in Node like Node name etc.
My method:
I used V1NodeList Model and ListNodeAsync interface to get information
My question:
But they are returning too much data, I just want to get the data I want and get rid of the extra properties, what should I do?
Also in the GetKubernetesNodeAsync method, how can I return the value, I think
return (T)(object)models;is not a good way.This is a .net question.
Code:
- Controller
[HttpGet("Nodes")]
public async Task<ActionResult<V1NodeList>> GetNodeAsync()
{
var nodes = await _resourceAccess.GetKubernetesNodeAsync(default);
return nodes;
}
- Method
public async Task<T> GetKubernetesNodeAsync(CancellationToken cancellationToken = default)
{
// todo Temp
var config = new KubernetesClientConfiguration { Host = "http://127.0.0.1:8001" };
var client = new Kubernetes(config);
var models = await client.CoreV1.ListNodeAsync(cancellationToken: cancellationToken);
return (T)(object)models;
}
- Data returned