Skip to content

Commit 7a0ba09

Browse files
committed
feat(operator): implement kilo-clustermesh-operator
Generic cluster-to-cluster mesh controller for Kilo that connects 2+ Kubernetes clusters into a flat node-to-node WireGuard mesh using Kilo's mesh-granularity=cross topology. Implements the design proposal from cozystack/community#7. Key components: - ClusterMesh CRD with named CIDR fields (podCIDRs, wireguardCIDR, serviceCIDR, additionalCIDRs) for precise validation - Two-layer validation: mesh-level CIDR overlap detection and per-node annotation validation (PodCIDR containment, WG-IP validity) - Multi-cluster client via controller-runtime pkg/cluster with graceful manager restart on cluster set changes - Peer builder creating per-node and anchor Peer CRDs with label-based ownership isolation between meshes - CRD self-install via embedded YAML applied on startup - Finalizer-based cleanup on ClusterMesh deletion - Helm chart with 38 helm-unittest assertions - Integration tests using dual envtest API servers - CI/CD with GitHub Actions (lint, test, integration, helm, release) Signed-off-by: Arsolitt <arsolitt@gmail.com>
0 parents  commit 7a0ba09

93 files changed

Lines changed: 8981 additions & 0 deletions

File tree

Some content is hidden

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

.containerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.git
2+
.github
3+
bin/
4+
dist/
5+
vendor/
6+
*.md
7+
LICENSE
8+
hack/
9+
charts/
10+
test/
11+
cover*.out

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated code
2+
**/zz_generated.*.go linguist-generated
3+
config/crd/bases/*.yaml linguist-generated
4+
5+
# Vendored Kilo types
6+
pkg/kilo/** linguist-vendored

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-go@v5
15+
with:
16+
go-version: "1.26.3"
17+
- uses: golangci/golangci-lint-action@v7
18+
with:
19+
version: latest
20+
21+
test:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-go@v5
26+
with:
27+
go-version: "1.26.3"
28+
- run: go test ./api/... ./pkg/... ./internal/... -race -coverprofile=coverage.out
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: coverage
32+
path: coverage.out
33+
34+
integration:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-go@v5
39+
with:
40+
go-version: "1.26.3"
41+
- run: go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
42+
- run: |
43+
export KUBEBUILDER_ASSETS=$(setup-envtest use -p path)
44+
go test ./test/integration/... -race -timeout 120s
45+
46+
build:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: actions/setup-go@v5
51+
with:
52+
go-version: "1.26.3"
53+
- run: go build -o /dev/null ./cmd/main.go
54+
55+
helm:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
- uses: azure/setup-helm@v4
60+
- run: helm plugin install https://github.com/helm-unittest/helm-unittest
61+
- run: helm lint charts/kilo-clustermesh-operator --strict
62+
- run: helm unittest charts/kilo-clustermesh-operator
63+
64+
generate:
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: actions/setup-go@v5
69+
with:
70+
go-version: "1.26.3"
71+
- run: make manifests generate
72+
- run: git diff --exit-code

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
jobs:
8+
image:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: docker/login-action@v3
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.actor }}
19+
password: ${{ secrets.GITHUB_TOKEN }}
20+
- uses: docker/setup-buildx-action@v3
21+
- uses: docker/build-push-action@v6
22+
with:
23+
context: .
24+
file: Containerfile
25+
push: true
26+
tags: |
27+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
28+
ghcr.io/${{ github.repository }}:latest
29+
platforms: linux/amd64,linux/arm64
30+
build-args: |
31+
VERSION=${{ github.ref_name }}
32+
REVISION=${{ github.sha }}

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
bin/*
8+
Dockerfile.cross
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
cover*.out
16+
17+
# Go workspace file
18+
go.work
19+
20+
# Vendored dependencies
21+
vendor/
22+
23+
# Build output
24+
dist/
25+
26+
# OS-specific
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Kubernetes Generated files - skip generated files, except for vendored files
31+
!vendor/**/zz_generated.*
32+
33+
# editor and IDE paraphernalia
34+
.idea
35+
.vscode
36+
*.swp
37+
*.swo
38+
*~
39+
40+
# Kubeconfig might contain secrets
41+
*.kubeconfig
42+
43+
# Internal planning docs (not for public history)
44+
PLAN.md

