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

🌱 Use upstream cluster RESTConfig utility #248

Merged

Conversation

jimmidyson
Copy link
Member

This commit simplifies the codebase by removing custom kubeconfig code
and instead using the existing fucntionality from cluster-api project.

@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 28, 2024
@jimmidyson jimmidyson force-pushed the jimmi/simplify-restconfig branch 2 times, most recently from 64fada5 to 745148d Compare May 28, 2024 10:12
Copy link
Contributor

@Jont828 Jont828 left a comment

Choose a reason for hiding this comment

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

Nice work! This cleans things up substantially. When did the rest config functionality get introduced in CAPI?

Namespace: cluster.Namespace,
},
Data: map[string][]byte{
secret.KubeconfigDataName: []byte(`apiVersion: v1
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe we can move this into a var declaration outside the function so the indentation looks better like this:

var config = []byte(`apiVersion: v1
kind: Config
clusters:
- cluster:
    server: http://127.0.0.1:8080
  name: ` + cluster.Name + `
contexts:
- context:
    cluster: ` + cluster.Name + `
  name: ` + cluster.Name + `
current-context: ` + cluster.Name + `
`),
    },
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Hard to move it outside as a var because it includes cluster.Name from the cluster argument. I've added new line at the start so indentation looks better but kept it in the function. Hope that's ok.

This commit simplifies the codebase by removing custom kubeconfig code
and instead using the existing fucntionality from cluster-api project.
@k8s-ci-robot
Copy link
Contributor

@jimmidyson: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-addon-provider-helm-apidiff-main db42942 link false /test pull-cluster-api-addon-provider-helm-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@jimmidyson
Copy link
Member Author

When did the rest config functionality get introduced in CAPI?

Since the beginning of time (well a long time anyway 😆 ) https://github.com/kubernetes-sigs/cluster-api/blame/main/controllers/remote/cluster.go#L52

@jimmidyson jimmidyson requested a review from Jont828 May 29, 2024 19:59
Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@@ -117,6 +141,8 @@ var _ = Describe("Testing HelmChartProxy and HelmReleaseProxy reconcile", func()
cluster := cluster1.DeepCopy()
err := k8sClient.Create(ctx, cluster)
Expect(err).ToNot(HaveOccurred())
err = k8sClient.Create(ctx, newKubeconfigSecretForCluster(cluster))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err = k8sClient.Create(ctx, newKubeconfigSecretForCluster(cluster))
Expect(k8sClient.Create(ctx, newKubeconfigSecretForCluster(cluster))).To(Succeed())

I think this style is more readable, but your change is parallel with the rest of the tests, so 🤷🏻.

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jimmidyson, mboersma

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 May 30, 2024
@k8s-ci-robot k8s-ci-robot merged commit d0f83a2 into kubernetes-sigs:main May 30, 2024
12 of 13 checks passed
@jimmidyson jimmidyson deleted the jimmi/simplify-restconfig branch May 30, 2024 15:43
faiq added a commit to nutanix-cloud-native/cluster-api-runtime-extensions-nutanix that referenced this pull request Jun 12, 2024
**What problem does this PR solve?**:
Upgrade CAAPH to 0.2.4
This release includes fixes needed for supporting CAAPH in airgap
environment.

🌱 Use upstream cluster RESTConfig utility by @jimmidyson in
kubernetes-sigs/cluster-api-addon-provider-helm#248
🐛 Fix OCI client configuration logic by @jimmidyson in
kubernetes-sigs/cluster-api-addon-provider-helm#252
🐛 pointer checks if user doesn't specify CASecret by @faiq in
kubernetes-sigs/cluster-api-addon-provider-helm#253
**Which issue(s) this PR fixes**:
Fixes #

**How Has This Been Tested?**:
<!--
Please describe the tests that you ran to verify your changes.
Provide output from the tests and any manual steps needed to replicate
the tests.
-->

**Special notes for your reviewer**:
<!--
Use this to provide any additional information to the reviewers.
This may include:
- Best way to review the PR.
- Where the author wants the most review attention on.
- etc.
-->
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/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.

4 participants