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

🌱 Test BYO certificates #10681

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lentzi90
Copy link
Contributor

What this PR does / why we need it:

This adds an integration test for BYO CA certificate. It is practically a copy of TestReconcileInitializeControlPlane but with a custom CA and a check to verify that the generated kubeconfig is really using this CA.

To make the test environment behave similar to the real world, it now also has a cache that picks up objects based on labels. For this reason it was also necessary to add labels in a few places.

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 #9568 (it was closed already when we added the docs)

/area testing

@k8s-ci-robot k8s-ci-robot added the area/testing Issues or PRs related to testing label May 27, 2024
@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 neolit123 for approval. For more information see the Kubernetes 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 k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 27, 2024
@lentzi90
Copy link
Contributor Author

Finally got around to add the CA verfification now.
/cc @fabriziopandini

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

overal lgtm. I will just wait for #10633 to merge first

@@ -408,6 +409,9 @@ func fakeCASecret(namespace, name string, caData []byte) *corev1.Secret {
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Labels: map[string]string{
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not necessary anymore as soon as we merge #10633

cc @sbueringer @chrischdi

Copy link
Member

@sbueringer sbueringer May 29, 2024

Choose a reason for hiding this comment

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

Let's definitely revert (after #10633 merges it should work without). This secret should not require the cluster-name label (also the secret should not correspond to any cluster)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! I will wait for it to merge, then rebase and remove this. 🙂

Copy link
Member

Choose a reason for hiding this comment

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

@lentzi90 PR is merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!
@adilGhaffarDev or @Sunnatillo does anyone of you want to take this over? It may be some time until I can get back to it since I'm on parental leave 😇

Copy link
Member

Choose a reason for hiding this comment

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

No worries! Enjoy!

Copy link
Contributor

Choose a reason for hiding this comment

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

I can address the comments and push the changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

pushed the changes, please check.

@sbueringer
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 19, 2024
@sbueringer
Copy link
Member

I think this also requires changes to another test, see: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/10681/pull-cluster-api-test-main/1812731035935313920

lentzi90 and others added 3 commits October 21, 2024 14:27
This adds an integration test for BYO CA certificate.
It is practically a copy of TestReconcileInitializeControlPlane
but with a custom CA and a check to verify that the generated kubeconfig
is really using this CA.

Signed-off-by: Lennart Jern <[email protected]>
Signed-off-by: Muhammad Adil Ghaffar <[email protected]>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 22, 2024
@lentzi90
Copy link
Contributor Author

The extension config controller test made me realize that my naive solution to add the cache directly to the test environment was probably not the best idea. Somehow I didn't realize that different controllers have different cache behavior.

To improve the situation I now made it so that each test suite can have its own cache options. I took inspiration from #11201 to implement it. It is in a separate commit for now so it can be easily reverted if there is some issue with it that I didn't realize.
I have only modified/added the cache for the kubeadm control plane controller suite and the addons controller suite. If you know about more places where it should be, please let me know! Also if I misunderstood how it should be configured for these two controllers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Issues or PRs related to testing cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

Test and document bring-your-own-cert use cases for KCP
5 participants