Skip to content

Commit 053ed25

Browse files
committed
refactor config structure for split k0smotron installations
Signed-off-by: apedriza <[email protected]>
1 parent 9b0502c commit 053ed25

File tree

133 files changed

+2014
-19711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+2014
-19711
lines changed

.github/workflows/capi-smoke-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ jobs:
7979
run: |
8080
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.24/deploy/local-path-storage.yaml
8181
82-
- name: Download install manifest for k0smotron
82+
- name: Download install manifest for k0smotron standalone
8383
uses: actions/download-artifact@v5
8484
with:
85-
name: install-yaml
85+
name: install-standalone-yaml
8686

8787
- name: Run inttest for CAPI with docker provider
8888
run: |

.github/workflows/go.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ jobs:
8080
config.yaml
8181
k0sproject-k0smotron/
8282
83-
- name: Generate install yaml
83+
- name: Generate install yaml for standalone mode
8484
run: |
85-
make release
85+
make release-standalone
8686
87-
- name: Upload install yaml
87+
- name: Upload install-standalone yaml
8888
uses: actions/upload-artifact@v4
8989
with:
90-
name: install-yaml
91-
path: install.yaml
90+
name: install-standalone-yaml
91+
path: install-standalone.yaml
9292

9393
unittest:
9494
name: Unit & Integration tests
@@ -176,7 +176,7 @@ jobs:
176176
- name: Download install manifest for k0smotron
177177
uses: actions/download-artifact@v5
178178
with:
179-
name: install-yaml
179+
name: install-standalone-yaml
180180

181181
- name: Load k0smotron image bundle
182182
run: |
@@ -270,11 +270,6 @@ jobs:
270270
run: |
271271
docker load -i k0smotron-image-bundle.tar
272272
273-
- name: Download install manifest
274-
uses: actions/download-artifact@v5
275-
with:
276-
name: install-yaml
277-
278273
- name: Run e2e test
279274
run: |
280275
export TEST_NAME=Test$(echo "${{ matrix.e2e-suite }}" | awk -F'-' '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1' OFS='')

.github/workflows/publish-docs.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
echo STABLE="$STABLE" >> $GITHUB_OUTPUT
8282
8383
# Ensures the current branch is gh-pages,
84-
# Creates / updates the "install.yaml" file with the corresponding versions
84+
# Creates / updates the "install.yaml" and "install-standalone.yaml" files with the corresponding versions
8585
# Commits if the files were changed
8686
# Finally pushes if there are unpushed commits
8787
- name: Create install files
@@ -94,9 +94,12 @@ jobs:
9494
run: |
9595
STABLE=${{ steps.set_versions.outputs.STABLE }}
9696
make release IMG=quay.io/k0sproject/k0smotron:${STABLE}
97+
make release-standalone IMG=quay.io/k0sproject/k0smotron:${STABLE}
9798
cp install.yaml /tmp/install.yaml
99+
cp install-standalone.yaml /tmp/install-standalone.yaml
98100
git checkout gh-pages
99101
cp /tmp/install.yaml ${STABLE}/install.yaml
100-
git add ${STABLE}/install.yaml && git update-index --refresh
101-
git diff-index --quiet HEAD -- || git commit -m "Update install.yaml to ${STABLE}"
102+
cp /tmp/install-standalone.yaml ${STABLE}/install-standalone.yaml
103+
git add ${STABLE}/install.yaml ${STABLE}/install-standalone.yaml && git update-index --refresh
104+
git diff-index --quiet HEAD -- || git commit -m "Update install.yaml and install-standalone.yaml to ${STABLE}"
102105
git push origin gh-pages

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Generated files
22
install.yaml
3+
install-standalone.yaml
34
bootstrap-components.yaml
45
control-plane-components.yaml
56
infrastructure-components.yaml
@@ -25,6 +26,9 @@ __debug_bin*
2526
# Output of the go coverage tool, specifically when used with LiteIDE
2627
*.out
2728

29+
# VSCode
30+
.vscode/
31+
2832
# Kubernetes Generated files - skip generated files, except for vendored files
2933

3034
!vendor/**/zz_generated.*

Makefile

Lines changed: 78 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,61 @@ help: ## Display this help.
6363
##@ Development
6464

