Skip to content

Commit 42bba1d

Browse files
committed
initial: Nantian Gateway control plane — Go
1 parent d891034 commit 42bba1d

6,099 files changed

Lines changed: 18685 additions & 1568355 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.

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.git
22
target
33
dataplane/target
4-
controlplane/bin
4+
bin
55
tmp
66
coverage
77
dashboard/.next

.github/workflows/ci.yml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,56 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-go@v5
1818
with:
19-
go-version-file: controlplane/go.mod
20-
cache-dependency-path: controlplane/go.sum
19+
go-version-file: go.mod
20+
cache-dependency-path: go.sum
2121
- name: Build
22-
run: cd controlplane && go build ./...
22+
run: go build ./...
2323

2424
go-test:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v4
2828
- uses: actions/setup-go@v5
2929
with:
30-
go-version-file: controlplane/go.mod
31-
cache-dependency-path: controlplane/go.sum
30+
go-version-file: go.mod
31+
cache-dependency-path: go.sum
3232
- name: Test
33-
run: cd controlplane && go test ./...
33+
run: go test ./...
3434

3535
proto-check:
3636
runs-on: ubuntu-latest
3737
steps:
3838
- uses: actions/checkout@v4
3939
- uses: actions/setup-go@v5
4040
with:
41-
go-version-file: controlplane/go.mod
42-
cache-dependency-path: controlplane/go.sum
41+
go-version-file: go.mod
42+
cache-dependency-path: go.sum
43+
- uses: bufbuild/buf-setup-action@v1
44+
with:
45+
github_token: ${{ github.token }}
46+
buf_api_token: ${{ secrets.BUF_TOKEN }}
47+
- name: Buf generate
48+
env:
49+
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
50+
run: buf generate buf.build/nantian/proto
4351
- name: Verify go mod tidy
4452
run: |
45-
cd controlplane
4653
go mod tidy
4754
git diff --exit-code
48-
49-
script-check:
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v4
53-
- name: Install dependencies
54-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends python3
55-
- name: Check script inventory
56-
run: ./scripts/check-script-inventory.sh
55+
- name: Verify generated code is up to date
56+
run: |
57+
if ! git diff --exit-code gen/; then
58+
echo "::error::Generated Go code is out of date. Run 'buf generate buf.build/nantian/proto && go mod tidy' locally and commit the changes."
59+
exit 1
60+
fi
5761
5862
go-bench:
5963
runs-on: ubuntu-latest
6064
steps:
6165
- uses: actions/checkout@v4
6266
- uses: actions/setup-go@v5
6367
with:
64-
go-version-file: controlplane/go.mod
65-
cache-dependency-path: controlplane/go.sum
68+
go-version-file: go.mod
69+
cache-dependency-path: go.sum
6670
- name: Run benchmarks
67-
run: cd controlplane && go test -bench=. -benchtime=1x ./...
71+
run: go test -bench=. -benchtime=1x ./...

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: CodeQL
77
paths:
88
- ".github/workflows/**"
99
- "Makefile"
10-
- "controlplane/**"
10+
- "**"
1111
- "proto/**"
1212
- "tests/conformance-harness/**"
1313
pull_request:
@@ -16,7 +16,7 @@ name: CodeQL
1616
paths:
1717
- ".github/workflows/**"
1818
- "Makefile"
19-
- "controlplane/**"
19+
- "**"
2020
- "proto/**"
2121
- "tests/conformance-harness/**"
2222
schedule:
@@ -46,9 +46,9 @@ jobs:
4646
- name: Set up Go
4747
uses: actions/setup-go@v5
4848
with:
49-
go-version-file: controlplane/go.mod
49+
go-version-file: go.mod
5050
cache-dependency-path: |
51-
controlplane/go.sum
51+
go.sum
5252
tests/conformance-harness/go.sum
5353
5454
- name: Install Go build dependencies

.github/workflows/conformance.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Conformance
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *'
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
gateway-api:
14+
name: Gateway API Conformance
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
cache-dependency-path: go.sum
23+
24+
- name: Create kind cluster
25+
run: |
26+
kind create cluster --name conformance --wait 5m
27+
kubectl wait --for=condition=ready node --all --timeout=2m
28+
29+
- name: Install Gateway API CRDs
30+
run: |
31+
for i in 1 2 3; do
32+
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml && break
33+
echo "Retry $i in 10s..."
34+
sleep 10
35+
done
36+
kubectl wait --for=condition=established crd/gatewayclasses.gateway.networking.k8s.io --timeout=60s
37+
38+
- name: Deploy nantian-gw
39+
run: |
40+
kubectl apply -k deploy/kubernetes/overlays/kind-conformance
41+
kubectl wait --for=condition=ready pod --all -n nantian-gw --timeout=300s
42+
43+
- name: Record image versions
44+
run: |
45+
echo "=== Images under test ==="
46+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"'
47+
echo "=== Image digests ==="
48+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"'
49+
50+
- name: Run conformance tests
51+
run: |
52+
go test -tags=conformance -count=1 -v -timeout 30m ./conformance/
53+
54+
- name: Collect logs on failure
55+
if: failure()
56+
run: |
57+
kubectl describe pods -n nantian-gw
58+
kubectl logs -n nantian-gw --all-containers --tail=200 || true
59+
60+
- name: Cleanup
61+
if: always()
62+
run: kind delete cluster --name conformance

