Skip to content

Conversation

everpeace
Copy link
Contributor

@everpeace everpeace commented Jun 19, 2025

This PR adds Cluster Inventory(ClusterProfile) API Provider.

The implementation heavily refers to the Cluster API Provider (/providers/cluster-api).

Note:

fixes #30

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 19, 2025
@k8s-ci-robot k8s-ci-robot requested review from JeremyOT and skitt June 19, 2025 13:56
@everpeace everpeace changed the title ✨ Cluster Inventory API Provider ✨ Cluster Inventory(ClusterProfile) API Provider Jun 19, 2025
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 19, 2025
@corentone
Copy link

Hello @everpeace thank you for opening the PR!
Given we have the proposal of adding credentials via plugin and a PR in this repo to support kubeconfigs I wonder if we need this intersection? We may be able to wait a tiny bit and use the KEP 5339?

@everpeace
Copy link
Contributor Author

everpeace commented Jun 19, 2025

@corentone

Given we have the proposal of adding kubernetes/enhancements#5338 and a PR in this repo to #45 I wonder if we need this intersection?

Oh, thanks for the info. I now understand kubeconfig based providers can basically support "Push Model via Credentials in Secret (Not Recommended)" in KEP-4322.

However, the kubeconfig provider seems to use different labels and key name for the Secret.

We may be able to wait a tiny bit and use the KEP 5339?

Yeah, agreed! Then, I will wait for KEP-5339 and the consumer library PR being merged and want to update this provider or add some implementation so to extract credentials via credslibrary as designed in KEP-5339 later.

WDYT??

Copy link
Contributor

@mjudeikis mjudeikis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One thing I got while reading this code that I dont think we handle case where cluster secret changes and we need to update-engaged cluster. @embik. do think this is the case and we need to address it?

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 20, 2025
Copy link
Contributor Author

@everpeace everpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjudeikis

One thing I got while reading this code that I dont think we handle case where cluster secret changes and we need to update-engaged cluster.

Cool! Thanks for the catch!

f4c93f0 adds the watch for Secrets and re-engaging the Cluster in manager when kubeconfig was updated.

I'm not so confident for my implementation being appropriate or not because I'm new to multicluster-runtime, particularly, how to stop/disengage existing Cluster in the manager (I just cancel() the context for the Cluster).

I would be appreciated if you gave review and some advice.


manual test result is also updated: https://gist.github.com/everpeace/4ba04f70830504fb1485279ba031d907

@embik
Copy link
Member

embik commented Jun 20, 2025

I'm not so confident for my implementation being appropriate or not because I'm new to multicluster-runtime, particularly, how to stop/disengage existing Cluster in the manager (I just cancel() the context for the Cluster).

That's absolutely correct!

Signed-off-by: Shingo Omura <everpeace@gmail.com>
Signed-off-by: Shingo Omura <everpeace@gmail.com>
Signed-off-by: Shingo Omura <everpeace@gmail.com>
…nfig is changed.

Signed-off-by: Shingo Omura <everpeace@gmail.com>
@everpeace everpeace force-pushed the cluster-inventory-api branch from f4c93f0 to ec412db Compare June 20, 2025 15:14
Signed-off-by: Shingo Omura <everpeace@gmail.com>
Signed-off-by: Shingo Omura <everpeace@gmail.com>
@everpeace everpeace force-pushed the cluster-inventory-api branch from ec412db to b35387b Compare June 20, 2025 15:21
Copy link
Contributor Author

@everpeace everpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corentone
kubeconfig-based provider seems not following the secret management specification defined in KEP-4322: Cluster Inventory - Push Model via Credentials in Secret. It uses the different labels, data key, and has no consumer concept.

So, how about this cluster-inventory-api provider keeping the support fetching kubeconfig from Secret objects managed as defined in the KEP.

And, I'd like to support KEP-5339 in another PR once the KEP and its helper library being merged.
WDYT??

@mjudeikis @embik I implemented re-engaging the Cluster in Manager when its kubeconfig was updated. And, I also unit test for the provider including re-engaging test case by envtest.

Please take a look.

Signed-off-by: Shingo Omura <everpeace@gmail.com>
@everpeace everpeace changed the title ✨ Cluster Inventory(ClusterProfile) API Provider 🌱 Cluster Inventory(ClusterProfile) API Provider Jun 20, 2025
@hdp617
Copy link
Contributor

hdp617 commented Jun 20, 2025

@corentone kubeconfig-based provider seems not following the secret management specification defined in KEP-4322: Cluster Inventory - Push Model via Credentials in Secret. It uses the different labels, data key, and has no consumer concept.