6565
### CRD manifests (one per API group)
66-
.PHONY: manifests-bootstrap manifests-controlplane manifests-infrastructure manifests-k0smotron
66+
.PHONY: manifests-bootstrap manifests-controlplane manifests-infrastructure manifests-standalone
6767
manifests-bootstrap: $(CONTROLLER_GEN) ## Generate CRDs for bootstrap.cluster.x-k8s.io
68-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook \
69-
paths="./..." \
70-
output:crd:artifacts:config=config/crd/bases/bootstrap
71-
find ./config/crd/bases/bootstrap -type f ! -name "bootstrap*" ! -name "kustomization.yaml" -print0 | xargs -0 rm
68+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true \
69+
paths="./api/bootstrap/v1beta1/..." \
70+
paths=./internal/controller/bootstrap/... \
71+
output:crd:artifacts:config=config/clusterapi/bootstrap/crd/bases \
72+
output:rbac:dir=config/clusterapi/bootstrap/rbac
7273

73-
manifests-controlplane: $(CONTROLLER_GEN) ## Generate CRDs for controlplane.cluster.x-k8s.io
74+
manifests-controlplane: $(CONTROLLER_GEN) ## Generate CRDs for controlplane.cluster.x-k8s.io.
75+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook \
76+
paths="./api/controlplane/v1beta1/..." \
77+
paths=./internal/controller/controlplane/... \
78+
output:crd:artifacts:config=config/clusterapi/controlplane/crd/bases
7479
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook \
75-
paths="./..." \
76-
output:crd:artifacts:config=config/crd/bases/controlplane
77-
find ./config/crd/bases/controlplane -type f ! -name "controlplane*" ! -name "kustomization.yaml" -print0 | xargs -0 rm
80+
paths="./api/controlplane/v1beta1/..." \
81+
paths="./api/k0smotron.io/v1beta1/..." \
82+
paths=./internal/controller/controlplane/... \
83+
paths=./internal/controller/k0smotron.io/... \
84+
output:rbac:dir=config/clusterapi/controlplane/rbac \
85+
output:webhook:dir=config/clusterapi/controlplane/webhook
7886

7987
manifests-infrastructure: $(CONTROLLER_GEN) ## Generate CRDs for infrastructure.cluster.x-k8s.io
80-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook \
81-
paths="./..." \
82-
output:crd:artifacts:config=config/crd/bases/infrastructure
83-
find ./config/crd/bases/infrastructure -type f ! -name "infrastructure*" ! -name "kustomization.yaml" -print0 | xargs -0 rm
88+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true \
89+
paths="./api/infrastructure/v1beta1/..." \
90+
paths=./internal/controller/infrastructure/... \
91+
output:crd:artifacts:config=config/clusterapi/infrastructure/crd/bases \
92+
output:rbac:dir=config/clusterapi/infrastructure/rbac
8493

85-
manifests-k0smotron: $(CONTROLLER_GEN) ## Generate CRDs for k0smotron.io
94+
manifests-standalone: $(CONTROLLER_GEN) ## Generate CRDs for k0smotron.io standalone
8695
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook \
87-
paths="./..." \
88-
output:crd:artifacts:config=config/crd/bases/k0smotron.io
89-
find ./config/crd/bases/k0smotron.io -type f ! -name "k0smotron.io*" ! -name "kustomization.yaml" -print0 | xargs -0 rm
96+
paths="./api/k0smotron.io/v1beta1/..." \
97+
paths=./internal/controller/k0smotron.io/... \
98+
output:crd:artifacts:config=config/standalone/crd/bases \
99+
output:rbac:dir=config/standalone/rbac \
100+
output:webhook:dir=config/standalone/webhook
101+
102+
.PHONY: manifests-capi-integration
103+
manifests-capi-integration: manifests manifests-capi-integration-without-crd
104+
105+
.PHONY: manifests-capi-integration-without-crd
106+
manifests-capi-integration-without-crd: $(CONTROLLER_GEN) # Generate RBAC and webhook manifests for all controllers except CRDs in order to reuse them from each config/clusterapi/{provider}
107+
$(CONTROLLER_GEN) rbac:roleName=manager-role webhook \
108+
paths="./api/bootstrap/v1beta1/..." \
109+
paths=./internal/controller/bootstrap/... \
110+
paths="./api/controlplane/v1beta1/..." \
111+
paths="./api/k0smotron.io/v1beta1/..." \
112+
paths=./internal/controller/controlplane/... \
113+
paths=./internal/controller/k0smotron.io/... \
114+
paths="./api/infrastructure/v1beta1/..." \
115+
paths=./internal/controller/infrastructure/... \
116+
output:rbac:dir=config/clusterapi/all/rbac \
117+
output:webhook:dir=config/clusterapi/all/webhook
90118

