From 251edcac228e07d9ee2a3cafa49d84e962739939 Mon Sep 17 00:00:00 2001 From: Claudia Beresford Date: Tue, 15 Nov 2022 15:52:21 +0000 Subject: [PATCH] Add microvm kind ``` kubebuilder create api \ --group infrastructure \ --version v1alpha1 \ --kind Microvm ``` My go installation was weird. It was using 1.19.x but trying to use `tools` from `/usr/lib/go-1.18`. Fixed by changing `GOROOT`. --- PROJECT | 10 ++ api/v1alpha1/groupversion_info.go | 36 ++++++ api/v1alpha1/microvm_types.go | 64 ++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 115 ++++++++++++++++++ config/crd/kustomization.yaml | 21 ++++ config/crd/kustomizeconfig.yaml | 19 +++ .../crd/patches/cainjection_in_microvms.yaml | 7 ++ config/crd/patches/webhook_in_microvms.yaml | 16 +++ config/rbac/microvm_editor_role.yaml | 31 +++++ config/rbac/microvm_viewer_role.yaml | 27 ++++ .../infrastructure_v1alpha1_microvm.yaml | 12 ++ controllers/microvm_controller.go | 62 ++++++++++ controllers/suite_test.go | 80 ++++++++++++ go.mod | 2 + go.sum | 2 + main.go | 11 ++ 16 files changed, 515 insertions(+) create mode 100644 api/v1alpha1/groupversion_info.go create mode 100644 api/v1alpha1/microvm_types.go create mode 100644 api/v1alpha1/zz_generated.deepcopy.go create mode 100644 config/crd/kustomization.yaml create mode 100644 config/crd/kustomizeconfig.yaml create mode 100644 config/crd/patches/cainjection_in_microvms.yaml create mode 100644 config/crd/patches/webhook_in_microvms.yaml create mode 100644 config/rbac/microvm_editor_role.yaml create mode 100644 config/rbac/microvm_viewer_role.yaml create mode 100644 config/samples/infrastructure_v1alpha1_microvm.yaml create mode 100644 controllers/microvm_controller.go create mode 100644 controllers/suite_test.go diff --git a/PROJECT b/PROJECT index 633a85f..10dd752 100644 --- a/PROJECT +++ b/PROJECT @@ -3,4 +3,14 @@ layout: - go.kubebuilder.io/v3 projectName: microvm-operator repo: github.com/weaveworks-liquidmetal/microvm-operator +resources: +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: flintlock.x-k8s.io + group: infrastructure + kind: Microvm + path: github.com/weaveworks-liquidmetal/microvm-operator/api/v1alpha1 + version: v1alpha1 version: "3" diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/groupversion_info.go new file mode 100644 index 0000000..2318e90 --- /dev/null +++ b/api/v1alpha1/groupversion_info.go @@ -0,0 +1,36 @@ +/* +Copyright 2022 Weaveworks. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=infrastructure.flintlock.x-k8s.io +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "infrastructure.flintlock.x-k8s.io", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/api/v1alpha1/microvm_types.go b/api/v1alpha1/microvm_types.go new file mode 100644 index 0000000..70cb7f7 --- /dev/null +++ b/api/v1alpha1/microvm_types.go @@ -0,0 +1,64 @@ +/* +Copyright 2022 Weaveworks. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// MicrovmSpec defines the desired state of Microvm +type MicrovmSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Foo is an example field of Microvm. Edit microvm_types.go to remove/update + Foo string `json:"foo,omitempty"` +} + +// MicrovmStatus defines the observed state of Microvm +type MicrovmStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// Microvm is the Schema for the microvms API +type Microvm struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec MicrovmSpec `json:"spec,omitempty"` + Status MicrovmStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// MicrovmList contains a list of Microvm +type MicrovmList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Microvm `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Microvm{}, &MicrovmList{}) +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000..9541113 --- /dev/null +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,115 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022 Weaveworks. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Microvm) DeepCopyInto(out *Microvm) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Microvm. +func (in *Microvm) DeepCopy() *Microvm { + if in == nil { + return nil + } + out := new(Microvm) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Microvm) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MicrovmList) DeepCopyInto(out *MicrovmList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Microvm, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MicrovmList. +func (in *MicrovmList) DeepCopy() *MicrovmList { + if in == nil { + return nil + } + out := new(MicrovmList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MicrovmList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MicrovmSpec) DeepCopyInto(out *MicrovmSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MicrovmSpec. +func (in *MicrovmSpec) DeepCopy() *MicrovmSpec { + if in == nil { + return nil + } + out := new(MicrovmSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MicrovmStatus) DeepCopyInto(out *MicrovmStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MicrovmStatus. +func (in *MicrovmStatus) DeepCopy() *MicrovmStatus { + if in == nil { + return nil + } + out := new(MicrovmStatus) + in.DeepCopyInto(out) + return out +} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml new file mode 100644 index 0000000..c3d3cc5 --- /dev/null +++ b/config/crd/kustomization.yaml @@ -0,0 +1,21 @@ +# This kustomization.yaml is not intended to be run by itself, +# since it depends on service name and namespace that are out of this kustomize package. +# It should be run by config/default +resources: +- bases/infrastructure.flintlock.x-k8s.io_microvms.yaml +#+kubebuilder:scaffold:crdkustomizeresource + +patchesStrategicMerge: +# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. +# patches here are for enabling the conversion webhook for each CRD +#- patches/webhook_in_microvms.yaml +#+kubebuilder:scaffold:crdkustomizewebhookpatch + +# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. +# patches here are for enabling the CA injection for each CRD +#- patches/cainjection_in_microvms.yaml +#+kubebuilder:scaffold:crdkustomizecainjectionpatch + +# the following config is for teaching kustomize how to do kustomization for CRDs. +configurations: +- kustomizeconfig.yaml diff --git a/config/crd/kustomizeconfig.yaml b/config/crd/kustomizeconfig.yaml new file mode 100644 index 0000000..ec5c150 --- /dev/null +++ b/config/crd/kustomizeconfig.yaml @@ -0,0 +1,19 @@ +# This file is for teaching kustomize how to substitute name and namespace reference in CRD +nameReference: +- kind: Service + version: v1 + fieldSpecs: + - kind: CustomResourceDefinition + version: v1 + group: apiextensions.k8s.io + path: spec/conversion/webhook/clientConfig/service/name + +namespace: +- kind: CustomResourceDefinition + version: v1 + group: apiextensions.k8s.io + path: spec/conversion/webhook/clientConfig/service/namespace + create: false + +varReference: +- path: metadata/annotations diff --git a/config/crd/patches/cainjection_in_microvms.yaml b/config/crd/patches/cainjection_in_microvms.yaml new file mode 100644 index 0000000..864db8e --- /dev/null +++ b/config/crd/patches/cainjection_in_microvms.yaml @@ -0,0 +1,7 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: microvms.infrastructure.flintlock.x-k8s.io diff --git a/config/crd/patches/webhook_in_microvms.yaml b/config/crd/patches/webhook_in_microvms.yaml new file mode 100644 index 0000000..bb44983 --- /dev/null +++ b/config/crd/patches/webhook_in_microvms.yaml @@ -0,0 +1,16 @@ +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: microvms.infrastructure.flintlock.x-k8s.io +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1 diff --git a/config/rbac/microvm_editor_role.yaml b/config/rbac/microvm_editor_role.yaml new file mode 100644 index 0000000..346ee0a --- /dev/null +++ b/config/rbac/microvm_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit microvms. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: microvm-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: microvm-operator + app.kubernetes.io/part-of: microvm-operator + app.kubernetes.io/managed-by: kustomize + name: microvm-editor-role +rules: +- apiGroups: + - infrastructure.flintlock.x-k8s.io + resources: + - microvms + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - infrastructure.flintlock.x-k8s.io + resources: + - microvms/status + verbs: + - get diff --git a/config/rbac/microvm_viewer_role.yaml b/config/rbac/microvm_viewer_role.yaml new file mode 100644 index 0000000..09dd67f --- /dev/null +++ b/config/rbac/microvm_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view microvms. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: microvm-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: microvm-operator + app.kubernetes.io/part-of: microvm-operator + app.kubernetes.io/managed-by: kustomize + name: microvm-viewer-role +rules: +- apiGroups: + - infrastructure.flintlock.x-k8s.io + resources: + - microvms + verbs: + - get + - list + - watch +- apiGroups: + - infrastructure.flintlock.x-k8s.io + resources: + - microvms/status + verbs: + - get diff --git a/config/samples/infrastructure_v1alpha1_microvm.yaml b/config/samples/infrastructure_v1alpha1_microvm.yaml new file mode 100644 index 0000000..20fbb0f --- /dev/null +++ b/config/samples/infrastructure_v1alpha1_microvm.yaml @@ -0,0 +1,12 @@ +apiVersion: infrastructure.flintlock.x-k8s.io/v1alpha1 +kind: Microvm +metadata: + labels: + app.kubernetes.io/name: microvm + app.kubernetes.io/instance: microvm-sample + app.kubernetes.io/part-of: microvm-operator + app.kuberentes.io/managed-by: kustomize + app.kubernetes.io/created-by: microvm-operator + name: microvm-sample +spec: + # TODO(user): Add fields here diff --git a/controllers/microvm_controller.go b/controllers/microvm_controller.go new file mode 100644 index 0000000..86ff6ea --- /dev/null +++ b/controllers/microvm_controller.go @@ -0,0 +1,62 @@ +/* +Copyright 2022 Weaveworks. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controllers + +import ( + "context" + + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/log" + + infrastructurev1alpha1 "github.com/weaveworks-liquidmetal/microvm-operator/api/v1alpha1" +) + +// MicrovmReconciler reconciles a Microvm object +type MicrovmReconciler struct { + client.Client + Scheme *runtime.Scheme +} + +//+kubebuilder:rbac:groups=infrastructure.flintlock.x-k8s.io,resources=microvms,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=infrastructure.flintlock.x-k8s.io,resources=microvms/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=infrastructure.flintlock.x-k8s.io,resources=microvms/finalizers,verbs=update + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// TODO(user): Modify the Reconcile function to compare the state specified by +// the Microvm object against the actual cluster state, and then +// perform operations to make the cluster state reflect the state specified by +// the user. +// +// For more details, check Reconcile and its Result here: +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile +func (r *MicrovmReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + _ = log.FromContext(ctx) + + // TODO(user): your logic here + + return ctrl.Result{}, nil +} + +// SetupWithManager sets up the controller with the Manager. +func (r *MicrovmReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&infrastructurev1alpha1.Microvm{}). + Complete(r) +} diff --git a/controllers/suite_test.go b/controllers/suite_test.go new file mode 100644 index 0000000..58e2ce8 --- /dev/null +++ b/controllers/suite_test.go @@ -0,0 +1,80 @@ +/* +Copyright 2022 Weaveworks. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controllers + +import ( + "path/filepath" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" + + infrastructurev1alpha1 "github.com/weaveworks-liquidmetal/microvm-operator/api/v1alpha1" + //+kubebuilder:scaffold:imports +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var cfg *rest.Config +var k8sClient client.Client +var testEnv *envtest.Environment + +func TestAPIs(t *testing.T) { + RegisterFailHandler(Fail) + + RunSpecs(t, "Controller Suite") +} + +var _ = BeforeSuite(func() { + logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) + + By("bootstrapping test environment") + testEnv = &envtest.Environment{ + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, + } + + var err error + // cfg is defined in this file globally. + cfg, err = testEnv.Start() + Expect(err).NotTo(HaveOccurred()) + Expect(cfg).NotTo(BeNil()) + + err = infrastructurev1alpha1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + //+kubebuilder:scaffold:scheme + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) + +}) + +var _ = AfterSuite(func() { + By("tearing down the test environment") + err := testEnv.Stop() + Expect(err).NotTo(HaveOccurred()) +}) diff --git a/go.mod b/go.mod index 364fc62..63f78ed 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,8 @@ module github.com/weaveworks-liquidmetal/microvm-operator go 1.19 require ( + github.com/onsi/ginkgo/v2 v2.1.4 + github.com/onsi/gomega v1.19.0 k8s.io/apimachinery v0.25.0 k8s.io/client-go v0.25.0 sigs.k8s.io/controller-runtime v0.13.0 diff --git a/go.sum b/go.sum index 7441f10..d51d467 100644 --- a/go.sum +++ b/go.sum @@ -278,7 +278,9 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= +github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/main.go b/main.go index a234283..8dc4a7d 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,9 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" + + infrastructurev1alpha1 "github.com/weaveworks-liquidmetal/microvm-operator/api/v1alpha1" + "github.com/weaveworks-liquidmetal/microvm-operator/controllers" //+kubebuilder:scaffold:imports ) @@ -41,6 +44,7 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) + utilruntime.Must(infrastructurev1alpha1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -85,6 +89,13 @@ func main() { os.Exit(1) } + if err = (&controllers.MicrovmReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "Microvm") + os.Exit(1) + } //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {