Skip to content

Commit 42f1d5f

Browse files
authored
Allow metal-stack resources to be provided externally. (#10)
1 parent 42192e8 commit 42f1d5f

17 files changed

+679
-160
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.so
66
*.dylib
77
bin/*
8+
test/external-crds
89
Dockerfile.cross
910

1011
infrastructure-components.yaml

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ issues:
1717
- dupl
1818
- lll
1919
linters:
20-
disable-all: true
2120
enable:
2221
- dupl
2322
- errcheck
@@ -30,7 +29,6 @@ linters:
3029
- gosimple
3130
- govet
3231
- ineffassign
33-
- lll
3432
- misspell
3533
- nakedret
3634
- prealloc

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
6767
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
6868
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
6969

70+
.PHONY: update-test-crds
71+
update-test-crds:
72+
go mod tidy
73+
rm -rf test/external-crds
74+
mkdir -p test/external-crds/cluster-api
75+
mkdir -p test/external-crds/firewall-controller-manager
76+
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
77+
cp -f $(shell go list -mod=mod -m -f '{{.Dir}}' all | grep metal-stack/firewall-controller-manager)/config/crds/* test/external-crds/firewall-controller-manager
78+
7079
.PHONY: fmt
7180
fmt: ## Run go fmt against code.
7281
go fmt ./...
@@ -76,15 +85,15 @@ vet: ## Run go vet against code.
7685
go vet ./...
7786

7887
.PHONY: test
79-
test: manifests generate fmt vet envtest ## Run tests.
88+
test: manifests generate update-test-crds fmt vet envtest ## Run tests.
8089
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
8190

8291
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
8392
# Prometheus and CertManager are installed by default; skip with:
8493
# - PROMETHEUS_INSTALL_SKIP=true
8594
# - CERT_MANAGER_INSTALL_SKIP=true
8695
.PHONY: test-e2e
87-
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
96+
test-e2e: manifests generate update-test-crds fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
8897
@command -v kind >/dev/null 2>&1 || { \
8998
echo "Kind is not installed. Please install Kind manually."; \
9099
exit 1; \
@@ -106,7 +115,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
106115
##@ Build
107116

108117
.PHONY: build
109-
build: manifests generate fmt vet ## Build manager binary.
118+
build: manifests generate update-test-crds fmt vet ## Build manager binary.
110119
CGO_ENABLED=0 go build -o bin/manager cmd/main.go
111120

112121
.PHONY: run

api/v1alpha1/metalstackcluster_types.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,28 @@ type MetalStackClusterSpec struct {
5050
// +optional
5151
ControlPlaneEndpoint APIEndpoint `json:"controlPlaneEndpoint,omitempty"`
5252

53-
// ProjectID is the project id of the project in metal-stack in which the associated metal-stack resources are created
53+
// ProjectID is the project id of the project in metal-stack in which the associated metal-stack resources are created.
5454
ProjectID string `json:"projectID"`
5555

56-
// Partition is the data center partition in which the resources are created
56+
// NodeNetworkID is the network ID in metal-stack in which the worker nodes and the firewall of the cluster are placed.
57+
// If not provided this will automatically be acquired during reconcile. Note that this field is not patched after auto-acquisition.
58+
// The ID of the auto-acquired network can be looked up in the status resource instead.
59+
// +optional
60+
NodeNetworkID *string `json:"nodeNetworkID,omitempty"`
61+
62+
// ControlPlaneIP is the ip address in metal-stack on which the control plane will be exposed.
63+
// If this ip and the control plane endpoint are not provided this will automatically be acquired during reconcile. Note that this field is not patched after auto-acquisition.
64+
// The address of the auto-acquired ip can be looked up in the control plane endpoint.
65+
// +optional
66+
ControlPlaneIP *string `json:"controlPlaneIP,omitempty"`
67+
68+
// Partition is the data center partition in which the resources are created.
5769
Partition string `json:"partition"`
5870

59-
// Firewall describes the firewall for this cluster
60-
Firewall Firewall `json:"firewall"`
71+
// Firewall describes the firewall for this cluster.
72+
// If not provided this will automatically be created during reconcile.
73+
// +optional
74+
Firewall *Firewall `json:"firewall,omitempty"`
6175
}
6276

6377
// APIEndpoint represents a reachable Kubernetes API endpoint.
@@ -114,10 +128,10 @@ type MetalStackClusterStatus struct {
114128
// +optional
115129
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
116130

117-
// NodeCIDR is set as soon as the node network was created
131+
// NodeCIDR is set as soon as the node network was created.
118132
// +optional
119133
NodeCIDR *string `json:"nodeCIDR,omitempty"`
120-
// NodeNetworkID is set as soon as the node network was created
134+
// NodeNetworkID is set as soon as the node network was created.
121135
// +optional
122136
NodeNetworkID *string `json:"nodeNetworkID,omitempty"`
123137
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

capi-lab/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.extra_vars.yaml
2+
requirements.yaml

capi-lab/mini-lab

Submodule mini-lab updated 66 files

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,24 @@ metal_ingress_dns: metal.{{ metal_control_plane_ingress_dns }}
77

88
metal_partition_metal_api_addr: metal.172.17.0.1.nip.io
99
metal_partition_metal_api_basepath: "/"
10+
11+
metal_api_images:
12+
- id: firewall-ubuntu-3.0
13+
name: Firewall 3 Ubuntu
14+
description: Firewall 3 Ubuntu Latest Release
15+
url: https://images.metal-stack.io/metal-os/{{ metal_api_latest_os_image_release_name }}/firewall/3.0-ubuntu/img.tar.lz4
16+
features:
17+
- firewall
18+
- id: ubuntu-24.04
19+
name: Ubuntu 24.04
20+
description: Ubuntu 24.04 Latest Release
21+
url: https://images.metal-stack.io/metal-os/{{ metal_api_latest_os_image_release_name }}/ubuntu/24.04/img.tar.lz4
22+
features:
23+
- machine
24+
- id: firewall-ubuntu-3.0.20241106
25+
name: Firewall 3 Ubuntu 20241106
26+
description: Firewall 3 Ubuntu 20241106
27+
url: http://images.metal-stack.io/metal-os/20241106/firewall/3.0-ubuntu/img.tar.lz4
28+
classification: supported
29+
features:
30+
- firewall

capi-lab/requirements.yaml

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

cmd/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,13 @@ func main() {
161161
if err = (&controller.MetalStackClusterReconciler{
162162
MetalClient: metalClient,
163163
Client: mgr.GetClient(),
164-
Scheme: mgr.GetScheme(),
165164
}).SetupWithManager(mgr); err != nil {
166165
setupLog.Error(err, "unable to create controller", "controller", "MetalStackCluster")
167166
os.Exit(1)
168167
}
169168
if err = (&controller.MetalStackMachineReconciler{
170169
MetalClient: metalClient,
171170
Client: mgr.GetClient(),
172-
Scheme: mgr.GetScheme(),
173171
}).SetupWithManager(mgr); err != nil {
174172
setupLog.Error(err, "unable to create controller", "controller", "MetalStackMachine")
175173
os.Exit(1)

0 commit comments

Comments
 (0)