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

Cluster API provider - initial skeleton for Bootstrap & ControlPlane providers #119

Merged
merged 11 commits into from
Jun 9, 2023

Conversation

jnummelin
Copy link
Member

Very rough skeleton for control plane provider using k0smotron

This implements following features:

  • ControlPlane provider using k0smotron controller
  • Bootstrap provider for worker nodes

There's quite a few things to still "fix":

  • Proper status handling, now the bootstrap&controlplane controllers output too many errors as they cannot do stuff. They should be able to better rely on status fields of depending things.
  • Version is not properly used in Bootstrap provider
  • Docs

I've currently been testing with Hetzner provider only but other infra providers should work too as they all adhere to Cluster API contracts.

@jnummelin jnummelin requested a review from a team as a code owner June 5, 2023 11:07
@jnummelin jnummelin requested review from makhov and juanluisvaladas and removed request for a team June 5, 2023 11:07
@@ -137,7 +150,7 @@ func (kmc *Cluster) GetStatefulSetName() string {
}

func (kmc *Cluster) GetAdminConfigSecretName() string {
return fmt.Sprintf("kmc-admin-kubeconfig-%s", kmc.Name)
return fmt.Sprintf("%s-kubeconfig", kmc.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.

This is to match the Cluster API conventions/contracts

@@ -65,6 +65,8 @@ type ClusterSpec struct {
//+kubebuilder:validation:Enum:=kuberouter;calico;custom
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="cniPlugin is immutable"
CNIPlugin string `json:"cniPlugin,omitempty"`
// CertificateRefs defines the certificate references.
CertificateRefs []CertificateRef `json:"certificateRefs,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

This allows passing certs from secrets when using Cluster API

config/crd/kustomization.yaml Outdated Show resolved Hide resolved
@jnummelin jnummelin force-pushed the capi-provider branch 4 times, most recently from c9a073a to 4929306 Compare June 5, 2023 13:30
Copy link
Collaborator

@juanluisvaladas juanluisvaladas left a comment

Choose a reason for hiding this comment

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

Just a couple questions, obviously there are a lot of things to address but given the early stage I'm not making a full code review.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@@ -6,10 +6,13 @@ require (
github.com/k0sproject/k0s v1.27.2-0.20230504131248-94378e521a29
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
github.com/pkg/errors v0.9.1
Copy link
Contributor

Choose a reason for hiding this comment

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

github.com/pkg/errors is legacy pkg/errors#245

apierrors.IsNotFound(errors.Cause(err)) should work as apierrors.IsNotFound(err).
errors.Wrap(..) => errors.Join(...)
errors.Cause(err) == x => errors.Is(err, x)

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. I took some inspiration for these from the upstream cluster api providers which seem to use these heavily still. And in the core of cluster api there's lot of usage of pkg/errors. I wonder if the changes would be fully compatible 🤔

@jnummelin jnummelin force-pushed the capi-provider branch 3 times, most recently from 13dc71d to 0905fed Compare June 7, 2023 12:58
Copy link
Contributor

@makhov makhov left a comment

Choose a reason for hiding this comment

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

LGTM in general. Left some minor comments

Copy link
Collaborator

@juanluisvaladas juanluisvaladas left a comment

Choose a reason for hiding this comment

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

It's mostly fine, other than the install.yaml which needs to be regenerated the rest are just nits. Also we need github actions to detect this in the future.

internal/cloudinit/cloudinit_test.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
docs/cluster-api.md Show resolved Hide resolved
@jnummelin
Copy link
Member Author

@makhov @juanluisvaladas I fixed all the commented bits now. PTAL again

Copy link
Collaborator

@juanluisvaladas juanluisvaladas left a comment

Choose a reason for hiding this comment

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

As a side note, I noticed the new API is not defined in the PROJECT file. I imagine this happened because you added this manually without using the kubebuilder CLI. If this is the case we should either remove the PROJECT file or make sure it's consistent.

The PROJECT file isn't adding a lot of value and I noticed it's already inconsistent in the main branch (became inconssistent after renaming the Cluster type) so I'm in favour of removing it entirely.

Anyway this doesn't have to be done in this PR, I'm requesting changes for the hertzner sample, the rest isn't important enough to block. The other changes look good to me.

config/samples/capi-hetzner.yaml Outdated Show resolved Hide resolved
config/samples/capi-hetzner.yaml Outdated Show resolved Hide resolved
api/bootstrap/v1beta1/kzeros_types.go Outdated Show resolved Hide resolved
Signed-off-by: Jussi Nummelin <[email protected]>

Very rough skeleton for control plane provider using k0smotron

Signed-off-by: Jussi Nummelin <[email protected]>

Use k8s 1.27 as dependency

Signed-off-by: Jussi Nummelin <[email protected]>
Signed-off-by: Jussi Nummelin <[email protected]>
Signed-off-by: Jussi Nummelin <[email protected]>
Signed-off-by: Jussi Nummelin <[email protected]>
Signed-off-by: Jussi Nummelin <[email protected]>
…ller was missing node get/list permissions.

Also remove stale hetzner example

Signed-off-by: Jussi Nummelin <[email protected]>
@jnummelin jnummelin merged commit 0b62b94 into k0sproject:main Jun 9, 2023
@jnummelin jnummelin deleted the capi-provider branch June 9, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants