Skip to content

Commit f38a047

Browse files
authored
feat(kilo): add patched image build with cross mesh granularity (#2604)
## What this PR does Adds infrastructure for building a patched kilo image from upstream `main` branch source, following the same pattern as the kamaji package. The patch introduces a new `cross` mesh granularity mode — WireGuard tunnels are created only between nodes in different locations, while intra-location traffic stays on the CNI overlay. Changes: - `images/kilo/Dockerfile` — multi-stage build: fetches upstream tarball, applies patches, builds `kg`/`kgctl` binaries with CNI plugins and iptables-wrapper - `images/kilo/patches/feat-add-cross-mesh-granularity.diff` — adds `CrossGranularity` to the kilo binary - `Makefile` — new `image:` target for building the patched image, updated `update:` target to pin upstream commit SHA ### Screenshots N/A — no UI changes. ### Release note ```release-note feat(kilo): add patched image build with cross mesh granularity support ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added "cross" mesh granularity mode for finer topology grouping, adjusted routing/encryption behavior * Added e2e tests covering cross-mode scenarios for improved reliability * **Chores** * Build automation now tracks latest main commit and derives image digests from build metadata * Introduced multi-stage container build and runtime packaging for kilo, including required networking tooling * **Configuration** * Updated default image reference to a new repository and digest [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/cozystack/cozystack/pull/2604) <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 92d128e + 0be25ce commit f38a047

4 files changed

Lines changed: 1047 additions & 7 deletions

File tree

‎packages/system/kilo/Makefile‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ include ../../../hack/common-envs.mk
55
include ../../../hack/package.mk
66

77
update:
8-
tag=$$(git ls-remote --tags --sort="v:refname" https://github.com/squat/kilo | awk -F'[/^]' 'END{print $$3}') && \
9-
digest=$$(skopeo inspect --override-os linux --override-arch amd64 --format '{{.Digest}}' docker://ghcr.io/squat/kilo:$${tag}) && \
10-
REPOSITORY="ghcr.io/squat/kilo" \
11-
yq -i '.kilo.image.repository = strenv(REPOSITORY)' values.yaml && \
12-
TAG="$${tag}@$${digest}" \
8+
sha=$$(git ls-remote https://github.com/squat/kilo refs/heads/main | awk '{print $$1}') && \
9+
sed -i "/ARG VERSION/ s|=.*|=$${sha}|g" images/kilo/Dockerfile
10+
11+
image:
12+
docker buildx build images/kilo \
13+
--tag $(REGISTRY)/kilo:$(call settag,$(TAG)) \
14+
--cache-from type=registry,ref=$(REGISTRY)/kilo:latest \
15+
--cache-to type=inline \
16+
--metadata-file images/kilo.json \
17+
$(BUILDX_ARGS)
18+
REPOSITORY="$(REGISTRY)/kilo" \
19+
yq -i '.kilo.image.repository = strenv(REPOSITORY)' values.yaml
20+
TAG=$(TAG)@$$(yq e '."containerimage.digest"' images/kilo.json -o json -r) \
1321
yq -i '.kilo.image.tag = strenv(TAG)' values.yaml
22+
rm -f images/kilo.json
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Build the kg binary
2+
FROM --platform=$BUILDPLATFORM golang:1.25 AS builder
3+
4+
ARG VERSION=fbce60d8033da073748f5b0d6ce0f1e216f03e7f
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
8+
WORKDIR /workspace
9+
10+
RUN curl -sSL https://github.com/squat/kilo/archive/${VERSION}.tar.gz | tar -xzvf- --strip=1
11+
12+
COPY patches /patches
13+
RUN git apply /patches/*.diff
14+
15+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build \
16+
-trimpath \
17+
-ldflags "-X github.com/squat/kilo/pkg/version.Version=${VERSION}" \
18+
-a -o kg ./cmd/kg
19+
20+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build \
21+
-trimpath \
22+
-ldflags "-X github.com/squat/kilo/pkg/version.Version=${VERSION}" \
23+
-a -o kgctl ./cmd/kgctl
24+
25+
# Download CNI plugins
26+
FROM alpine:3.23 AS cni
27+
ARG TARGETARCH
28+
ARG CNI_PLUGINS_VERSION=v1.9.0
29+
RUN apk add --no-cache curl && \
30+
curl -Lo cni.tar.gz https://github.com/containernetworking/plugins/releases/download/$CNI_PLUGINS_VERSION/cni-plugins-linux-$TARGETARCH-$CNI_PLUGINS_VERSION.tgz && \
31+
tar -xf cni.tar.gz
32+
33+
FROM alpine:3.23
34+
RUN apk add --no-cache ipset iptables ip6tables graphviz font-noto
35+
COPY --from=cni bridge host-local loopback portmap /opt/cni/bin/
36+
ADD https://raw.githubusercontent.com/kubernetes-sigs/iptables-wrappers/e139a115350974aac8a82ec4b815d2845f86997e/iptables-wrapper-installer.sh /
37+
RUN chmod 700 /iptables-wrapper-installer.sh && /iptables-wrapper-installer.sh --no-sanity-check
38+
COPY --from=builder /workspace/kg /opt/bin/kg
39+
COPY --from=builder /workspace/kgctl /opt/bin/kgctl
40+
41+
ENTRYPOINT ["/opt/bin/kg"]

0 commit comments

Comments
 (0)