Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ⚠️ Allow specifying a different credentials per VSphereMachine #3353

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GabQ-Bib
Copy link

… and defaulting to this identity if it exists.

What this PR does / why we need it:

This PR adds support for configuring a VsphereIdentity in the vspheremachine / vspherevm objects, which the controller will use when looking for credentials to contact the vcenter with. This appears to be a good solution to the issue mentioned below, because these objects already carry the server name & thumbprint so it makes sense they also carry the credentials.
This PR is a rewrite of the PR originally proposed by farodin91.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1720

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 12, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign srm09 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

Welcome @GabQ-Bib!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-vsphere 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-vsphere has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

Copy link

linux-foundation-easycla bot commented Feb 12, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 12, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @GabQ-Bib. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 12, 2025
@GabQ-Bib
Copy link
Author

I can see several way of implementing the feature:

  • Add a second "getCredential" method that is specifically called when trying to extract credentials from the VspereVM (instead of the cluster). This is the implementation you will find in the attached commit. It has the less impact on the codebase because the original method signature is kept throughout the rest of the controllers. As of right now, both method share a lot of code which is not ideal. Some of the code of the two methods could be factored in a 3rd method to help with code duplication.
  • A second implementation would be to change the getCredential method signature to directly use a "VsphereIdentityRef" along with a "namespace" string to cover all use cases. It requires a modest refactoring of the controllers that already use this method but it feels ultimately a better approach. I have a commit ready with this implementation.
  • I'm wondering if we could just change the method signature to expect an "object that has a property VsphereIdentityRef" which both cluster and vspherevm would comply to, removing the need to change the way the method is called in the rest of the code. My understanding of Go makes me think this would require creating such a type and having both cluster and vspherevm embed it, but It feels like a much more profound rework than the other two implementation proposed above.

I'm still in the process of testing whether this implementation fixes the issue in a satisfactory manner for my use case. In the meantime I would love if you could find the time to do a quick overview of my proposal and provide insights.

@chrischdi
Copy link
Member

/retitle [WIP] ⚠️ Allow specifying a different credentials per VSphereMachine

@k8s-ci-robot k8s-ci-robot changed the title [WIP] ✨ Add support for defining an identity in the vspheremachine… [WIP] ⚠️ Allow specifying a different credentials per VSphereMachine Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple vCenter in one cluster
3 participants