91119
.PHONY: manifests
92-
manifests: manifests-bootstrap manifests-controlplane manifests-infrastructure manifests-k0smotron ## Generate all CRD YAMLs per group
120+
manifests: manifests-bootstrap manifests-controlplane manifests-infrastructure manifests-standalone ## Generate all CRD YAMLs per group
93121

94122
### generate
95123
generate_targets += api/k0smotron.io/v1beta1/zz_generated.deepcopy.go
@@ -99,7 +127,7 @@ generate_targets += api/infrastructure/v1beta1/zz_generated.deepcopy.go
99127
$(generate_targets): $(CONTROLLER_GEN)
100128
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
101129

102-
generate: $(generate_targets) clusterapi-manifests ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
130+
generate: $(generate_targets) manifests ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
103131

104132

105133
GO_PKGS=$(shell go list ./...)
@@ -149,10 +177,6 @@ e2e-aws:
149177
build:
150178
go build -o bin/manager cmd/main.go
151179

152-
.PHONY: run
153-
run: manifests generate fmt vet ## Run a controller from your host.
154-
go run ./cmd/main.go
155-
156180
# If you wish built the manager image targeting other platforms you can use the --platform flag.
157181
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
158182
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
@@ -193,49 +217,43 @@ ifndef ignore-not-found
193217
ignore-not-found = false
194218
endif
195219

196-
.PHONY: install
197-
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
198-
$(KUSTOMIZE) build config/crd | kubectl create -f -
199-
200-
.PHONY: uninstall
201-
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
202-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
203-
204220
.PHONY: deploy
205221
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
206-
cd config/manager && $(KUSTOMIZE) edit set image k0s/k0smotron=${IMG}
207-
$(KUSTOMIZE) build config/default | kubectl create -f -
222+
cd config/clusterapi/all/manager && $(KUSTOMIZE) edit set image k0s/k0smotron=${IMG}
223+
$(KUSTOMIZE) build config/clusterapi/all | kubectl create -f -
224+
git checkout config/clusterapi/all/manager/kustomization.yaml
208225

209226
.PHONY: undeploy
210227
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
211-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
228+
$(KUSTOMIZE) build config/clusterapi/all | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
212229

213230
.PHONY: release
214-
release: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
215-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
216-
$(KUSTOMIZE) build config/default > install.yaml
217-
git checkout config/manager/kustomization.yaml
218-
219-
clusterapi-manifests:
220-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./api/bootstrap/..." output:crd:artifacts:config=config/clusterapi/bootstrap/bases
221-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./api/controlplane/..." output:crd:artifacts:config=config/clusterapi/controlplane/bases
222-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./api/infrastructure/..." output:crd:artifacts:config=config/clusterapi/infrastructure/bases
223-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./api/k0smotron.io/..." output:crd:artifacts:config=config/clusterapi/k0smotron.io/bases
224-
225-
bootstrap-components.yaml: $(CONTROLLER_GEN) clusterapi-manifests kustomize
226-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
231+
release: manifests-capi-integration kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
232+
cd config/clusterapi/all/manager && $(KUSTOMIZE) edit set image controller=${IMG}
233+
$(KUSTOMIZE) build config/clusterapi/all > install.yaml
234+
git checkout config/clusterapi/all/manager/kustomization.yaml
235+
236+
.PHONY: release-standalone
237+
release-standalone: manifests-standalone kustomize ## Generate install yaml for standalone mode
238+
cd config/standalone/manager && $(KUSTOMIZE) edit set image controller=${IMG}
239+
$(KUSTOMIZE) build config/standalone > install-standalone.yaml
240+
git checkout config/standalone/manager/kustomization.yaml
241+
242+
bootstrap-components.yaml: $(CONTROLLER_GEN) manifests-bootstrap kustomize
243+
cd config/clusterapi/bootstrap/manager && $(KUSTOMIZE) edit set image controller=${IMG}
227244
$(KUSTOMIZE) build config/clusterapi/bootstrap/ > bootstrap-components.yaml
228-
git checkout config/manager/kustomization.yaml
245+
git checkout config/clusterapi/bootstrap/manager/kustomization.yaml
229246

