Skip to content

Commit 40bfd1b

Browse files
committed
Merge remote-tracking branch 'origin/main' into test-k8s-upgrade
# Conflicts: # test/e2e/frmwrk/shared_cases.go
2 parents 314e8df + 698b9ef commit 40bfd1b

23 files changed

+1341
-618
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: 21 additions & 6 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
@@ -111,6 +125,7 @@ E2E_METAL_API_URL ?= "$(METALCTL_API_URL)"
111125
E2E_METAL_API_HMAC ?= "$(METALCTL_HMAC)"
112126
E2E_METAL_API_HMAC_AUTH_TYPE ?= "$(or $(METALCTL_HMAC_AUTH_TYPE),Metal-Admin)"
113127
E2E_METAL_PROJECT_ID ?= "00000000-0000-0000-0000-000000000001"
128+
E2E_METAL_PROJECT_NAME ?= "test"
114129
E2E_METAL_PARTITION ?= "mini-lab"
115130
E2E_METAL_PUBLIC_NETWORK ?= "internet-mini-lab"
116131
E2E_KUBERNETES_VERSIONS ?= "v1.32.9"
@@ -122,20 +137,19 @@ E2E_FIREWALL_IMAGE ?= "firewall-ubuntu-3.0"
122137
E2E_FIREWALL_SIZE ?= "v1-small-x86"
123138
E2E_FIREWALL_NETWORKS ?= "internet-mini-lab"
124139
ARTIFACTS ?= "$(PWD)/_artifacts"
140+
E2E_DEFAULT_FLAVOR ?= "calico"
125141
# Can be something like: basic && !move
126142
E2E_LABEL_FILTER ?= ""
127143

128144
.PHONY: test-e2e
129145
test-e2e: manifests generate fmt vet ginkgo
130-
rm -rf $(ARTIFACTS)/config/target
131-
132-
mkdir -p $(ARTIFACTS)/config/target
133-
kubectl kustomize test/e2e/frmwrk/config/target/base -o $(ARTIFACTS)/config/target/base.yaml
146+
rm -rf $(ARTIFACTS)
134147

135148
@METAL_API_URL=$(E2E_METAL_API_URL) \
136149
METAL_API_HMAC=$(E2E_METAL_API_HMAC) \
137150
METAL_API_HMAC_AUTH_TYPE=$(E2E_METAL_API_HMAC_AUTH_TYPE) \
138151
METAL_PROJECT_ID=$(E2E_METAL_PROJECT_ID) \
152+
E2E_METAL_PROJECT_NAME=$(E2E_METAL_PROJECT_NAME) \
139153
METAL_PARTITION=$(E2E_METAL_PARTITION) \
140154
METAL_PUBLIC_NETWORK=$(E2E_METAL_PUBLIC_NETWORK) \
141155
E2E_KUBERNETES_VERSIONS=$(E2E_KUBERNETES_VERSIONS) \
@@ -147,7 +161,8 @@ test-e2e: manifests generate fmt vet ginkgo
147161
FIREWALL_SIZE=$(E2E_FIREWALL_SIZE) \
148162
FIREWALL_NETWORKS=$(E2E_FIREWALL_NETWORKS) \
149163
ARTIFACTS=$(ARTIFACTS) \
150-
$(GINKGO) -vv -r --junit-report="junit.e2e_suite.xml" --output-dir="$(ARTIFACTS)" --label-filter="$(E2E_LABEL_FILTER)" -timeout 60m ./test/e2e/frmwrk
164+
E2E_DEFAULT_FLAVOR=$(E2E_DEFAULT_FLAVOR) \
165+
$(GINKGO) -vv -r --junit-report="junit.e2e_suite.xml" --output-dir="$(ARTIFACTS)" --label-filter="$(E2E_LABEL_FILTER)" -timeout 60m ./test/e2e/frmwrk
151166

152167
.PHONY: lint
153168
lint: golangci-lint ## Run golangci-lint linter

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
# cluster-api-provider-metal-stack
22

3-
The Cluster API provider for metal-stack (CAPMS) implements the declarative management of Kubernetes cluster infrastructure.
3+
The Cluster API provider for metal-stack (CAPMS) implements the declarative management of Kubernetes cluster infrastructure on top of [metal-stack](https://metal-stack.io/) using [Cluster API (CAPI)](https://cluster-api.sigs.k8s.io/).
44

5-
> [!CAUTION]
6-
> This project is currently under heavy development and is not advised to be used in production any time soon.
7-
> Please use our stack on top of [Gardener](https://docs.metal-stack.io/stable/installation/deployment/#Gardener-with-metal-stack) instead.
5+
> [!WARNING]
6+
> As of now the CAPMS is not yet feature complete and there might be breaking changes in future releases.
7+
> In case you search for a feature stable alternative consider [Gardener on metal-stack](https://docs.metal-stack.io/stable/installation/deployment/#Gardener-with-metal-stack) instead.
88
> For developing this project head to our [DEVELOPMENT.md](/DEVELOPMENT.md).
99
1010
Currently, we provide the following custom resources:
1111

1212
- [`MetalStackCluster`](./api/v1alpha1/metalstackcluster_types.go) can be used as [infrastructure cluster](https://cluster-api.sigs.k8s.io/developer/providers/contracts/infra-cluster) and ensures that there is a control plane IP for the cluster.
1313
- [`MetalStackMachine`](./api/v1alpha1/metalstackmachine_types.go) bridges between [infrastructure machines](https://cluster-api.sigs.k8s.io/developer/providers/contracts/infra-machine) and metal-stack machines.
1414

15+
We plan to cover more resources in the future:
16+
17+
- Node Networks
18+
- Firewall Deployments
19+
- Improved configuration suggestion of CNIs
20+
1521
> [!note]
1622
> Currently our infrastructure provider is only tested against the [Cluster API bootstrap provider Kubeadm (CABPK)](https://cluster-api.sigs.k8s.io/tasks/bootstrap/kubeadm-bootstrap/index.html?highlight=kubeadm#cluster-api-bootstrap-provider-kubeadm).
1723
> While other providers might work, there is no guarantee nor the goal to reach compatibility.
@@ -21,6 +27,7 @@ Currently, we provide the following custom resources:
2127
**Prerequisites:**
2228

2329
- Running metal-stack installation. See our [installation](https://docs.metal-stack.io/stable/installation/deployment/) section on how to get started with metal-stack.
30+
- Operating system images available to metal-stack. See [metal-stack/metal-images](https://github.com/metal-stack/metal-images) for pre-built ones.
2431
- Management cluster (with network access to the metal-stack infrastructure).
2532
- CLI metalctl installed for communicating with the metal-api. Installation instructions can be found in the corresponding [repository](https://github.com/metal-stack/metalctl).
2633
- CLI clusterctl
@@ -91,7 +98,7 @@ export WORKER_MACHINE_IMAGE=<machine-image>
9198
export WORKER_MACHINE_SIZE=<machine-size>
9299

93100
# generate manifest
94-
clusterctl generate cluster $CLUSTER_NAME --kubernetes-version v1.30.6 --infrastructure metal-stack
101+
clusterctl generate cluster $CLUSTER_NAME --kubernetes-version v1.32.9 --infrastructure metal-stack
95102
```
96103

97104
Apply the generated manifest from the `clusterctl` output.
@@ -163,3 +170,13 @@ When generating your cluster, set `POD_CIDR` to your desired value.
163170
```bash
164171
export POD_CIDR=["10.240.0.0/12"]
165172
```
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)