From 2e4328238273c09f2f8c742f9dc565b375883620 Mon Sep 17 00:00:00 2001 From: Deepak Sharma Date: Thu, 5 Aug 2021 23:33:41 +0530 Subject: [PATCH] verify e2e working examples (#8) * verify e2e working examples * readme update * further instructions * make release --- Makefile | 6 +++- README.md | 54 ++++++++++++++++++++++++++++++++ examples/cluster3-baremetal.yaml | 12 +++---- go.mod | 4 +-- go.sum | 8 ++--- pkg/maas/machine/machine.go | 17 +++++++--- 6 files changed, 83 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index ccf6604..c0251a3 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ ifeq ($(VERSION), 0.0.0) endif .PHONY: release-manifests -release-manifests: +release-manifests: test $(MAKE) manifests STAGE=release MANIFEST_DIR=$(RELEASE_DIR) PULL_POLICY=IfNotPresent IMAGE=$(RELEASE_CONTROLLER_IMG):$(VERSION) cp metadata.yaml $(RELEASE_DIR)/metadata.yaml @@ -147,3 +147,7 @@ mock: $(MOCKGEN) clean-release: rm -rf $(RELEASE_DIR) + +release: release-manifests + $(MAKE) docker-build IMG=$(RELEASE_CONTROLLER_IMG):$(VERSION) + $(MAKE) docker-push IMG=$(RELEASE_CONTROLLER_IMG):$(VERSION) diff --git a/README.md b/README.md index d330be1..ab05eaa 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,57 @@ Cluster API Provider MaaS +# Getting Started + +## Image Generation + + +## Set up + +create kind cluster + +```bash +kind create cluster +``` + +install clusterctl v3 + https://release-0-3.cluster-api.sigs.k8s.io/user/quick-start.html + +run +``` +clusterctl init --core cluster-api:v0.3.19 --bootstrap kubeadm:v0.3.19 --control-plane kubeadm:v0.3.19 +``` + +Makefile set IMG= +run +``` +make docker-build && make docker-push +``` + +generate dev manifests +``` +make dev-manifests +``` + +edit _build/dev/infrastructure-components.yaml +```yaml +apiVersion: v1 +kind: Secret +metadata: + labels: + cluster.x-k8s.io/provider: infrastructure-maas + name: capmaas-manager-bootstrap-credentials + namespace: capmaas-system +stringData: + MAAS_API_KEY: _ #${MAAS_API_KEY} + MAAS_ENDPOINT: _ #${MAAS_ENDPOINT} +type: Opaque +``` + +run +```shell +kubectl apply -f _build/dev/infrastructure-components.yaml +``` + +wait for capi and capmaas pods to be running + diff --git a/examples/cluster3-baremetal.yaml b/examples/cluster3-baremetal.yaml index e9b0a8b..f00eff4 100644 --- a/examples/cluster3-baremetal.yaml +++ b/examples/cluster3-baremetal.yaml @@ -41,8 +41,8 @@ spec: spec: minCPU: 4 minMemory: 8192 - resourcePool: GPU - image: spectro-u18-k11815 +# resourcePool: GPU + image: u-1804-0-k-11912-0 --- apiVersion: controlplane.cluster.x-k8s.io/v1alpha3 kind: KubeadmControlPlane @@ -51,7 +51,7 @@ metadata: namespace: default spec: replicas: 1 - version: v1.18.15 + version: v1.19.12 infrastructureTemplate: apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 kind: MaasMachineTemplate @@ -192,8 +192,8 @@ spec: spec: minCPU: 4 minMemory: 8192 - resourcePool: GPU - image: spectro-u18-k11815 +# resourcePool: GPU + image: u-1804-0-k-11912-0 --- apiVersion: cluster.x-k8s.io/v1alpha3 kind: MachineDeployment @@ -209,7 +209,7 @@ spec: template: spec: clusterName: cluster-maas3 - version: 1.18.15 + version: 1.19.12 bootstrap: configRef: apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3 diff --git a/go.mod b/go.mod index b16b9c2..193040d 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.15 require ( github.com/go-logr/logr v0.3.0 github.com/golang/mock v1.2.0 - github.com/onsi/gomega v1.10.1 // indirect + github.com/onsi/gomega v1.10.1 github.com/pkg/errors v0.9.1 github.com/prometheus/common v0.10.0 - github.com/spectrocloud/maas-client-go v0.0.1-beta + github.com/spectrocloud/maas-client-go v0.0.1-beta1.0.20210805102600-28f250f3bdc7 github.com/spf13/pflag v1.0.5 k8s.io/api v0.17.9 k8s.io/apimachinery v0.17.9 diff --git a/go.sum b/go.sum index 58bfa4e..fa4802f 100644 --- a/go.sum +++ b/go.sum @@ -357,10 +357,10 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spectrocloud/maas-client-go v0.0.1-alpha h1:byZ8ThX/WRyJkYUdYzO+UQceZhoWlUeoeaI5JTnd1Do= -github.com/spectrocloud/maas-client-go v0.0.1-alpha/go.mod h1:ih7QvZPySD8fiIo56wO+W40w1ojiqNnpLP0Zb6nKvKk= -github.com/spectrocloud/maas-client-go v0.0.1-beta h1:PQtT0NH28+WCQpRd0RZ32qukn3hTdLRm+eTLvxg1+1I= -github.com/spectrocloud/maas-client-go v0.0.1-beta/go.mod h1:ih7QvZPySD8fiIo56wO+W40w1ojiqNnpLP0Zb6nKvKk= +github.com/spectrocloud/maas-client-go v0.0.1-beta1 h1:OZGxJl5AR+4mM2w+ylJewYIORBGBCMy2kMh/iMCkZsw= +github.com/spectrocloud/maas-client-go v0.0.1-beta1/go.mod h1:ih7QvZPySD8fiIo56wO+W40w1ojiqNnpLP0Zb6nKvKk= +github.com/spectrocloud/maas-client-go v0.0.1-beta1.0.20210805102600-28f250f3bdc7 h1:4HsJjvyBXs8co1ss78oEh7OQbBG+h8E7cRx1WRaRtE0= +github.com/spectrocloud/maas-client-go v0.0.1-beta1.0.20210805102600-28f250f3bdc7/go.mod h1:ih7QvZPySD8fiIo56wO+W40w1ojiqNnpLP0Zb6nKvKk= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= diff --git a/pkg/maas/machine/machine.go b/pkg/maas/machine/machine.go index f0763d0..7fef431 100644 --- a/pkg/maas/machine/machine.go +++ b/pkg/maas/machine/machine.go @@ -59,14 +59,21 @@ func (s *Service) DeployMachine(userDataB64 string) (_ *infrav1.Machine, rerr er failureDomain = s.scope.Machine.Spec.FailureDomain } - m, err := s.maasClient. + allocator := s.maasClient. Machines(). Allocator(). - WithZone(*failureDomain). - WithResourcePool(*mm.Spec.ResourcePool). WithCPUCount(*mm.Spec.MinCPU). - WithMemory(*mm.Spec.MinMemory). - Allocate(ctx) + WithMemory(*mm.Spec.MinMemory) + + if failureDomain != nil { + allocator.WithZone(*failureDomain) + } + + if mm.Spec.ResourcePool != nil { + allocator.WithResourcePool(*mm.Spec.ResourcePool) + } + + m, err := allocator.Allocate(ctx) if err != nil { return nil, errors.Wrapf(err, "Unable to allocate machine") }