Skip to content

Commit ddab6e4

Browse files
committed
Support CAPI in-place version updates
Signed-off-by: apedriza <adripedriza@gmail.com>
1 parent eab61d0 commit ddab6e4

Some content is hidden

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

49 files changed

+1496
-61
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# Ignore build and test binaries.
33
bin/
44
testbin/
5+
extensions/config

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ jobs:
5858
uses: supplypike/setup-bin@v4
5959
with:
6060
name: clusterctl
61-
version: v1.11.4
62-
uri: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.11.4/clusterctl-linux-amd64
61+
version: v1.12.1
62+
uri: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.12.1/clusterctl-linux-amd64
6363

6464
- name: Download cluster-api components
6565
uses: actions/download-artifact@v5

.github/workflows/go.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ jobs:
8989
with:
9090
name: install-standalone-yaml
9191
path: install-standalone.yaml
92+
93+
- name: Generate inplace-extension install yaml
94+
run: |
95+
make release-extension-webhook
96+
97+
- name: Upload inplace-extension yaml
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: extension-webhook-install-yaml
101+
path: extension-webhook-install.yaml
92102

93103
unittest:
94104
name: Unit tests
@@ -262,6 +272,7 @@ jobs:
262272
- TestControlplaneRemediation
263273
- TestControlplaneConditions
264274
- TestWorkloadClusterInplaceUpgrade
275+
- TestWorkloadClusterCAPIInplaceUpgrade
265276
- TestWorkloadClusterRecreateUpgrade
266277
- TestWorkloadClusterRecreateDeleteFirstUpgrade
267278
- TestAdmissionWebhookRecreateStrategyInSingleMode

.github/workflows/publish-docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,14 @@ jobs:
9696
STABLE=${{ steps.set_versions.outputs.STABLE }}
9797
make release IMG=quay.io/k0sproject/k0smotron:${STABLE}
9898
make release-standalone IMG=quay.io/k0sproject/k0smotron:${STABLE}
99+
make release-extension-webhook IMG=quay.io/k0sproject/k0smotron:${STABLE}
99100
cp install.yaml /tmp/install.yaml
100101
cp install-standalone.yaml /tmp/install-standalone.yaml
102+
cp extension-webhook-install.yaml /tmp/extension-webhook-install.yaml
101103
git checkout gh-pages
102104
cp /tmp/install.yaml ${STABLE}/install.yaml
103105
cp /tmp/install-standalone.yaml ${STABLE}/install-standalone.yaml
104-
git add ${STABLE}/install.yaml ${STABLE}/install-standalone.yaml && git update-index --refresh
105-
git diff-index --quiet HEAD -- || git commit -m "Update install.yaml and install-standalone.yaml to ${STABLE}"
106+
cp /tmp/extension-webhook-install.yaml ${STABLE}/extension-webhook-install.yaml
107+
git add ${STABLE}/install.yaml ${STABLE}/install-standalone.yaml ${STABLE}/extension-webhook-install.yaml && git update-index --refresh
108+
git diff-index --quiet HEAD -- || git commit -m "Update install.yaml, install-standalone.yaml, and extension-webhook-install.yaml to ${STABLE}"
106109
git push origin gh-pages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated files
22
install.yaml
33
install-standalone.yaml
4+
extension-webhook-install.yaml
45
bootstrap-components.yaml
56
control-plane-components.yaml
67
infrastructure-components.yaml

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RUN go mod download
1717
COPY cmd/main.go cmd/main.go
1818
COPY api/ api/
1919
COPY internal/ internal/
20+
COPY extensions/ extensions/
2021

2122

2223
# Build
@@ -25,12 +26,13 @@ COPY internal/ internal/
2526
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2627
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
2728
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
28-
29+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -tags extension -o extension-webhook-server extensions/main.go
2930
# Use distroless as minimal base image to package the manager binary
3031
# Refer to https://github.com/GoogleContainerTools/distroless for more details
3132
FROM gcr.io/distroless/static:nonroot
3233
WORKDIR /
3334
COPY --from=builder /workspace/manager .
35+
COPY --from=builder /workspace/extension-webhook-server .
3436
USER 65532:65532
3537