If I understand correctly from PR #45, the secret label and key in the kubeconfig provider are customizable. To work with the Cluster Inventory spec, we only need to set the KubeconfigSecretLabel and KubeconfigSecretKey options in the provider?

@everpeace
Copy link
Contributor Author

everpeace commented Jun 21, 2025

To work with the Cluster Inventory spec, we only need to set the KubeconfigSecretLabel and KubeconfigSecretKey options in the provider?

I understand it is configurable. However, in the Cluster Inventory API KEP, one Cluster Profile can have multiple Secrets so that it can support multiple consumers like this:

kind: ClusterProfile
metadata:
  name: cluster1
..
---
kind: Secret
metadata:
  name: kubeconfig-cluster1-for-consumer-x-but-name-is-not-important
  metadata:
    labels:
      x-k8s.io/cluster-inventory-consumer: consumer-x
      x-k8s.io/cluster-profile: cluster1
data:
  Config: ...
---
kind: Secret
metadata:
  name: kubeconfig-cluster1-for-consumer-y-but-name-is-not-important
  metadata:
    labels:
      x-k8s.io/cluster-inventory-consumer: consumer-y
      x-k8s.io/cluster-profile: cluster1
data:
  Config: ...

From the user perspective, when using the Cluster Inventory API:

  • The cluster name that the provider handles should be ClusterProfile's name instead of the Secret name. Of course, I understand that another level of configurability can be added to the kubeconfig-based provider, allowing another label to specify the cluster name
  • It is quite natural for me that Cluster Inventory API provider support fetching kubeconfig as defined in the KEP.

Signed-off-by: Shingo Omura <everpeace@gmail.com>
…new local manager

Signed-off-by: Shingo Omura <everpeace@gmail.com>
Signed-off-by: Shingo Omura <everpeace@gmail.com>
Copy link
Contributor Author

@everpeace everpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@embik Thank you for your review! I addressed your comments. PTAL.

@embik
Copy link
Member

embik commented Jul 14, 2025

Sorry for this PR moving slowly! I haven't forgotten it, just haven't gotten around to a better understanding of ClusterProfile so I can fully review this PR. But I promise it's on my TODO list.

@everpeace
Copy link
Contributor Author

everpeace commented Jul 14, 2025

Thank you for updating your status! I'm looking forward to your another review round👍

Signed-off-by: Shingo Omura <everpeace@gmail.com>
…ch can abstract how kubeconfigs are managed and retrieved.

Signed-off-by: Shingo Omura <everpeace@gmail.com>
@everpeace everpeace force-pushed the cluster-inventory-api branch from d1e2781 to 58bdaed Compare July 25, 2025 17:58
Copy link
Contributor Author

@everpeace everpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@embik @hdp617

as agreed in #55 (comment):

And,

PTAL 🙇


@corentone @qiujian16

This provider now supports both CredentialProvider-based approach(KEP-5339) and Secret-based approach(KEP-4322). PTAL.

@everpeace everpeace force-pushed the cluster-inventory-api branch from bfca3ba to c9efaa0 Compare July 25, 2025 18:30
Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we aren't running tests successfully yet, let's try to get them working!

@everpeace everpeace force-pushed the cluster-inventory-api branch 2 times, most recently from 376d169 to 87eaf7e Compare July 28, 2025 13:57
hdp617 and others added 4 commits July 28, 2025 23:03
Co-authored-by: Shingo Omura <everpeace@gmail.com>
Signed-off-by: Shingo Omura <everpeace@gmail.com>
…api provider

Signed-off-by: Shingo Omura <everpeace@gmail.com>
Signed-off-by: Shingo Omura <everpeace@gmail.com>
@everpeace everpeace force-pushed the cluster-inventory-api branch from 87eaf7e to c6278a3 Compare July 28, 2025 14:07
everpeace and others added 2 commits July 28, 2025 23:11
Co-authored-by: Marvin Beckers <mail@embik.me>
…"make moduels"

Signed-off-by: Shingo Omura <everpeace@gmail.com>
@everpeace everpeace force-pushed the cluster-inventory-api branch from d67a0e7 to c35aa8e Compare July 28, 2025 14:12
Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Thank you so much for this contribution!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 28, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: f156a1b5d54aef87ee9bd71325ab0f63b4ce6a3b

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik, everpeace

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 28, 2025
@k8s-ci-robot k8s-ci-robot merged commit eb0549c into kubernetes-sigs:main Jul 28, 2025
16 checks passed
@everpeace everpeace deleted the cluster-inventory-api branch July 28, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClusterProfile (sig-multicluster) API provider
6 participants