Skip to content

Commit a4e09c5

Browse files
Merge branch 'main' into machine-labels
2 parents 4a50b29 + 3219667 commit a4e09c5

File tree

11 files changed

+378
-63
lines changed

11 files changed

+378
-63
lines changed

CONTRIBUTING.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ make -C capi-lab node-network firewall
3131
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.
3232

3333
```bash
34-
make apply-sample-cluster
34+
make -C capi-lab apply-sample-cluster
3535
```
3636

3737
Once the control plane node has phoned home, run:
@@ -43,20 +43,14 @@ make -C capi-lab mtu-fix
4343
When the control plane node was provisioned, you can obtain the kubeconfig like:
4444

4545
```bash
46-
kubectl get secret metal-test-kubeconfig -o jsonpath='{.data.value}' | base64 -d > .capms-cluster-kubeconfig.yaml
47-
```
48-
49-
For now, the provider ID has to be manually added to the node object because we did not integrate the [metal-ccm](https://github.com/metal-stack/metal-ccm) yet:
50-
51-
```bash
52-
kubectl --kubeconfig=.capms-cluster-kubeconfig.yaml patch node <control-plane-node-name> --patch='{"spec":{"providerID": "metal://<machine-id>"}}'
46+
kubectl get secret metal-test-kubeconfig -o jsonpath='{.data.value}' | base64 -d > capi-lab/.capms-cluster-kubeconfig.yaml
5347
```
5448

5549
It is now expected to deploy a CNI to the cluster:
5650

5751
```bash
58-
kubectl --kubeconfig=.capms-cluster-kubeconfig.yaml create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.2/manifests/tigera-operator.yaml
59-
cat <<EOF | kubectl --kubeconfig=.capms-cluster-kubeconfig.yaml create -f -
52+
kubectl --kubeconfig=capi-lab/.capms-cluster-kubeconfig.yaml create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.2/manifests/tigera-operator.yaml
53+
cat <<EOF | kubectl --kubeconfig=capi-lab/.capms-cluster-kubeconfig.yaml create -f -
6054
apiVersion: operator.tigera.io/v1
6155
kind: Installation
6256
metadata:
@@ -81,10 +75,42 @@ EOF
8175
> [!note]
8276
> Actually, Calico should be configured using BGP (no overlay), eBPF and DSR. An example will be proposed in this repository at a later point in time.
8377
84-
As soon as the worker node was provisioned, the same provider ID patch as above is required:
78+
The node's provider ID is provided by the [metal-ccm](https://github.com/metal-stack/metal-ccm), which needs to be deployed into the cluster:
79+
80+
```bash
81+
make -C capi-lab deploy-metal-ccm
82+
```
83+
84+
If you want to provide service's of type load balancer through MetalLB by the metal-ccm, you need to deploy MetalLB:
8585

8686
```bash
87-
kubectl --kubeconfig=.capms-cluster-kubeconfig.yaml patch node <worker-node-name> --patch='{"spec":{"providerID": "metal://<machine-id>"}}'
87+
kubectl --kubeconfig capi-lab/.capms-cluster-kubeconfig.yaml apply --kustomize capi-lab/metallb
88+
```
89+
90+
For each node in your Kubernetes cluster, you need to create a BGP peer configuration. Replace the placeholders ({{
91+
NODE_ASN }}, {{ NODE_HOSTNAME }}, and {{ NODE_ROUTER_ID }}) with the appropriate values for each node.
92+
93+
```bash
94+
cat <<EOF | kubectl --kubeconfig=capi-lab/.capms-cluster-kubeconfig.yaml create -f -
95+
apiVersion: metallb.io/v1beta2
96+
kind: BGPPeer
97+
metadata:
98+
name: ${NODE_HOSTNAME}
99+
namespace: metallb-system
100+
spec:
101+
holdTime: 1m30s
102+
keepaliveTime: 0s
103+
myASN: ${NODE_ASN}
104+
nodeSelectors:
105+
- matchExpressions:
106+
- key: kubernetes.io/hostname
107+
operator: In
108+
values:
109+
- ${NODE_HOSTNAME}
110+
passwordSecret: {}
111+
peerASN: ${NODE_ASN}
112+
peerAddress: ${NODE_ROUTER_ID}
113+
EOF
88114
```
89115

90116
That's it!
@@ -112,21 +138,20 @@ make install
112138
make deploy IMG=<some-registry>/cluster-api-provider-metal-stack:tag
113139
```
114140

115-
> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin
116-
privileges or be logged in as admin.
141+
> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin.
117142
118143
**Create instances of your solution**
119144
You can apply the sample cluster configuration:
120145

121146
```sh
122-
make apply-sample-cluster
147+
make -C capi-lab apply-sample-cluster
123148
```
124149

125150
### To Uninstall
126151
**Delete the instances (CRs) from the cluster:**
127152

128153
```sh
129-
make delete-sample-cluster
154+
make -C capi-lab delete-sample-cluster
130155
```
131156

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

Makefile

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -241,36 +241,3 @@ mv $(1) $(1)-$(3) ;\
241241
} ;\
242242
ln -sf $(1)-$(3) $(1)
243243
endef
244-
245-
# mini-lab developer environment
246-
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_MACHINE_IMAGE ?= ubuntu-24.04
251-
export CONTROL_PLANE_MACHINE_SIZE ?= v1-small-x86
252-
export WORKER_MACHINE_IMAGE ?= ubuntu-24.04
253-
export WORKER_MACHINE_SIZE ?= v1-small-x86
254-
255-
.PHONY: up
256-
up: bake deploy-cloud-stack
257-
258-
.PHONY: apply-sample-cluster
259-
apply-sample-cluster: generate manifests
260-
clusterctl generate cluster metal-test \
261-
--kubeconfig=$(KUBECONFIG) \
262-
--worker-machine-count 1 \
263-
--control-plane-machine-count 1 \
264-
--kubernetes-version 1.30.6 \
265-
--from config/clusterctl-templates/cluster-template.yaml \
266-
| kubectl --kubeconfig=$(KUBECONFIG) apply -f -
267-
268-
.PHONY: delete-sample-cluster
269-
delete-sample-cluster: generate manifests
270-
clusterctl generate cluster metal-test \
271-
--kubeconfig=$(KUBECONFIG) \
272-
--worker-machine-count 1 \
273-
--control-plane-machine-count 1 \
274-
--kubernetes-version 1.30.6 \
275-
--from config/clusterctl-templates/cluster-template.yaml \
276-
| kubectl --kubeconfig=$(KUBECONFIG) delete -f -

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,5 @@ clusterctl generate cluster example --kubernetes-version v1.30.6 --infrastructur
5757
> Due to the early development stage the following manual actions are needed for the cluster to operate.
5858
5959
1. The firewall needs to be created manually.
60-
2. You need to install your CNI of choice. This is required due to CAPI.
61-
3. Control plane and worker nodes need to be patched.
62-
63-
```bash
64-
kubectl patch node <worker-node-name> --patch='{"spec":{"providerID": "metal://<machine-id>"}}'
65-
```
60+
2. The metal-ccm has to be deployed
61+
3. You need to install your CNI of choice. This is required due to CAPI.

