-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add boilerplate for clusterctl #119
Conversation
/assign @jessicaochen |
@@ -0,0 +1 @@ | |||
# Contributing Guidelines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional to have empty conributing guidelines for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'm happy to remove the file though, but I wanted to link to something from the README.
clusterctl/README.md
Outdated
|
||
### Prerequisites | ||
|
||
Follow the steps listed at [CONTRIBUTING.md](https://github.com/kubernetes/kube-deploy/blob/master/cluster-api/clusterctl/CONTRIBUTING.md) to: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
clusterctl/README.md
Outdated
|
||
Follow the steps listed at [CONTRIBUTING.md](https://github.com/kubernetes/kube-deploy/blob/master/cluster-api/clusterctl/CONTRIBUTING.md) to: | ||
|
||
1. Build the `clusterctl` tool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably will want an example of how to build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one
clusterctl/README.md
Outdated
Follow the steps listed at [CONTRIBUTING.md](https://github.com/kubernetes/kube-deploy/blob/master/cluster-api/clusterctl/CONTRIBUTING.md) to: | ||
|
||
1. Build the `clusterctl` tool | ||
3. Create a `machines.yaml` file configured for your cluster. See the provided template for an example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come it jumped from 1 to 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MD renders ordered lists just fine even if the numbers are wrong here. I'll fix them nevertheless.
clusterctl/README.md
Outdated
1. Build the `clusterctl` tool | ||
3. Create a `machines.yaml` file configured for your cluster. See the provided template for an example. | ||
|
||
### Limitation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit)
Limitations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
clusterctl/README.md
Outdated
object. There will be defaults running. This will make the tool easily pluggage | ||
(change the controller spec) instead of changing the tool or mucking with flags. | ||
|
||
1. Create a cluster: `./clusterctl create cluster -c cluster.yaml -m machines.yaml -e extras.yaml` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave the create cluster details out. They can be filled in as the implementation is checked in. That way the docs and reality keep in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
clusterctl/cmd/root.go
Outdated
} | ||
|
||
func init() { | ||
RootCmd.PersistentFlags().StringVarP(&kubeConfig, "kubeconfig", "k", "", "location for the kubernetes config file. If not provided, $HOME/.kube/config is used") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave all flags out of the skeleton. They can be filled in as code uses them. This ensures the the flags actually do something when they appear and also ensure they are defined in a way that works and is accurate to the behavior of the code.
For example, I already know this definition of kubeconfig will not be accurate for bootstrapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
clusterctl/cmd/create.go
Outdated
createCmd.Flags().StringVarP(&co.Machine, "machines", "m", "", "machine yaml file") | ||
createCmd.Flags().StringVarP(&co.Extras, "extras", "e", "", "extras yaml file") | ||
|
||
RootCmd.AddCommand(createCmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the goal was something like:
./clusterctl create cluster .....
This seems to produce:
./clusterctl create ....
Or did I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on community feedback, we decided to align ourselves with the rest of the tooling -- This is also reflected in https://docs.google.com/document/d/1-sYb3EdkRga49nULH1kSwuQFf1o6GvAw_POrsNo5d8c/edit#.
*/ | ||
|
||
package cmd | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would recommend the cluster subcommand files be named with the cluster prefix. That way we do not have confusion when we have other NOUNS that happen to have a similar verb eg. create.
cluster_create.go or clustercreate.go instead of create.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we are going with the kubectl/kops model of VERB NOUN, this comment is moot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Moot.
clusterctl/cmd/create.go
Outdated
import ( | ||
"os" | ||
|
||
//"fmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional to have a commented out import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it. Typo
*/ | ||
|
||
package cmd | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Moot.
clusterctl/cmd/create.go
Outdated
return errors.NotImplementedError | ||
} | ||
func init() { | ||
RootCmd.AddCommand(createCmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we are doing VERB NOUN right now. This makes me expect
clusterctl create cluster .....
to be the create commmand instead of
clusterctl create ....
which is what this seems to be doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Added the subcommands
### Creating a cluster | ||
|
||
**NOT YET SUPPORTED!** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would cut out everything other than NOT YET SUPPORTED! in the creating a cluster section till it actually is supported. Similar reasoning to flags, it is best to keep the implementation and documentation in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair.
clusterctl/cmd/root.go
Outdated
}, | ||
} | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my previous comment on flags, I do mean all flags on all commands should not be implemented yet. They can be implemented when there is actually functionality to back it. This way the usage and description is accurate to how it is actually used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flags have been removed, I guess I missed the var.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The var seems to still be here. There also still seem to be flags on some of the commands that are not backed by implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird my linter didn't complain.
clusterctl/cmd/create.go
Outdated
if co.Cluster == "" { | ||
glog.Error("Please provide yaml file for cluster definition.") | ||
cmd.Help() | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are doing the following:
cmd.Help()
os.Exit(...)
in 4 locations in the Create command and there are similar sections in Delete and Register commands. Theoretically this number will grow as the scope of this application increases. Is there a simplification we can make so that it is only called in a single place for the various error scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. DOne
clusterctl/cmd/register.go
Outdated
var ro = &RegisterOptions{} | ||
|
||
var registerCmd = &cobra.Command{ | ||
Use: "register", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should register also follow VERB NOUN? ie. "register cluster" instead of just "register"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever register is implemented, it can be branched out. For now, I'm leaving it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this is the right approach.
Either we structure it as it is supposed to be structured ie. VERB NOUN or we leave it out entirely and when it is implemented, it is added with the right structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have decided to remove it and leave it up to implementer to add this cmd as well.
clusterctl/cmd/root.go
Outdated
}, | ||
} | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The var seems to still be here. There also still seem to be flags on some of the commands that are not backed by implementation.
clusterctl/cmd/register.go
Outdated
var ro = &RegisterOptions{} | ||
|
||
var registerCmd = &cobra.Command{ | ||
Use: "register", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this is the right approach.
Either we structure it as it is supposed to be structured ie. VERB NOUN or we leave it out entirely and when it is implemented, it is added with the right structure.
clusterctl/cmd/create_cluster.go
Outdated
type CreateOptions struct { | ||
Cluster string | ||
Machine string | ||
Extras string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were using a different name for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch. I changed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jessicaochen, karan 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 |
Use same logger throughout the codebase
What this PR does / why we need it: Adds boilerplate for clusterctl tool.
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 #112
Special notes for your reviewer: This is only a boilerplate to unblock anyone who wants to start working on adding features.
@kubernetes/kube-deploy-reviewers