.golangci.yml

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
version: "2"
2+
3+
run:
4+
allow-parallel-runners: true
5+
6+
linters:
7+
default: all
8+
disable:
9+
- depguard
10+
- exhaustruct
11+
- gochecknoinits
12+
- wsl
13+
- lll
14+
- errchkjson
15+
- ireturn
16+
- gomoddirectives
17+
settings:
18+
tagliatelle:
19+
case:
20+
use-field-name: true
21+
extended-rules:
22+
json:
23+
case: camel
24+
extra-initialisms: true
25+
initialism-overrides:
26+
ID: true
27+
URL: true
28+
CPU: true
29+
IP: true
30+
OS: true
31+
API: true
32+
UUID: true
33+
MAC: true
34+
UID: true
35+
GID: true
36+
DNS: true
37+
CIDR: true
38+
dupl:
39+
threshold: 100
40+
goconst:
41+
min-len: 2
42+
min-occurrences: 2
43+
gocritic:
44+
disabled-checks:
45+
- dupImport
46+
- unnamedResult
47+
enabled-tags:
48+
- diagnostic
49+
- experimental
50+
- opinionated
51+
- performance
52+
- style
53+
funlen:
54+
lines: 60
55+
statements: 60
56+
gocyclo:
57+
min-complexity: 15
58+
cyclop:
59+
max-complexity: 15
60+
mnd:
61+
ignored-numbers:
62+
- "2"
63+
- "10"
64+
- "60"
65+
- "64"
66+
- "100"
67+
- "500"
68+
- "1000"
69+
godot:
70+
exclude:
71+
- "^ ?\\+kubebuilder:"
72+
- "^ ?\\+optional"
73+
wrapcheck:
74+
ignore-sig-regexps:
75+
- '\.Newf\('
76+
ignore-package-globs:
77+
- github.com/cockroachdb/errors
78+
nolintlint:
79+
require-explanation: true
80+
require-specific: true
81+
allow-unused: false
82+
varnamelen:
83+
max-distance: 5
84+
min-name-length: 3
85+
check-receiver: false
86+
check-return: false
87+
ignore-type-assert-ok: false
88+
ignore-map-index-ok: false
89+
ignore-chan-recv-ok: false
90+
ignore-decls:
91+
- wg sync.WaitGroup
92+
- wg *sync.WaitGroup
93+
- mu sync.Mutex
94+
- ok bool
95+
ignore-names:
96+
- i
97+
- w
98+
- r
99+
- b
100+
- c
101+
- m
102+
- n
103+
- tt
104+
- rw
105+
exclusions:
106+
generated: lax
107+
presets:
108+
- comments
109+
- common-false-positives
110+
- legacy
111+
- std-error-handling
112+
paths:
113+
- third_party$
114+
- builtin$
115+
- examples/
116+
- generated\.go$
117+
rules:
118+
- linters:
119+
- funlen
120+
- dupl
121+
- gocognit
122+
- gocyclo
123+
- cyclop
124+
- errcheck
125+
- testableexamples
126+
- testpackage
127+
- forcetypeassert
128+
- gocritic
129+
- nlreturn
130+
- wsl_v5
131+
- varnamelen
132+
- unparam
133+
- modernize
134+
- gosec
135+
- testifylint
136+
- perfsprint
137+
- paralleltest
138+
- maintidx
139+
- godox
140+
- revive
141+
- gochecknoglobals
142+
- noinlineerr
143+
path: _test\.go
144+
- linters:
145+
- err113
146+
- fatcontext
147+
- forbidigo
148+
- forcetypeassert
149+
- goconst
150+
- nolintlint
151+
- prealloc
152+
- unconvert
153+
- varnamelen
154+
- wsl_v5
155+
- noctx
156+
- noinlineerr
157+
- gosec
158+
- mnd
159+
- gocritic
160+
- maintidx
161+
- intrange
162+
- staticcheck
163+
- wrapcheck
164+
- revive
165+
path: test/
166+
- linters:
167+
- gochecknoglobals
168+
- gocognit
169+
- funlen
170+
- gocyclo
171+
- cyclop
172+
- maintidx
173+
- noinlineerr
174+
- mnd
175+
path: cmd/
176+
- linters:
177+
- gochecknoglobals
178+
- revive
179+
- gocritic
180+
- varnamelen
181+
- godot
182+
- mnd
183+
- funlen
184+
- gocognit
185+
- gocyclo
186+
- cyclop
187+
- maintidx
188+
path: zz_generated
189+
- linters:
190+
- gochecknoglobals
191+
path: groupversion_info\.go
192+
193+
formatters:
194+
enable:
195+
- gofmt
196+
- gofumpt
197+
- goimports
198+
exclusions:
199+
generated: lax
200+
paths:
201+
- third_party$
202+
- builtin$
203+
- examples/
204+
- generated\.go$

0 commit comments

Comments
 (0)