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

Allow to use existing k8s cluster instead of minikube #442

Merged
merged 7 commits into from
Jul 27, 2018

Conversation

alejandroEsc
Copy link
Contributor

@alejandroEsc alejandroEsc commented Jul 24, 2018

What this PR does / why we need it:
Allows us to use an existing cluster with a valid kubeconfig to launch resources instead of using minikube

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 #

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

The command cluster create can now accept a kubeconfig file and launch on an existing k8s cluster. This allows us not to use minikube if we do not want to.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 24, 2018
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 24, 2018
@alejandroEsc alejandroEsc changed the title Ae/externalcluster Allow to use existing k8s cluster instead of minikube Jul 24, 2018
@jessicaochen
Copy link
Contributor

Thanks for doing this! One of the reasons I wrote the logic with the ClusterProvisioner interface we could easily sub out minikube. I am glad it is being used.

I'm not going to jump on this review (unless someone wants me to). The only high level point you may want to think through is cleanup. As it is, after bootstrap is done, the external cluster will have a bunch of leftover controllers/objects sitting in it. We will want some cleanup logic if you plan on leaving the external cluster running. For minikube, the cleanup was handled in the deletion of the minikube cluster.

@dims
Copy link
Member

dims commented Jul 24, 2018

@alejandroEsc can you please add some notes on what if any we need to run on the "external cluster"?

Copy link
Contributor

@mkjelland mkjelland left a comment

Choose a reason for hiding this comment

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

This is a great! Just added a few notes.

return err
}
} else {
exernalProvider = minikube.New(co.VmDriver)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo, should be externalProvider

@@ -112,6 +124,7 @@ func init() {
createClusterCmd.Flags().BoolVarP(&co.CleanupExternalCluster, "cleanup-external-cluster", "", true, "Whether to cleanup the external cluster after bootstrap")
createClusterCmd.Flags().StringVarP(&co.VmDriver, "vm-driver", "", "", "Which vm driver to use for minikube")
createClusterCmd.Flags().StringVarP(&co.KubeconfigOutput, "kubeconfig-out", "", "kubeconfig", "Where to output the kubeconfig for the provisioned cluster")
createClusterCmd.Flags().StringVarP(&co.ExistingClusterKubeconfigPath, "existing-cluster-kubeconfig", "k", "", "path to an existing cluster's kubeconfig (intead of using minikube)")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can you use uppercase for "path" to match the other flags values?

-a, --addon-components string A yaml file containing cluster addons to apply to the internal cluster
--cleanup-external-cluster Whether to cleanup the external cluster after bootstrap (default true)
-c, --cluster string A yaml file containing cluster object definition
-k, --existing-cluster-kubeconfig string path to an existing cluster's kubeconfig (intead of using minikube)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to use the -k? Since it's not a required flag, it seems like we could force people to use the full "existing-cluster-kubeconfig" string

@@ -112,6 +124,7 @@ func init() {
createClusterCmd.Flags().BoolVarP(&co.CleanupExternalCluster, "cleanup-external-cluster", "", true, "Whether to cleanup the external cluster after bootstrap")
createClusterCmd.Flags().StringVarP(&co.VmDriver, "vm-driver", "", "", "Which vm driver to use for minikube")
createClusterCmd.Flags().StringVarP(&co.KubeconfigOutput, "kubeconfig-out", "", "kubeconfig", "Where to output the kubeconfig for the provisioned cluster")
createClusterCmd.Flags().StringVarP(&co.ExistingClusterKubeconfigPath, "existing-cluster-kubeconfig", "k", "", "path to an existing cluster's kubeconfig (intead of using minikube)")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit of a confusing concept for the external user, but it's unclear from the flag name what the existing cluster will be used for. Maybe it could be called "existing-bootstrap-cluster-kubeconfig" or change the explanation text to "path to an existing cluster's kubeconfig for bootstrapping (intead of using minikube)"

@alejandroEsc
Copy link
Contributor Author

@jessicaochen would it be ok to review the cleanup process in another PR? Its definitely something im considering, including maybe adding an additional function to the interface that would do this. But, I want to be careful first and observe which items are safe to cleanup and which are not.

@alejandroEsc
Copy link
Contributor Author

@dims Do you mean what are the min requirements for the external cluster? Where would you like to see the notes? Also would be ok to include that in another PR?

@alejandroEsc
Copy link
Contributor Author

@jessicaochen @dims @mkjelland thank you so much for taking your time to review! I have made the changes requested for this PR at the moment. I renamed things a bit for clarity, let me know if thats ok or not.

@jessicaochen
Copy link
Contributor

jessicaochen commented Jul 25, 2018

@alejandroEsc - It is fine to do cleanup in another PR. If you have not already, create an issue to track this cleanup work and add a comment in the code referencing the issue.

That way folks looking at the code will understand the situation till the cleanup is done.

If you want my 2-cents on how the cleanup should be - It should probably be in the ClusterDeployer. Since that class creates all the objects in the external cluster, it should have enough context to (optionally) clean them as well.

@alejandroEsc
Copy link
Contributor Author

@jessicaochen agreed on all accounts. Issue: #448

Copy link
Contributor

@mkjelland mkjelland left a comment

Choose a reason for hiding this comment

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

lgtm, can someone else read through this and add the lgtm label?

@dims
Copy link
Member

dims commented Jul 25, 2018

/lgtm

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

@jessicaochen @dims can i get this merged? or is there something missing?

@jessicaochen
Copy link
Contributor

The box says you need still in an approval from at least one of your reviewers before it will automerge.

@mkjelland
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alejandroEsc, mkjelland

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 27, 2018
@dims
Copy link
Member

dims commented Jul 27, 2018

right, i am not an approver .. ah looks like @mkjelland took care of it

@k8s-ci-robot k8s-ci-robot merged commit f17f564 into kubernetes-sigs:master Jul 27, 2018
jayunit100 pushed a commit to jayunit100/cluster-api that referenced this pull request Jan 31, 2020
Cluster actuator needs delete permission for secret.
@alejandroEsc alejandroEsc deleted the ae/externalcluster branch December 29, 2021 18:33
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.

None yet

5 participants