Skip to content

Commit b5aeddc

Browse files
committed
Merge remote-tracking branch 'origin/main' into capi-v1.11.2
# Conflicts: # go.mod # go.sum
2 parents 4adf0b3 + ade7c75 commit b5aeddc

File tree

18 files changed

+1283
-18
lines changed

18 files changed

+1283
-18
lines changed

.github/workflows/test-e2e.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- main
1111

1212
jobs:
13-
test-e2e:
13+
test-e2e-controller:
1414
name: E2E Tests
1515
runs-on: ubuntu-latest
1616
steps:
@@ -34,7 +34,7 @@ jobs:
3434
- name: Create kind cluster
3535
run: kind create cluster
3636

37-
- name: Running Test e2e
37+
- name: Running Test e2e-controller
3838
run: |
3939
go mod tidy
40-
make test-e2e
40+
make test-e2e-controller

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*.dylib
77
bin/*
88
test/external-crds
9+
test/e2e/frmwrk/artifacts
10+
_artifacts
911
Dockerfile.cross
1012
.release
1113

@@ -17,6 +19,7 @@ infrastructure-components.yaml
1719

1820
# Output of the go coverage tool, specifically when used with LiteIDE
1921
*.out
22+
junit.e2e_suite.xml
2023

2124
# Go workspace file
2225
go.work

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export WORKER_MACHINE_SIZE=
204204

205205
export CLUSTER_NAME=
206206
export NAMESPACE=default
207-
export KUBERNETES_VERSION=v1.31.6
207+
export KUBERNETES_VERSION=v1.32.9
208208

209209
export CONTROL_PLANE_MACHINE_COUNT=1
210210
export WORKER_MACHINE_COUNT=1

Makefile

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ update-test-crds:
7777
go mod tidy
7878
rm -rf test/external-crds
7979
mkdir -p test/external-crds/cluster-api
80-
cp -f $(shell go list -mod=mod -m -f '{{.Dir}}' all | grep sigs.k8s.io/cluster-api)/config/crd/bases/* test/external-crds/cluster-api
80+
cp -f $(shell go list -mod=mod -m -f '{{.Dir}}' all | grep sigs.k8s.io/cluster-api@)/config/crd/bases/* test/external-crds/cluster-api
8181

8282
.PHONY: fmt
8383
fmt: ## Run go fmt against code.
@@ -88,15 +88,15 @@ vet: ## Run go vet against code.
8888
go vet ./...
8989

9090
.PHONY: test
91-
test: manifests generate update-test-crds fmt vet envtest ## Run tests.
92-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
91+
test: manifests generate update-test-crds fmt vet envtest ginkgo ## Run tests.
92+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) -r --junit-report="junit.e2e_suite.xml" --cover -coverprofile cover.out $$(go list ./... | grep -v /e2e | sed "s|github.com/metal-stack/cluster-api-provider-metal-stack|.|")
9393

9494
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
9595
# Prometheus and CertManager are installed by default; skip with:
9696
# - PROMETHEUS_INSTALL_SKIP=true
9797
# - CERT_MANAGER_INSTALL_SKIP=true
98-
.PHONY: test-e2e
99-
test-e2e: manifests generate update-test-crds fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
98+
.PHONY: test-e2e-controller
99+
test-e2e-controller: manifests generate update-test-crds fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
100100
@command -v kind >/dev/null 2>&1 || { \
101101
echo "Kind is not installed. Please install Kind manually."; \
102102
exit 1; \
@@ -107,6 +107,46 @@ test-e2e: manifests generate update-test-crds fmt vet ## Run the e2e tests. Expe
107107
}
108108
go test ./test/e2e/ -v -ginkgo.v
109109

110+
E2E_METAL_API_URL ?= "$(METALCTL_API_URL)"
111+
E2E_METAL_API_HMAC ?= "$(METALCTL_HMAC)"
112+
E2E_METAL_API_HMAC_AUTH_TYPE ?= "$(or $(METALCTL_HMAC_AUTH_TYPE),Metal-Admin)"
113+
E2E_METAL_PROJECT_ID ?= "00000000-0000-0000-0000-000000000001"
114+
E2E_METAL_PARTITION ?= "mini-lab"
115+
E2E_METAL_PUBLIC_NETWORK ?= "internet-mini-lab"
116+
E2E_KUBERNETES_VERSIONS ?= "v1.32.9"
117+
E2E_CONTROL_PLANE_MACHINE_IMAGE_PREFIX ?= "capms-ubuntu-"
118+
E2E_CONTROL_PLANE_MACHINE_SIZE ?= "v1-small-x86"
119+
E2E_WORKER_MACHINE_IMAGE_PREFIX ?= "capms-ubuntu-"
120+
E2E_WORKER_MACHINE_SIZE ?= "v1-small-x86"
121+
E2E_FIREWALL_IMAGE ?= "firewall-ubuntu-3.0"
122+
E2E_FIREWALL_SIZE ?= "v1-small-x86"
123+
E2E_FIREWALL_NETWORKS ?= "internet-mini-lab"
124+
ARTIFACTS ?= "$(PWD)/_artifacts"
125+
126+
.PHONY: test-e2e
127+
test-e2e: manifests generate fmt vet ginkgo
128+
rm -rf test/e2e/frmwrk/artifacts
129+
130+
mkdir -p $(ARTIFACTS)/config/target
131+
kubectl kustomize test/e2e/frmwrk/config/target/base -o $(ARTIFACTS)/config/target/base.yaml
132+
133+
@METAL_API_URL=$(E2E_METAL_API_URL) \
134+
METAL_API_HMAC=$(E2E_METAL_API_HMAC) \
135+
METAL_API_HMAC_AUTH_TYPE=$(E2E_METAL_API_HMAC_AUTH_TYPE) \
136+
METAL_PROJECT_ID=$(E2E_METAL_PROJECT_ID) \
137+
METAL_PARTITION=$(E2E_METAL_PARTITION) \
138+
METAL_PUBLIC_NETWORK=$(E2E_METAL_PUBLIC_NETWORK) \
139+
E2E_KUBERNETES_VERSIONS=$(E2E_KUBERNETES_VERSIONS) \
140+
E2E_CONTROL_PLANE_MACHINE_IMAGE_PREFIX=$(E2E_CONTROL_PLANE_MACHINE_IMAGE_PREFIX) \
141+
CONTROL_PLANE_MACHINE_SIZE=$(E2E_CONTROL_PLANE_MACHINE_SIZE) \
142+
E2E_WORKER_MACHINE_IMAGE_PREFIX=$(E2E_WORKER_MACHINE_IMAGE_PREFIX) \
143+
WORKER_MACHINE_SIZE=$(E2E_WORKER_MACHINE_SIZE) \
144+
FIREWALL_IMAGE=$(E2E_FIREWALL_IMAGE) \
145+
FIREWALL_SIZE=$(E2E_FIREWALL_SIZE) \
146+
FIREWALL_NETWORKS=$(E2E_FIREWALL_NETWORKS) \
147+
ARTIFACTS=$(ARTIFACTS) \
148+
$(GINKGO) -vv -r --junit-report="junit.e2e_suite.xml" --output-dir="$(ARTIFACTS)" -timeout 60m ./test/e2e/frmwrk
149+
110150
.PHONY: lint
111151
lint: golangci-lint ## Run golangci-lint linter
112152
$(GOLANGCI_LINT) run
@@ -199,13 +239,15 @@ KUBECTL ?= kubectl
199239
KUSTOMIZE ?= $(LOCALBIN)/kustomize
200240
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
201241
ENVTEST ?= $(LOCALBIN)/setup-envtest
242+
GINKGO ?= $(LOCALBIN)/ginkgo
202243
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
203244

204245
## Tool Versions
205246
KUSTOMIZE_VERSION ?= v5.4.3
206247
CONTROLLER_TOOLS_VERSION ?= v0.16.4
207248
ENVTEST_VERSION ?= release-0.19
208249
GOLANGCI_LINT_VERSION ?= v1.61.0
250+
GINKGO_VERSION ?= v2.23.3
209251

210252
.PHONY: kustomize
211253
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -227,6 +269,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
227269
$(GOLANGCI_LINT): $(LOCALBIN)
228270
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
229271

272+
.PHONY: ginkgo
273+
ginkgo: $(GINKGO) ## Download setup-envtest locally if necessary.
274+
$(GINKGO): $(LOCALBIN)
275+
$(call go-install-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo,$(GINKGO_VERSION))
276+
230277
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
231278
# $1 - target path with name of binary
232279
# $2 - package url which can be installed

capi-lab/Makefile

Lines changed: 4 additions & 3 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.31.6
10+
KUBERNETES_VERSION ?= 1.32.9
1111

1212
METAL_API_URL=http://metal.203.0.113.1.nip.io:8080
1313
METAL_API_HMAC=metal-edit
@@ -19,9 +19,9 @@ METALCTL_HMAC_AUTH_TYPE=Metal-Edit
1919
METAL_PARTITION ?= mini-lab
2020
METAL_PROJECT_ID ?= 00000000-0000-0000-0000-000000000001
2121

22-
CONTROL_PLANE_MACHINE_IMAGE ?= ubuntu-24.0-k8s-$(KUBERNETES_VERSION)
22+
CONTROL_PLANE_MACHINE_IMAGE ?= capms-ubuntu-$(KUBERNETES_VERSION)
2323
CONTROL_PLANE_MACHINE_SIZE ?= v1-small-x86
24-
WORKER_MACHINE_IMAGE ?= ubuntu-24.0-k8s-$(KUBERNETES_VERSION)
24+
WORKER_MACHINE_IMAGE ?= capms-ubuntu-$(KUBERNETES_VERSION)
2525
WORKER_MACHINE_SIZE ?= v1-small-x86
2626

2727
IMG ?= ghcr.io/metal-stack/cluster-api-metal-stack-controller:latest
@@ -46,6 +46,7 @@ cleanup:
4646
dev-env:
4747
@echo "export METALCTL_API_URL=${METALCTL_API_URL}"
4848
@echo "export METALCTL_HMAC=${METALCTL_HMAC}"
49+
@echo "export METALCTL_HMAC_AUTH_TYPE=${METALCTL_HMAC_AUTH_TYPE}"
4950
@echo "export KUBECONFIG=${KUBECONFIG}"
5051

5152
.PHONY: controller

capi-lab/mini-lab-overrides/extra-vars.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ metal_api_images:
1717
url: https://images.metal-stack.io/metal-os/stable/firewall/3.0-ubuntu/img.tar.lz4
1818
features:
1919
- firewall
20-
- id: ubuntu-24.4
21-
name: Ubuntu 24.04 with Kubernetes 1.30.6
22-
description: Ubuntu 24.04 with Kubernetes 1.30.6
23-
url: https://images.metal-stack.io/metal-os/pull_requests/273-cluster-api-k8s-v1.30.6/cluster-api/cluster-api-k8s-1.30.6/img.tar.lz4
20+
- id: capms-ubuntu-1.34.1
21+
name: Ubuntu 24.04 with Kubernetes 1.34.1
22+
description: Ubuntu 24.04 with Kubernetes 1.34.1
23+
url: https://images.metal-stack.io/metal-os/pull_requests/352-capi-images/capms-ubuntu/1.34.1/img.tar.lz4
24+
features:
25+
- machine
26+
- id: capms-ubuntu-1.33.5
27+
name: Ubuntu 24.04 with Kubernetes 1.33.5
28+
description: Ubuntu 24.04 with Kubernetes 1.33.5
29+
url: https://images.metal-stack.io/metal-os/pull_requests/352-capi-images/capms-ubuntu/1.33.5/img.tar.lz4
30+
features:
31+
- machine
32+
- id: capms-ubuntu-1.32.9
33+
name: Ubuntu 24.04 with Kubernetes 1.32.9
34+
description: Ubuntu 24.04 with Kubernetes 1.32.9
35+
url: https://images.metal-stack.io/metal-os/pull_requests/352-capi-images/capms-ubuntu/1.32.9/img.tar.lz4
2436
features:
2537
- machine
2638

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resources:
2+
- ./metal-ccm.yaml

test/e2e/frmwrk/bootstrap_test.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package frmwrk
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
"path"
8+
"strings"
9+
10+
"github.com/drone/envsubst/v2"
11+
. "github.com/onsi/ginkgo/v2"
12+
. "github.com/onsi/gomega"
13+
14+
"sigs.k8s.io/cluster-api/test/framework"
15+
)
16+
17+
var _ = Describe("Basic Cluster Creation", Ordered, func() {
18+
var (
19+
ec *E2ECluster
20+
)
21+
22+
BeforeAll(func() {
23+
e2eCtx = NewE2EContext()
24+
e2eCtx.ProvideBootstrapCluster()
25+
e2eCtx.CreateClusterctlConfig(context.TODO())
26+
e2eCtx.InitManagementCluster(context.TODO())
27+
28+
DeferCleanup(e2eCtx.Teardown, context.TODO())
29+
})
30+
31+
BeforeEach(func() {
32+
ec = nil
33+
})
34+
35+
kubernetesVersions := strings.Split(os.Getenv("E2E_KUBERNETES_VERSIONS"), ",")
36+
Expect(kubernetesVersions).ToNot(BeEmpty(), "E2E_KUBERNETES_VERSIONS must be set")
37+
38+
for i, v := range kubernetesVersions {
39+
It(fmt.Sprintf("create new cluster with kubernetes %s", v), func() {
40+
ctx := context.Background()
41+
42+
ec = createE2ECluster(ctx, e2eCtx, ClusterConfig{
43+
SpecName: "basic-cluster-creation-" + v,
44+
NamespaceName: fmt.Sprintf("e2e-basic-cluster-creation-%d", i),
45+
ClusterName: fmt.Sprintf("simple-%d", i),
46+
KubernetesVersion: v,
47+
ControlPlaneMachineImage: os.Getenv("E2E_CONTROL_PLANE_MACHINE_IMAGE_PREFIX") + strings.TrimPrefix(v, "v"),
48+
ControlPlaneMachineCount: 1,
49+
WorkerMachineImage: os.Getenv("E2E_WORKER_MACHINE_IMAGE_PREFIX") + strings.TrimPrefix(v, "v"),
50+
WorkerMachineCount: 1,
51+
})
52+
Expect(ec).ToNot(BeNil())
53+
})
54+
}
55+
})
56+
57+
func createE2ECluster(ctx context.Context, e2eCtx *E2EContext, cfg ClusterConfig) *E2ECluster {
58+
ec := e2eCtx.NewE2ECluster(cfg)
59+
DeferCleanup(ec.Teardown, ctx)
60+
61+
ec.SetupMetalStackPreconditions(ctx)
62+
ec.SetupNamespace(ctx)
63+
ec.GenerateAndApplyClusterTemplate(ctx)
64+
65+
By("Wait for cluster")
66+
controlPlane := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{
67+
Lister: e2eCtx.Environment.Bootstrap.GetClient(),
68+
ClusterName: ec.Refs.Cluster.Name,
69+
Namespace: ec.Refs.Cluster.Namespace,
70+
})
71+
72+
framework.DiscoveryAndWaitForCluster(ctx, framework.DiscoveryAndWaitForClusterInput{
73+
Getter: e2eCtx.Environment.Bootstrap.GetClient(),
74+
Namespace: ec.Refs.Cluster.Namespace,
75+
Name: ec.Refs.Cluster.Name,
76+
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-cluster")...)
77+
78+
Expect(controlPlane).To(Not(BeNil()))
79+
80+
By("Wait for CNI and CCM")
81+
targetTemplate, err := os.ReadFile(path.Join(e2eCtx.Environment.artifactsPath, "config", "target", "base.yaml"))
82+
Expect(err).ToNot(HaveOccurred())
83+
84+
vars := ec.Variables()
85+
targetResources, err := envsubst.Eval(string(targetTemplate), func(varName string) string {
86+
return vars[varName]
87+
})
88+
Expect(err).ToNot(HaveOccurred())
89+
90+
Eventually(func() error {
91+
return ec.Refs.Workload.CreateOrUpdate(ctx, []byte(targetResources))
92+
}, "5m", "15s").Should(Succeed())
93+
94+
By("Wait for kubeadm control plane")
95+
framework.DiscoveryAndWaitForControlPlaneInitialized(ctx, framework.DiscoveryAndWaitForControlPlaneInitializedInput{
96+
Lister: e2eCtx.Environment.Bootstrap.GetClient(),
97+
Cluster: ec.Refs.Cluster,
98+
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-control-plane")...)
99+
100+
framework.WaitForClusterToProvision(ctx, framework.WaitForClusterToProvisionInput{
101+
Cluster: ec.Refs.Cluster,
102+
Getter: e2eCtx.Environment.Bootstrap.GetClient(),
103+
}, e2eCtx.E2EConfig.GetIntervals("default", "wait-cluster-provisioned")...)
104+
return ec
105+
}

0 commit comments

Comments
 (0)