capi-lab/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@ ANSIBLE_EXTRA_VARS_FILE=$(shell pwd)/mini-lab-overrides/extra-vars.yaml
55
KIND_EXPERIMENTAL_DOCKER_NETWORK=mini_lab_ext
66
KUBECONFIG := $(shell pwd)/mini-lab/.kubeconfig
77
MINI_LAB_FLAVOR=capms
8+
9+
METAL_API_URL=http://metal.203.0.113.1.nip.io:8080
10+
METAL_API_HMAC=metal-admin
811
METALCTL_API_URL=http://metal.203.0.113.1.nip.io:8080
912
METALCTL_HMAC=metal-admin
1013

14+
METAL_PARTITION ?= mini-lab
15+
METAL_PROJECT_ID ?= 00000000-0000-0000-0000-000000000001
16+
17+
CONTROL_PLANE_MACHINE_IMAGE ?= ubuntu-24.04
18+
CONTROL_PLANE_MACHINE_SIZE ?= v1-small-x86
19+
WORKER_MACHINE_IMAGE ?= ubuntu-24.04
20+
WORKER_MACHINE_SIZE ?= v1-small-x86
21+
1122
IMG ?= ghcr.io/metal-stack/cluster-api-metal-stack-controller:latest
1223

1324
.PHONY: up
@@ -47,7 +58,35 @@ firewall:
4758
node-network:
4859
metalctl network allocate --description "node network for metal-test cluster" --name metal-test --project 00000000-0000-0000-0000-000000000001 --partition mini-lab
4960

61+
.PHONY: apply-sample-cluster
62+
apply-sample-cluster:
63+
$(eval METAL_NODE_NETWORK_ID = $(shell metalctl network list --name metal-test -o template --template '{{ .id }}'))
64+
clusterctl generate cluster metal-test \
65+
--kubeconfig=$(KUBECONFIG) \
66+
--worker-machine-count 1 \
67+
--control-plane-machine-count 1 \
68+
--kubernetes-version 1.30.6 \
69+
--from ../config/clusterctl-templates/cluster-template.yaml \
70+
| kubectl --kubeconfig=$(KUBECONFIG) apply -f -
71+
72+
.PHONY: delete-sample-cluster
73+
delete-sample-cluster:
74+
$(eval METAL_NODE_NETWORK_ID = $(shell metalctl network list --name metal-test -o template --template '{{ .id }}'))
75+
clusterctl generate cluster metal-test \
76+
--kubeconfig=$(KUBECONFIG) \
77+
--worker-machine-count 1 \
78+
--control-plane-machine-count 1 \
79+
--kubernetes-version 1.30.6 \
80+
--from ../config/clusterctl-templates/cluster-template.yaml \
81+
| kubectl --kubeconfig=$(KUBECONFIG) delete -f -
82+
5083
.PHONY: mtu-fix
5184
mtu-fix:
5285
cd mini-lab && ssh -F files/ssh/config leaf01 'ip link set dev vtep-1001 mtu 9100 && echo done'
5386
cd mini-lab && ssh -F files/ssh/config leaf02 'ip link set dev vtep-1001 mtu 9100 && echo done'
87+
88+
.PHONY: deploy-metal-ccm
89+
deploy-metal-ccm:
90+
$(eval METAL_CLUSTER_ID = $(shell kubectl get metalstackclusters.infrastructure.cluster.x-k8s.io metal-test -ojsonpath='{.metadata.uid}'))
91+
$(eval METAL_NODE_NETWORK_ID = $(shell metalctl network list --name metal-test -o template --template '{{ .id }}'))
92+
cat metal-ccm.yaml | envsubst | kubectl --kubeconfig=.capms-cluster-kubeconfig.yaml apply -f -

capi-lab/firewall-rules.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ egress:
1313
protocol: TCP
1414
to:
1515
- 0.0.0.0/0
16+
- comment: allow outgoing traffic to control plane for ccm
17+
ports:
18+
- 8080
19+
protocol: TCP
20+
to:
21+
- 203.0.113.0/24
1622
- comment: allow outgoing DNS and NTP traffic via UDP
1723
ports:
1824
- 53

0 commit comments

Comments
 (0)