-
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
Migrate to kubebuilder #494
Conversation
I've removing WIP from this PR. The tests all pass locally for me and I am able to stand up a cluster on gce using clusterctl with this change. I need to figure out how to get prow configured to run the kubebuilder tests (e.g. have etcd, apiserver, etc. in the path). It would also be nice to update to go 1.10+ while doing so to re-enable coverage, which works on multiple packages in 1.10 but not in earlier versions. Coverage has temporarily been disabled in the test target. |
Tests are passing :) |
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.
cmd/clusterctl/clusterctl
binary shouldn't be committed to the repo
This is a quick first pass. Wanted to free up for @xmudrii to continue
CONTRIBUTING.md
Outdated
@@ -1,116 +0,0 @@ | |||
# 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.
Was CONTRIBUTING.md intentionally removed, or was this a drive-by in 46b895e?
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 think it was an artifact of the commits. I can probably clean that up if you like. It looks like there aren't any changes to that file in the PR as a whole. https://github.com/kubernetes-sigs/cluster-api/pull/494/files
Dockerfile
Outdated
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager sigs.k8s.io/cluster-api/cmd/manager | ||
|
||
# Copy the controller-manager into a thin image | ||
FROM ubuntu:latest |
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 should use debian-base
or scratch
as the base image
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 switched to debian:latest. I didn't see debian-base here: https://hub.docker.com/_/debian/. Is this correct?
Dockerfile
Outdated
FROM golang:1.10.3 as builder | ||
|
||
# Copy in the go src | ||
WORKDIR /go/src/sigs.k8s.io/cluster-api |
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.
/go/
$GOPATH/
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.
Done
LICENSE
Outdated
@@ -1,201 +0,0 @@ | |||
Apache License |
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.
Was LICENSE intentionally removed, or was this a drive-by?
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 think that is an artifact of the commits. It should be back.
closeFn func() error | ||
} | ||
|
||
// New creates and returns the address of a Client, the kubeconfig argument is expected to be the string represenattion |
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.
typo
/represenattion/representation/
return nil | ||
} | ||
|
||
// NewFromDefaultSearchPath creates and returns the address of a Client, the kubeconfigFile argument is expected to be the path to a |
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.
/Client, the kubeconfigFile/Client. The kubeconfigFile/
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.
Done
}, nil | ||
} | ||
|
||
// Frees resources associated with the cluster client |
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.
/Frees/Close frees/
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.
Done
} | ||
|
||
// Deprecated API. Please do not extend or use. | ||
func (c *client) GetClusterObjects() ([]*clusterv1.Cluster, error) { |
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.
If the client isn't backwards compatible, maybe this is a good time to drop the deprecated APIs?
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.
Done
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.
Review in progress, but here are initial findings.
Some other nits:
cmd/clusterctl/clusterctl
- binary file, should probably be deletedcmd/clusterctl/CONTRIBUTING.md
- do we need this CONTRIBUTING.md here?cmd/clusterctl/README.md
- to be checked should links be updated
Makefile
Outdated
$$GOPATH/bin/conversion-gen -i ./pkg/apis/cluster/v1alpha1/ -O zz_generated.conversion --go-header-file boilerplate.go.txt | ||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
deploy: manifests | ||
kubectl apply -f config/crds |
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: this line could be replaced by deploy: manifests install
.
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 am not sure the CRDs need to be installed separately since they are referenced by config/default/kustomization.yaml
. Am I missing 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.
No. That can probably just be deleted.
package clientcmd | ||
|
||
import ( | ||
"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.
Nit(goimports): probably a new line here
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.
Obsolete
"sigs.k8s.io/cluster-api/cmd/clusterctl/clientcmd" | ||
) | ||
|
||
// Can create cluster clients |
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(lint): could be Factory can...
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.
Done
"sigs.k8s.io/cluster-api/pkg/apis/cluster/common" | ||
) | ||
|
||
const ClusterFinalizer string = "cluster.cluster.k8s.io" | ||
const ClusterFinalizer = "cluster.cluster.k8s.io" |
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.
Question: should this be cluster.cluster.k8s.io
or clusters.cluster.k8s.io
? I've seen that CRDs are named plural, but should plural name be used here as well?
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.
@xmudrii Good question. Since this wasn't something changed by this PR and this PR has a lot of changes, perhaps it can be opened in a separate thread or issue.
) | ||
|
||
// Finalizer is set on PreareForCreate callback | ||
const MachineFinalizer string = "machine.cluster.k8s.io" | ||
const MachineFinalizer = "machine.cluster.k8s.io" |
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.
Question: Same as for cluster
/clusters
, should this be machines.cluster.k8s.io
?
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.
Ack
@xmudrii Thanks for the comments. |
FYI: I restructured the commits and re-pushed so that it is easier to review. |
Any plans to use 1.12 instead of ancient 1.10 version at this point? |
@@ -128,15 +122,16 @@ type MachineStatus struct { | |||
// can be added as events to the Machine object and/or logged in the |
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.
Done
@@ -128,9 +124,7 @@ type MachineSetStatus struct { | |||
ErrorMessage *string `json:"errorMessage,omitempty"` |
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.
typo
/reconcilation/reconciliation/
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.
Done
} | ||
|
||
// newRestConfigForKubeconfig creates a rest.Config for a given kubeconfig string. | ||
func newRestConfigForKubeconfig(kubeconfig string) (*rest.Config, error) { |
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.
lint: deadcode
It appears this isn't used anywhere in the package. Is this intentional?
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.
Done
"sigs.k8s.io/controller-runtime/pkg/handler" | ||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
"sigs.k8s.io/controller-runtime/pkg/source" | ||
) | ||
|
||
const requeueAfterWhenQueueAbsent = 1 * time.Second |
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.
lint: deadcode
Looks like the patch from #504 was dropped (as intended) without removing the const
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.
Done
Sorry for the late comments, wifi was out on the train. If these have already been fixed please ignore. |
Are you asking about the cluster that gets created, or the codebase the apis are built on? This is using the 1.11.0 : |
@chaosaffe Thanks for the first pass. I've addressed a few of the comments, but not all. |
@@ -298,59 +297,29 @@ func (d *ClusterDeployer) saveProviderComponentsToCluster(factory ProviderCompon | |||
} | |||
|
|||
func (d *ClusterDeployer) applyClusterAPIStack(client clusterclient.Client, namespace string) error { | |||
glog.Info("Applying Cluster API APIServer") |
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.
Deleted because we no longer setup an aggregated apiserver
What's the thinking behind removing the Bazel build infrastructure? |
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've went through some commits again and everything seems reasonable. Looks very well done, no more comments from my side 👍
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pwittrock, roberthbailey 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 |
Woot! |
This PR is a WIP for migrating from apiserver-builder (aggregation based) to kubebuilder (CRD based). As a consequence of differences in the design philosophies a number of structural changes are made: