Skip to content

Commit

Permalink
verify e2e working examples (#8)
Browse files Browse the repository at this point in the history
* verify e2e working examples

* readme update

* further instructions

* make release
  • Loading branch information
sadysnaat authored Aug 5, 2021
1 parent 962c8db commit 2e43282
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 18 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<your docker repo>
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

12 changes: 6 additions & 6 deletions examples/cluster3-baremetal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
17 changes: 12 additions & 5 deletions pkg/maas/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 2e43282

Please sign in to comment.