3638
ENTRYPOINT ["/manager"]

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ generate-e2e-templates-main: $(KUSTOMIZE)
160160
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-machinedeployment --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-machinedeployment.yaml
161161
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-remote-hcp --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-remote-hcp.yaml
162162
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-ingress --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-ingress.yaml
163+
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-inplace-extension --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-inplace-extension.yaml
163164

164165
AWS_TEMPLATES := e2e/data/infrastructure-aws
165166

@@ -257,6 +258,12 @@ release-standalone: manifests-standalone kustomize ## Generate install yaml for
257258
$(KUSTOMIZE) build config/standalone > install-standalone.yaml
258259
git checkout config/manager/kustomization.yaml
259260

261+
.PHONY: release-extension-webhook
262+
release-extension-webhook: docker-build kustomize
263+
cd extensions/config/webhook && $(KUSTOMIZE) edit set image extension-webhook=${IMG}
264+
$(KUSTOMIZE) build extensions/config/default > extension-webhook-install.yaml
265+
git checkout extensions/config/webhook/kustomization.yaml
266+
260267
bootstrap-components.yaml: $(CONTROLLER_GEN) manifests-bootstrap kustomize
261268
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
262269
$(KUSTOMIZE) build config/clusterapi/bootstrap/ > bootstrap-components.yaml

api/bootstrap/v1beta1/k0s_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ type K0sWorkerConfigSpec struct {
104104
// UseSystemHostname specifies whether to use the system hostname for the kubernetes node name.
105105
// By default, k0smotron will use Machine name as a node name. If true, it will pick it from `hostname` command output.
106106
// +kubebuilder:validation:Optional
107-
// +kubebuilder:default=false
108107
UseSystemHostname bool `json:"useSystemHostname,omitempty"`
109108

110109
// Files specifies extra files to be passed to user_data upon creation.

cmd/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import (
3636
_ "k8s.io/client-go/plugin/pkg/client/auth"
3737
"k8s.io/client-go/rest"
3838
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
39+
runtimev1 "sigs.k8s.io/cluster-api/api/runtime/v1beta2"
40+
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3941
"sigs.k8s.io/cluster-api/util/flags"
4042
ctrl "sigs.k8s.io/controller-runtime"
4143
"sigs.k8s.io/controller-runtime/pkg/cache"
@@ -92,6 +94,8 @@ func init() {
9294
utilruntime.Must(clusterv1.AddToScheme(scheme))
9395
utilruntime.Must(cpv1beta1.AddToScheme(scheme))
9496
utilruntime.Must(infrastructurev1beta1.AddToScheme(scheme))
97+
utilruntime.Must(runtimev1.AddToScheme(scheme))
98+
utilruntime.Must(clusterctlv1.AddToScheme(scheme))
9599
//+kubebuilder:scaffold:scheme
96100
}
97101

config/clusterapi/all/rbac/role.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ rules:
138138
- get
139139
- list
140140
- watch
141+
- apiGroups:
142+
- clusterctl.cluster.x-k8s.io
143+
resources:
144+
- providers
145+
verbs:
146+
- get
147+
- list
148+
- watch
141149
- apiGroups:
142150
- controlplane.cluster.x-k8s.io
143151
resources:
@@ -213,6 +221,14 @@ rules:
213221
- patch
214222
- update
215223
- watch
224+
- apiGroups:
225+
- runtime.cluster.x-k8s.io
226+
resources:
227+
- extensionconfigs
228+
verbs:
229+
- get
230+
- list
231+
- watch
216232
- apiGroups:
217233
- storage.k8s.io
218234
resources:

0 commit comments

Comments
 (0)