metrics-server API for kubernetes-client/c

58 views
Skip to first unread message

Ferenc Gerlits

unread,
Jul 20, 2022, 7:01:01 AM7/20/22
to dev
Hi,

We use kubernetes-client/c in our project https://github.com/apache/nifi-minifi-cpp and access the metrics-server API `apis/metrics.k8s.io` using the low-level `apiClient_invoke()`, since there is no wrapper for this API in kubernetes-client/c.

I am thinking of contributing a new MetricsServerV1Beta1API wrapper for these API calls (GET pods, GET nodes).  Is that something you would be interested in, and could be accepted as a pull request?

Thank you,
Ferenc

Boshi Lian

unread,
Jul 20, 2022, 2:36:50 PM7/20/22
to fger...@gmail.com, dev

--
You received this message because you are subscribed to the Google Groups "dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dev+uns...@kubernetes.io.
To view this discussion on the web visit https://groups.google.com/a/kubernetes.io/d/msgid/dev/2e3bf4c7-febf-470f-b914-595acb6d777an%40kubernetes.io.

Jordan Liggitt

unread,
Jul 20, 2022, 2:47:28 PM7/20/22
to farme...@gmail.com, fger...@gmail.com, dev
I think the intent of the kubernetes-client generated clients is to include typed clients for APIs compiled into kube-apiserver, but not for aggregated APIs and CRD-based APIs.

For aggregated and CRD-based APIs, something like https://pkg.go.dev/k8s.io/client-go/dynamic could be useful.

Kevin Wiesmueller

unread,
Jul 20, 2022, 2:55:21 PM7/20/22
to lig...@google.com, farme...@gmail.com, fger...@gmail.com, dev
I agree with Jordan, I don't think metrics api belongs in the client-go typed client and should rather be provided by metrics-server or whoever defines the metrics-api schema like other non-standard apis. Especially because it's not a default/optional api so having it in the client would formalize it more than it is right now.

Brendan Burns

unread,
Jul 20, 2022, 3:31:32 PM7/20/22
to lig...@google.com, kwiesm...@google.com, farme...@gmail.com, fgerlits, dev
I'm the maintainer of many of these clients (including assisting w/ the C client)

Generating code for CRDs and other extension APIs is actually fairly straightforward to do, there is documentation here for how to do it in Java:


We have taken the approach that we will generate separate API packages based on community contributions.

I hope that you can adapt the Java instructions to generate C code instead, but if you run into problems please file issues on https://github.com/kubernetes-client/c and we can discuss it there.

In addition, we also supply a 'generic' client which can work with any API (at the expense of having typed values in your code) but it may be easier to get started with:


Part of the reason why this is feasible is that all of the clients other than golang are based on code generation rather than hand-written code (though code generation brings it's own set of issues, it's a tradeoff)

--brendan



From: 'Kevin Wiesmueller' via dev <d...@kubernetes.io>
Sent: Wednesday, July 20, 2022 11:55 AM
To: lig...@google.com <lig...@google.com>
Cc: farme...@gmail.com <farme...@gmail.com>; fgerlits <fger...@gmail.com>; dev <d...@kubernetes.io>
Subject: [EXTERNAL] Re: metrics-server API for kubernetes-client/c
 

Hui Yu

unread,
Jul 20, 2022, 10:17:32 PM7/20/22
to dev, bbu...@microsoft.com, farme...@gmail.com, fger...@gmail.com, dev, lig...@google.com, kwiesm...@google.com
I agree with Brendan and the other commenters here.

Now the best solution for aggregated APIs and CRD-based APIs using kubernetes-client/c is 'generic' client:
I will document this in the README to make it easier for developers to find this solution.

But I also wonder if we should keep/develop the codebase for the metrics server API `apis/metrics.k8s.io` with a generic client somewhere to avoid duplication of work by other developers? Because more than one developer mentioned before that they implemented the metrics API client using kubernetes-client/c.

Ferenc Gerlits

unread,
Jul 21, 2022, 9:17:55 AM7/21/22
to dev, bbu...@microsoft.com, farme...@gmail.com, lig...@google.com, kwiesm...@google.com, Hui Yu
Thanks everyone for your help!  I did not know about genericClient.  I will use that, as it is nice and simple.  And thanks Hui for adding it to the README, I think that will be useful to others, as well.
Reply all
Reply to author
Forward
0 new messages