Skip to content

Commit 5f82c72

Browse files
authored
Use cluster-template for our sample cluster (#47)
1 parent 5251d2c commit 5f82c72

File tree

7 files changed

+47
-134
lines changed

7 files changed

+47
-134
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,21 @@ Next install our CAPMS provider into the cluster.
2222
make push-to-capi-lab
2323
```
2424

25-
A basic cluster configuration resides in `config/samples`.
25+
Before creating a cluster some manual steps are required beforehand: you need to allocate a node network and a firewall.
2626

2727
```bash
28-
kubectl apply -k config/samples
28+
make -C capi-lab node-network firewall
2929
```
3030

31-
For now it is required to manually create the firewall. This might be changed in the future, but for now run:
31+
A basic cluster configuration that relies on `config/clusterctl-templates/cluster-template.yaml` and uses the aforementioned node network can be generated and applied to the management cluster using a make target.
32+
33+
```bash
34+
make apply-sample-cluster
35+
```
36+
37+
Once the control plane node has phoned home, run:
3238

3339
```bash
34-
make -C capi-lab firewall
35-
# once the firewall is up run
3640
make -C capi-lab mtu-fix
3741
```
3842

@@ -112,19 +116,17 @@ make deploy IMG=<some-registry>/cluster-api-provider-metal-stack:tag
112116
privileges or be logged in as admin.
113117

114118
**Create instances of your solution**
115-
You can apply the samples (examples) from the config/sample:
119+
You can apply the sample cluster configuration:
116120

117121
```sh
118-
kubectl apply -k config/samples/
122+
make apply-sample-cluster
119123
```
120124

121-
>**NOTE**: Ensure that the samples has default values to test it out.
122-
123125
### To Uninstall
124126
**Delete the instances (CRs) from the cluster:**
125127

126128
```sh
127-
kubectl delete -k config/samples/
129+
make delete-sample-cluster
128130
```
129131

130132
**Delete the APIs(CRDs) from the cluster:**

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,34 @@ endef
244244

245245
# mini-lab developer environment
246246

247+
export METAL_PARTITION ?= mini-lab
248+
export METAL_PROJECT_ID ?= 00000000-0000-0000-0000-000000000001
249+
export METAL_NODE_NETWORK_ID ?= $(shell metalctl network list --name metal-test -o template --template '{{ .id }}')
250+
export CONTROL_PLANE_ENDPOINT ?= "203.0.113.129:443"
251+
export CONTROL_PLANE_MACHINE_IMAGE ?= ubuntu-24.04
252+
export CONTROL_PLANE_MACHINE_SIZE ?= v1-small-x86
253+
export WORKER_MACHINE_IMAGE ?= ubuntu-24.04
254+
export WORKER_MACHINE_SIZE ?= v1-small-x86
255+
247256
.PHONY: up
248257
up: bake deploy-cloud-stack
258+
259+
.PHONY: apply-sample-cluster
260+
apply-sample-cluster: generate manifests
261+
clusterctl generate cluster metal-test \
262+
--kubeconfig=$(KUBECONFIG) \
263+
--worker-machine-count 1 \
264+
--control-plane-machine-count 1 \
265+
--kubernetes-version 1.30.6 \
266+
--from config/clusterctl-templates/cluster-template.yaml \
267+
| kubectl --kubeconfig=$(KUBECONFIG) apply -f -
268+
269+
.PHONY: delete-sample-cluster
270+
delete-sample-cluster: generate manifests
271+
clusterctl generate cluster metal-test \
272+
--kubeconfig=$(KUBECONFIG) \
273+
--worker-machine-count 1 \
274+
--control-plane-machine-count 1 \
275+
--kubernetes-version 1.30.6 \
276+
--from config/clusterctl-templates/cluster-template.yaml \
277+
| kubectl --kubeconfig=$(KUBECONFIG) delete -f -

capi-lab/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ controller:
3838
firewall:
3939
metalctl firewall create --description fw --name fw --hostname fw --project 00000000-0000-0000-0000-000000000001 --partition mini-lab --image firewall-ubuntu-3.0 --size v1-small-x86 --firewall-rules-file=firewall-rules.yaml --networks internet-mini-lab,$(shell metalctl network list --name metal-test -o template --template '{{ .id }}')
4040

41+
.PHONY: node-network
42+
node-network:
43+
metalctl network allocate --description "node network for metal-test cluster" --name metal-test --project 00000000-0000-0000-0000-000000000001 --partition mini-lab
44+
4145
.PHONY: mtu-fix
4246
mtu-fix:
4347
cd mini-lab && ssh -F files/ssh/config leaf01 'ip link set dev vtep-1001 mtu 9100 && echo done'

config/clusterctl-templates/cluster-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ metadata:
2727
spec:
2828
projectID: ${METAL_PROJECT_ID}
2929
partition: ${METAL_PARTITION}
30+
nodeNetworkID: ${METAL_NODE_NETWORK_ID}
3031
---
3132
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
3233
kind: MetalStackMachineTemplate

config/clusterctl-templates/example_variables.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ export METAL_API_HMAC=metal-admin
44
export METAL_PROJECT_ID=00000000-0000-0000-0000-000000000001
55
export POD_CIDR=10.240.0.0/12
66
export METAL_PARTITION=mini-lab
7+
export METAL_NODE_NETWORK_ID=00000000-0000-0000-0000-000000000002
78

89
export FIREWALL_MACHINE_SIZE=v1-small-x86
910
export FIREWALL_MACHINE_IMAGE=
1011
export FIREWALL_NETWORKS=[internet]
1112

12-
export NODE_NETWORK_ID=00000000-0000-0000-0000-000000000002
1313
export CONTROL_PLANE_ENDPOINT=203.0.113.129:443
1414
export CONTROL_PLANE_PORT=443
1515
export CONTROL_PLANE_MACHINE_SIZE=v1-small-x86

config/samples/example-kubeadm.yaml

Lines changed: 0 additions & 117 deletions
This file was deleted.

config/samples/kustomization.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)