Skip to content

Commit 540f598

Browse files
authored
Add first flavors for cluster templates. (#110)
1 parent 4a92c81 commit 540f598

File tree

9 files changed

+750
-281
lines changed

9 files changed

+750
-281
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _artifacts
1111
Dockerfile.cross
1212
.release
1313

14+
infrastructure-metal-stack
1415
infrastructure-components.yaml
1516
.capms-cluster-kubeconfig.yaml
1617

DEVELOPMENT.md

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,8 @@ kubectl get secret metal-test-kubeconfig -o jsonpath='{.data.value}' | base64 -d
4444
clusterctl get kubeconfig metal-test > capi-lab/.capms-cluster-kubeconfig.yaml
4545
```
4646

47-
It is now expected to deploy a CNI to the cluster:
48-
49-
```bash
50-
kubectl --kubeconfig=capi-lab/.capms-cluster-kubeconfig.yaml create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.2/manifests/tigera-operator.yaml
51-
cat <<EOF | kubectl --kubeconfig=capi-lab/.capms-cluster-kubeconfig.yaml create -f -
52-
apiVersion: operator.tigera.io/v1
53-
kind: Installation
54-
metadata:
55-
name: default
56-
spec:
57-
# Configures Calico networking.
58-
calicoNetwork:
59-
bgp: Disabled
60-
ipPools:
61-
- name: default-ipv4-ippool
62-
blockSize: 26
63-
cidr: 10.240.0.0/12
64-
encapsulation: None
65-
mtu: 1440
66-
cni:
67-
ipam:
68-
type: HostLocal
69-
type: Calico
70-
EOF
71-
```
72-
73-
> [!note]
74-
> 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.
75-
7647
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:
7748

78-
```bash
79-
make -C capi-lab deploy-metal-ccm
80-
```
8149

8250
If you want to provide service's of type load balancer through MetalLB by the metal-ccm, you need to deploy MetalLB:
8351

@@ -244,7 +212,7 @@ export control_plane_machine_id=
244212
metalctl machine console --ipmi $control_plane_machine_id
245213
# ip r
246214
# sudo systemctl restart kubeadm
247-
# crictl ps
215+
# crictl ps
248216
# ~.
249217

250218
clusterctl get kubeconfig > capms-cluster.kubeconfig
@@ -279,12 +247,15 @@ watch kubectl -n $NAMESPACE --kubeconfig kind-bootstrap.kubeconfig get cluster,m
279247
# until everything is ready
280248
```
281249

250+
> [!note]
251+
> 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.
252+
282253
Now you are able to move the cluster resources as you wish:
283254

284255
```bash
285256
clusterctl init --infrastructure metal-stack --kubeconfig capms-cluster.kubeconfig
286257

287-
clusterctl move -n $NAMESPACE --kubeconfig kind-bootstrap.kubeconfig --to-kubeconfig capms-cluster.kubeconfig
258+
clusterctl move -n $NAMESPACE --kubeconfig kind-bootstrap.kubeconfig --to-kubeconfig capms-cluster.kubeconfig
288259
# everything as expected
289260
kubectl --kubeconfig -n $NAMESPACE kind-bootstrap.kubeconfig get cluster,metalstackcluster,machine,metalstackmachine,kubeadmcontrolplanes,kubeadmconfigs
290261
kubectl --kubeconfig -n $NAMESPACE capms-cluster.kubeconfig get cluster,metalstackcluster,machine,metalstackmachine,kubeadmcontrolplanes,kubeadmconfigs

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,29 @@ help: ## Display this help.
4646

4747
##@ Releases
4848

49+
LATEST_RELEASE_TAG := $(shell git describe --tags `git rev-list --tags --max-count=1`)
50+
4951
.PHONY: release-manifests
5052
release-manifests: $(KUSTOMIZE) build-installer ## Builds the manifests to publish with a release
5153
mkdir -p $(RELEASE_DIR)
5254
$(KUSTOMIZE) build config/default > $(RELEASE_DIR)/infrastructure-components.yaml
5355
sed -i 's!image: $(IMG_NAME):latest!image: $(IMG_NAME):$(IMG_TAG)!' $(RELEASE_DIR)/infrastructure-components.yaml
5456
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
55-
cp config/clusterctl-templates/cluster-template.yaml $(RELEASE_DIR)/cluster-template.yaml
57+
cp config/clusterctl-templates/cluster-template*.yaml $(RELEASE_DIR)/
5658
cp config/clusterctl-templates/example_variables.rc $(RELEASE_DIR)/example_variables.rc
5759

60+
ifneq ($(CI),true)
61+
# for devel purposes with local overwrite in clusterctl.yaml
62+
# $ cat ~/.config/cluster-api/clusterctl.yaml  1.25.3 13:33:07
63+
# providers:
64+
# - name: "metal-stack"
65+
# # url: "https://github.com/metal-stack/cluster-api-provider-metal-stack/releases/latest/download/infrastructure-components.yaml"
66+
# url: <your-repo-path>/infrastructure-metal-stack/$(LATEST_RELEASE_TAG)/infrastructure-components.yaml
67+
# type: InfrastructureProvider
68+
rm -rf infrastructure-metal-stack
69+
mkdir -p infrastructure-metal-stack && cd infrastructure-metal-stack && ln -s ../.release $(LATEST_RELEASE_TAG)
70+
endif
71+
5872
##@ Development
5973

6074
.PHONY: push-to-capi-lab
@@ -149,7 +163,7 @@ test-e2e: manifests generate fmt vet ginkgo
149163
FIREWALL_SIZE=$(E2E_FIREWALL_SIZE) \
150164
FIREWALL_NETWORKS=$(E2E_FIREWALL_NETWORKS) \
151165
ARTIFACTS=$(ARTIFACTS) \
152-
$(GINKGO) -vv -r --junit-report="junit.e2e_suite.xml" --output-dir="$(ARTIFACTS)" --label-filter="$(E2E_LABEL_FILTER)" -timeout 60m ./test/e2e/frmwrk
166+
$(GINKGO) -vv -r --junit-report="junit.e2e_suite.xml" --output-dir="$(ARTIFACTS)" --label-filter="$(E2E_LABEL_FILTER)" -timeout 60m ./test/e2e/frmwrk
153167

154168
.PHONY: lint
155169
lint: golangci-lint ## Run golangci-lint linter

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,13 @@ When generating your cluster, set `POD_CIDR` to your desired value.
170170
```bash
171171
export POD_CIDR=["10.240.0.0/12"]
172172
```
173+
174+
## Flavors
175+
176+
You might choose from different cluster template [flavors](https://cluster-api.sigs.k8s.io/clusterctl/commands/generate-cluster.html?highlight=flavor#flavors) to generate manifests with clusterctl. Here is a table describing the available flavors:
177+
178+
| Name | Description | K8s Compatibility |
179+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
180+
| | This is the default flavor without providing the `--flavor` flag. This expects the user to deploy a CNI and a CCM. | >= v1.33 |
181+
| calico | Installs [calico](https://docs.tigera.io/calico/latest/about/) CNI along with [metal-ccm](https://github.com/metal-stack/metal-ccm). Depends on `ClusterResourceSet` and the [Add-on Provider for Helm](https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm/tree/main). | >= v1.33 |
182+
| pre-v1.33 | The same as the default flavor but working for K8s versions < v1.33. | < v1.33 |

capi-lab/Makefile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ KUBECONFIG := $(shell pwd)/mini-lab/.kubeconfig
77
MINI_LAB_FLAVOR=capms
88

99
CLUSTER_NAME ?= metal-test
10-
KUBERNETES_VERSION ?= 1.32.9
10+
KUBERNETES_VERSION ?= 1.33.5
1111

1212
METAL_API_URL=http://metal.203.0.113.1.nip.io:8080
1313
METAL_API_HMAC=metal-edit
@@ -35,7 +35,7 @@ bake:
3535

3636
.PHONY: deploy-capi
3737
deploy-capi:
38-
docker compose run --rm clusterctl init
38+
docker compose run --rm clusterctl init --addon helm
3939

4040
.PHONY: cleanup
4141
cleanup:
@@ -78,7 +78,7 @@ apply-sample-cluster:
7878
--worker-machine-count 1 \
7979
--control-plane-machine-count 1 \
8080
--kubernetes-version $(KUBERNETES_VERSION) \
81-
--from ../config/clusterctl-templates/cluster-template.yaml \
81+
--from ../config/clusterctl-templates/cluster-template-calico.yaml \
8282
| kubectl --kubeconfig=$(KUBECONFIG) apply -f -
8383

8484
.PHONY: delete-sample-cluster
@@ -90,17 +90,10 @@ delete-sample-cluster:
9090
--worker-machine-count 1 \
9191
--control-plane-machine-count 1 \
9292
--kubernetes-version $(KUBERNETES_VERSION) \
93-
--from ../config/clusterctl-templates/cluster-template.yaml \
93+
--from ../config/clusterctl-templates/cluster-template-calico.yaml \
9494
| kubectl --kubeconfig=$(KUBECONFIG) delete -f -
9595

9696
.PHONY: mtu-fix
9797
mtu-fix:
9898
cd mini-lab && ssh -F files/ssh/config leaf01 'ip link set dev vtep-1001 mtu 9100 && echo done'
9999
cd mini-lab && ssh -F files/ssh/config leaf02 'ip link set dev vtep-1001 mtu 9100 && echo done'
100-
101-
.PHONY: deploy-metal-ccm
102-
deploy-metal-ccm:
103-
$(eval NAMESPACE = $(shell kubectl get metalstackclusters.infrastructure.cluster.x-k8s.io $(CLUSTER_NAME) -ojsonpath='{.metadata.namespace}'))
104-
$(eval METAL_NODE_NETWORK_ID = $(shell metalctl network list --name $(CLUSTER_NAME) -o template --template '{{ .id }}'))
105-
$(eval CONTROL_PLANE_IP = $(shell metalctl network ip list --name "$(CLUSTER_NAME)-vip" -o template --template '{{ .id }}'))
106-
cat metal-ccm.yaml | envsubst | kubectl --kubeconfig=.capms-cluster-kubeconfig.yaml apply -f -

0 commit comments

Comments
 (0)