Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Update to v1alpha3 #172

Merged
merged 72 commits into from Jun 24, 2020
Merged

Update to v1alpha3 #172

merged 72 commits into from Jun 24, 2020

Conversation

bboreham
Copy link
Contributor

@bboreham bboreham commented Apr 28, 2020

Fixes #170

  • Since upstream CAPI has changed so much this is an extremely breaking change: there is no automated upgrade from v1alpha1.
  • The v1alpha1 types are left in place for anyone who wants to run programs containing both.
  • We now run two controllers - upstream CAPI controller for Machine and Cluster, and wks controller for BareMetalMachine and BareMetalCluster.
  • Minimum Kubernetes version is now 1.16.0, as required by upstream CAPI.
  • Examples are not updated yet

@bboreham bboreham force-pushed the update-to-v1alpha3 branch 2 times, most recently from 0347619 to 26d795b Compare April 28, 2020 15:04
Copy link

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

I've not looked at the parts that do the actual ssh / kubeadm stuff. I've just looked at the CAPI specific parts.

pkg/baremetal/v1alpha3/types.go Show resolved Hide resolved
if err != nil {
log.Fatal(err)
}
if err = clusterReconciler.SetupWithManager(mgr, controller.Options{MaxConcurrentReconciles: 1}); err != nil {

Choose a reason for hiding this comment

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

Can the reconcile occur in parallel or does it have to be a singleton? A lot of the other provider expose a concurrency flag.

@@ -342,22 +393,11 @@ func (a *MachineActuator) installNewBootstrapToken(ns string) (*corev1.Secret, e
}

// Delete the machine. If no error is returned, it is assumed that all dependent resources have been cleaned up.
func (a *MachineActuator) Delete(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine) error {
contextLog := log.WithFields(log.Fields{"machine": machine.Name, "cluster": cluster.Name})
func (a *MachineController) delete(ctx context.Context, c *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, bmm *baremetalspecv1.BareMetalMachine) error {

Choose a reason for hiding this comment

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

Could we name this reconcileDelete instead to have consistency with other providers?

return ctrl.Result{}, nil
}

func (a *MachineController) create(ctx context.Context, c *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, bmm *baremetalspecv1.BareMetalMachine) error {

Choose a reason for hiding this comment

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

Could this be called reconcileNormal or reconcile instead? This will be consistent with other providers.

pkg/baremetal/v1alpha3/types.go Outdated Show resolved Hide resolved
func FirstMaster(machines []*clusterv1.Machine) *clusterv1.Machine {
for _, machine := range machines {
// Machines and BareMetalMachines must be in the same order
func FirstMaster(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine) (*clusterv1.Machine, *baremetalspecv1.BareMetalMachine) {
Copy link

Choose a reason for hiding this comment

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

I wonder if we should rethink how we denote master nodes. I'm not sure a label on Machine is the right place. I think we should probably implement a capi control plane instead to make it explicit. https://cluster-api.sigs.k8s.io/developer/architecture/controllers/control-plane.html

Choose a reason for hiding this comment

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

Assuming there is no way to reuse the existing kubeadm control plane. Or perhaps support both?

pkg/kubernetes/config/kubeconfig.go Outdated Show resolved Hide resolved
Copy link
Contributor

@luxas luxas left a comment

Choose a reason for hiding this comment

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

Awesome work @bboreham 👏!
I think we shall merge this now, and fix the comments I spot here in smaller follow-up PRs.

"github.com/weaveworks/wksctl/pkg/apis"
"github.com/weaveworks/wksctl/pkg/apis/wksprovider/controller/wksctl"
wks "github.com/weaveworks/wksctl/pkg/apis/wksprovider/controller/wksctl"
baremetalv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd either name this baremetalapi, baremetalext (as in external version), just baremetal or fully-qualified baremetalv1alpha3, but to me v1 suffix means stable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clustercommon "sigs.k8s.io/cluster-api/pkg/apis/cluster/common"
capicluster "sigs.k8s.io/cluster-api/pkg/controller/cluster"
capimachine "sigs.k8s.io/cluster-api/pkg/controller/machine"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Maybe just clusterapi?

machineActuator, err := wks.NewMachineActuator(wks.MachineActuatorParams{
EventRecorder: mgr.GetRecorder(wks.ProviderName + "-controller"),

machineController, err := wks.NewMachineController(wks.MachineControllerParams{
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, maybe rename Controller to Reconciler

}

var ctlrNamespace string
{
Copy link
Contributor

Choose a reason for hiding this comment

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

are you creating a new scope here? maybe add a comment why

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To limit where client created on the line below can be used.
I suspect the correct fix is to not care about namespaces.

if err != nil {
log.Fatalf("failed to create client: %s", err)
}
ctlrNamespace, err = initializeControllerNamespace(client)
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this doing? machineutil.GetKubernetesNamespaceFromMachines that is called by this fn doesn't seem to change state, but this name suggests it does

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, but the name of that function did not change in this PR.

@@ -0,0 +1,46 @@
package v1alpha3
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment for later, but I'd maybe keep the v1alpha1 packages here for a grace period for being able to convert objects over eventually.

A comment for now: this is an api, it should exist under pkg/apis

return nil
}

func NewScheme() (*runtime.Scheme, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function seems unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

return nil, err
}
// Parse parses the provided machines io.Reader.
func Parse(r io.ReadCloser) (ml []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: I've coded a pretty cool serializer that can do these things in a generic manner, so we can use that later to avoid writing the same code over and over again. But for a future PR.

}
Populate(machines)

errors := Validate(machines)
return errorsHandler(machines, errors)
errors := Validate(machines, bl)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd put validation of the API objects in pkg/apis/baremetal/validation

@@ -38,14 +38,14 @@ var AddToScheme = SchemeBuilder.AddToScheme

func addKnownTypes(scheme *runtime.Scheme) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function seems weird. I'd use the AddToScheme methods instead to get what's actually needed without duplicating code.

bboreham and others added 24 commits June 24, 2020 14:43
Blank means use the default, but when ImageRepository is set the
current code is failing.
Almost everywhere uses Public.Address or Private.Address,
so these other ones are just a source of confusion.
Signed-off-by: Dennis Marttinen <dennis@weave.works>
so it can be used by other packages
It's awkward having to do this every time the controller does anything.
This means the controller will see it as unchanged when it fires up.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to ClusterAPI v1alpha3
4 participants