.github/workflows/docker.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
jobs:
17+
build:
18+
name: Build image
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v4
25+
26+
- name: Docker metadata
27+
id: meta
28+
uses: docker/metadata-action@v6
29+
with:
30+
images: ghcr.io/${{ github.repository_owner }}/nantian-controlplane
31+
tags: |
32+
type=sha,prefix=sha-,format=short
33+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
34+
35+
- name: Login to GHCR
36+
if: github.ref == 'refs/heads/main'
37+
uses: docker/login-action@v4
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Build and push
44+
uses: docker/build-push-action@v7
45+
with:
46+
context: .
47+
push: ${{ github.ref == 'refs/heads/main' }}
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max

.github/workflows/e2e.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: E2E
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *'
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
smoke:
14+
name: Smoke
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Create kind cluster
20+
run: |
21+
kind create cluster --name e2e --wait 5m
22+
kubectl wait --for=condition=ready node --all --timeout=2m
23+
24+
- name: Install Gateway API CRDs
25+
run: |
26+
for i in 1 2 3; do
27+
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml && break
28+
echo "Retry $i in 10s..."
29+
sleep 10
30+
done
31+
kubectl wait --for=condition=established crd/gatewayclasses.gateway.networking.k8s.io --timeout=60s
32+
33+
- name: Deploy nantian-gw
34+
run: |
35+
kubectl apply -k deploy/kubernetes/overlays/kind-conformance
36+
kubectl wait --for=condition=ready pod --all -n nantian-gw --timeout=300s
37+
38+
- name: Record image versions
39+
run: |
40+
echo "=== Images under test ==="
41+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"'
42+
echo "=== Image digests ==="
43+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"'
44+
45+
- name: Run smoke test
46+
run: |
47+
CLUSTER_NAME=e2e ./test/e2e/smoke/run.sh --no-cleanup
48+
49+
- name: Collect logs on failure
50+
if: failure()
51+
run: |
52+
kubectl describe pods -n nantian-gw
53+
kubectl logs -n nantian-gw --all-containers --tail=200
54+
55+
- name: Cleanup
56+
if: always()
57+
run: kind delete cluster --name e2e

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
fi
4848
4949
owner_lc="${GITHUB_REPOSITORY_OWNER,,}"
50-
control_image_name="ghcr.io/${owner_lc}/aether-gateway-controlplane"
50+
control_image_name="ghcr.io/${owner_lc}/nantian-controlplane"
5151
control_image="${control_image_name}:${release_tag}"
5252
5353
{
@@ -76,8 +76,8 @@ jobs:
7676
- name: Set up Go
7777
uses: actions/setup-go@v5
7878
with:
79-
go-version-file: controlplane/go.mod
80-
cache-dependency-path: controlplane/go.sum
79+
go-version-file: go.mod
80+
cache-dependency-path: go.sum
8181

8282
- name: Run Go unit tests
8383
working-directory: controlplane
@@ -100,8 +100,8 @@ jobs:
100100
- name: Set up Go
101101
uses: actions/setup-go@v5
102102
with:
103-
go-version-file: controlplane/go.mod
104-
cache-dependency-path: controlplane/go.sum
103+
go-version-file: go.mod
104+
cache-dependency-path: go.sum
105105

106106
- name: Install release validation dependencies
107107
run: |
@@ -198,8 +198,8 @@ jobs:
198198
- name: Set up Go
199199
uses: actions/setup-go@v5
200200
with:
201-
go-version-file: controlplane/go.mod
202-
cache-dependency-path: controlplane/go.sum
201+
go-version-file: go.mod
202+
cache-dependency-path: go.sum
203203

204204
- name: Set up Docker Buildx
205205
uses: docker/setup-buildx-action@v4
@@ -216,7 +216,7 @@ jobs:
216216
uses: docker/build-push-action@v6
217217
with:
218218
context: .
219-
file: controlplane/Dockerfile
219+
file: Dockerfile
220220
push: true
221221
tags: ${{ needs.metadata.outputs.control_image }}
222222

.github/workflows/security-scans.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
- name: Set up Go
2626
uses: actions/setup-go@v5
2727
with:
28-
go-version-file: controlplane/go.mod
29-
cache-dependency-path: controlplane/go.sum
28+
go-version-file: go.mod
29+
cache-dependency-path: go.sum
3030

3131
- name: Install scanner prerequisites
3232
run: |

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ dist/
55
.vscode/
66
coverage/
77
tmp/
8-
controlplane/internal/gen/
9-
!controlplane/internal/gen/
10-
!controlplane/internal/gen/gateway/
11-
!controlplane/internal/gen/gateway/control/
12-
!controlplane/internal/gen/gateway/control/v1/
13-
!controlplane/internal/gen/gateway/control/v1/*.go
14-
controlplane/bin/
8+
159
.DS_Store
1610
build_push.sh
1711
.worktrees/

0 commit comments

Comments
 (0)