230-
control-plane-components.yaml: $(CONTROLLER_GEN) clusterapi-manifests kustomize
231-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
247+
control-plane-components.yaml: $(CONTROLLER_GEN) manifests-controlplane kustomize
248+
cd config/clusterapi/controlplane/manager && $(KUSTOMIZE) edit set image controller=${IMG}
232249
$(KUSTOMIZE) build config/clusterapi/controlplane/ > control-plane-components.yaml
233-
git checkout config/manager/kustomization.yaml
250+
git checkout config/clusterapi/controlplane/manager/kustomization.yaml
234251

235-
infrastructure-components.yaml: $(CONTROLLER_GEN) clusterapi-manifests kustomize
236-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
252+
infrastructure-components.yaml: $(CONTROLLER_GEN) manifests-infrastructure kustomize
253+
cd config/clusterapi/infrastructure/manager && $(KUSTOMIZE) edit set image controller=${IMG}
237254
$(KUSTOMIZE) build config/clusterapi/infrastructure/ > infrastructure-components.yaml
238-
git checkout config/manager/kustomization.yaml
255+
git checkout config/clusterapi/infrastructure/manager/kustomization.yaml
256+
239257
##@ Build Dependencies
240258

241259
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
@@ -270,23 +288,23 @@ $(CRDOC): Makefile.variables | $(LOCALBIN)
270288

271289
.PHONY: docs-generate-bootstrap docs-generate-controlplane docs-generate-infrastructure docs-generate-k0smotron docs-generate-reference
272290
docs-generate-bootstrap: $(CRDOC) ## Generate docs for bootstrap CRDs
273-
$(CRDOC) --resources config/crd/bases/bootstrap --output docs/resource-reference/bootstrap.cluster.x-k8s.io-v1beta1.md
291+
$(CRDOC) --resources config/clusterapi/bootstrap/crd/bases --output docs/resource-reference/bootstrap.cluster.x-k8s.io-v1beta1.md
274292

275293
docs-generate-controlplane: $(CRDOC) ## Generate docs for controlplane CRDs
276-
$(CRDOC) --resources config/crd/bases/controlplane --output docs/resource-reference/controlplane.cluster.x-k8s.io-v1beta1.md
294+
$(CRDOC) --resources config/clusterapi/controlplane/crd/bases --output docs/resource-reference/controlplane.cluster.x-k8s.io-v1beta1.md
277295

278296
docs-generate-infrastructure: $(CRDOC) ## Generate docs for infrastructure CRDs
279-
$(CRDOC) --resources config/crd/bases/infrastructure --output docs/resource-reference/infrastructure.cluster.x-k8s.io-v1beta1.md
297+
$(CRDOC) --resources config/clusterapi/infrastructure/crd/bases --output docs/resource-reference/infrastructure.cluster.x-k8s.io-v1beta1.md
280298

281299
docs-generate-k0smotron: $(CRDOC) ## Generate docs for k0smotron CRDs
282-
$(CRDOC) --resources config/crd/bases/k0smotron.io --output docs/resource-reference/k0smotron.io-v1beta1.md
300+
$(CRDOC) --resources config/standalone/crd/bases --output docs/resource-reference/k0smotron.io-v1beta1.md
283301

284302
# Generate docs for all CRDs apis
285303
docs-generate-reference: docs-generate-bootstrap docs-generate-controlplane docs-generate-infrastructure docs-generate-k0smotron
286304

287305
## Generate all code, manifests, documentation, and release artifacts
288306
.PHONY: generate-all
289-
generate-all: clean generate manifests clusterapi-manifests docs-generate-reference release
307+
generate-all: clean generate docs-generate-reference release
290308

291309
.PHONY: $(smoketests)
292310
$(smoketests): release k0smotron-image-bundle.tar
@@ -338,7 +356,7 @@ kind-deploy-capi:
338356

339357
.PHONY: kind-deploy-k0smotron
340358
kind-deploy-k0smotron: release k0smotron-image-bundle.tar
341-
kind load image-archive k0smotron-image-bundle.tar --name k0smotron
359+
kind load image-archive k0smotron-image-bundle.tar
342360
kubectl apply --server-side=true -f install.yaml
343361
kubectl rollout restart -n k0smotron deployment/k0smotron-controller-manager
344362

0 commit comments

Comments
 (0)