Skip to content

Commit e184ac6

Browse files
kvapsclaude
andcommitted
feat(cpprovider): rebuild kamaji control-plane provider from v0.19.0 + patch
Replaces the externally-built v0.16.0-talos-csr-signer.0 fork image (image and ConfigMap version labels had drifted: image suffix .0, ConfigMap/Provider suffix .1) with a chart-local build from upstream v0.19.0 plus a single backport patch: - new images/cluster-api-control-plane-provider-kamaji/Dockerfile builds the manager from upstream v0.19.0 with patches/ applied, on top of distroless/static:nonroot; - patches/0001-backport-additional-service-ports-pr347.diff brings upstream PR #347 (AdditionalServicePorts) back to the v1alpha1 schema — upstream merged the feature to v1alpha2 only, but our chart's KamajiControlPlane is still v1alpha1 to avoid breaking in-flight tenants; - new image and update Makefile targets handle build, manifest regen via kustomize, and components.gz refresh; - files/control-plane-components.yaml + files/components.gz regenerated from v0.19.0+patch via make update; - templates/providers.yaml + templates/configmaps.yaml renamed to v0.19.0-cozystack.0 (single source of truth, no .0/.1 skew). Why v0.19.0 instead of master: upstream master (PR #327) renames api/v1alpha1 -> api/v1alpha2 wholesale, drops v1alpha1 entirely, and ships no conversion webhook. Adopting it would orphan every existing v1alpha1 KamajiControlPlane until manual rewrite. Once upstream gives us either a real migration path or a v1alpha1 served as deprecated alongside v1alpha2, this Dockerfile + patches can go. Co-Authored-By: Claude <[email protected]> Signed-off-by: Andrei Kvapil <[email protected]>
1 parent b289e7f commit e184ac6

8 files changed

Lines changed: 2813 additions & 619 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ build: build-deps
2828
make -C packages/system/dashboard image
2929
make -C packages/system/metallb image
3030
make -C packages/system/kamaji image
31+
make -C packages/system/capi-providers-cpprovider image
3132
make -C packages/system/multus image
3233
make -C packages/system/bucket image
3334
make -C packages/system/objectstorage-controller image
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
11
export NAME=capi-providers-cpprovider
22
export NAMESPACE=cozy-cluster-api
33

4+
include ../../../hack/common-envs.mk
45
include ../../../hack/package.mk
6+
7+
.PHONY: image update
8+
9+
# Upstream tag pinned in the Dockerfile and reused below for the
10+
# kustomize re-render. Keep them in lockstep when bumping.
11+
UPSTREAM_VERSION = $(shell awk -F= '/^ARG VERSION=/{print $$2}' images/cluster-api-control-plane-provider-kamaji/Dockerfile)
12+
# Counter for cozystack-side respins on top of the same UPSTREAM_VERSION
13+
# (e.g. patches/ refresh, Go toolchain bump). Bump when something other
14+
# than UPSTREAM_VERSION changes.
15+
COZYSTACK_REV = 0
16+
IMAGE_BASE = $(REGISTRY)/cluster-api-control-plane-provider-kamaji
17+
IMAGE_TAG = $(UPSTREAM_VERSION)-cozystack.$(COZYSTACK_REV)
18+
19+
image:
20+
docker buildx build images/cluster-api-control-plane-provider-kamaji \
21+
--tag $(IMAGE_BASE):$(IMAGE_TAG) \
22+
--tag $(IMAGE_BASE):$(IMAGE_TAG)-$(TAG) \
23+
--cache-from type=registry,ref=$(IMAGE_BASE):latest \
24+
--cache-to type=inline \
25+
--metadata-file images/cluster-api-control-plane-provider-kamaji.json \
26+
$(BUILDX_ARGS)
27+
digest=$$(yq e '."containerimage.digest"' images/cluster-api-control-plane-provider-kamaji.json -o json -r); \
28+
IMG="$(IMAGE_BASE):$(IMAGE_TAG)@$$digest"; \
29+
echo "$$IMG" > images/cluster-api-control-plane-provider-kamaji.tag; \
30+
sed -i.bak -E "s|image: ghcr\.io/.+/cluster-api-control-plane-provider-kamaji:[^[:space:]]+|image: $$IMG|" files/control-plane-components.yaml; \
31+
rm files/control-plane-components.yaml.bak; \
32+
gzip -nc files/control-plane-components.yaml > files/components.gz
33+
rm -f images/cluster-api-control-plane-provider-kamaji.json
34+
35+
# Refreshes files/control-plane-components.yaml + files/components.gz from
36+
# upstream sources at UPSTREAM_VERSION with patches/ applied, leaving the
37+
# manager image ref pointing at our mirror. Use when bumping UPSTREAM_VERSION
38+
# or editing patches/. Requires kustomize on PATH.
39+
update:
40+
@command -v kustomize >/dev/null || { echo "kustomize required (https://kustomize.io)"; exit 1; }
41+
rm -rf .update-tmp
42+
mkdir .update-tmp
43+
curl -sSL "https://github.com/clastix/cluster-api-control-plane-provider-kamaji/archive/refs/tags/$(UPSTREAM_VERSION).tar.gz" \
44+
| tar -xzf - --strip=1 -C .update-tmp
45+
cd .update-tmp && git init -q && git add . && git commit -qm init && \
46+
for p in ../images/cluster-api-control-plane-provider-kamaji/patches/*.diff; do \
47+
git apply --recount "$$p"; \
48+
done
49+
cd .update-tmp/config/manager && \
50+
kustomize edit set image controller=$(IMAGE_BASE):$(IMAGE_TAG)
51+
kustomize build .update-tmp/config/default > files/control-plane-components.yaml
52+
gzip -nc files/control-plane-components.yaml > files/components.gz
53+
rm -rf .update-tmp
8.51 KB
Binary file not shown.

‎packages/system/capi-providers-cpprovider/files/control-plane-components.yaml‎

Lines changed: 2421 additions & 617 deletions
Large diffs are not rendered by default.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Builds the clastix/cluster-api-control-plane-provider-kamaji manager
2+
# binary from a tagged upstream release with a small backport patch.
3+
#
4+
# We pin to v0.19.0 because everything after it (upstream master, the
5+
# unreleased v0.20.0) renames api/v1alpha1 -> api/v1alpha2 wholesale and
6+
# ships a CRD that serves only v1alpha2 with no conversion webhook -
7+
# upgrading would orphan every existing KamajiControlPlane in the wild
8+
# until a manual rewrite. patches/0001-backport-additional-service-ports-pr347.diff
9+
# brings PR #347 (AdditionalServicePorts) back to the v1alpha1 schema,
10+
# which our chart relies on for the talos-trustd sidecar port. Once
11+
# upstream ships a real migration path, drop both this Dockerfile and the
12+
# patch and consume vanilla upstream images directly.
13+
FROM golang:1.26 AS builder
14+
15+
# Upstream release tag. Bump together with patches/ when refreshing.
16+
ARG VERSION=v0.19.0
17+
ARG TARGETOS
18+
ARG TARGETARCH
19+
20+
WORKDIR /workspace
21+
22+
RUN curl -sSL "https://github.com/clastix/cluster-api-control-plane-provider-kamaji/archive/refs/tags/${VERSION}.tar.gz" \
23+
| tar -xzf - --strip=1
24+
25+
COPY patches /patches
26+
RUN git apply --recount /patches/*.diff
27+
28+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
29+
go build -a -o manager main.go
30+
31+
FROM gcr.io/distroless/static:nonroot
32+
WORKDIR /
33+
COPY --from=builder /workspace/manager /manager
34+
USER 65532:65532
35+
36+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)