Skip to content

Commit f009012

Browse files
authored
feat(standalone): support apisix-standalone for adc (#155)
1 parent e365525 commit f009012

Some content is hidden

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

54 files changed

+769
-392
lines changed

.github/workflows/apisix-conformance-test.yml.example renamed to .github/workflows/apisix-conformance-test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
ARCH: amd64
5555
ENABLE_PROXY: "false"
5656
BASE_IMAGE_TAG: "debug"
57+
ADC_VERSION: "dev"
5758
run: |
5859
echo "building images..."
5960
make build-image
@@ -73,7 +74,7 @@ jobs:
7374
7475
- name: Loading Docker Image to Kind Cluster
7576
run: |
76-
make kind-load-images
77+
make kind-load-ingress-image
7778
7879
- name: Run Conformance Test
7980
shell: bash
@@ -106,6 +107,6 @@ jobs:
106107
if: ${{ github.event_name == 'pull_request' }}
107108
uses: mshick/add-pr-comment@v2
108109
with:
109-
message-id: '${{ matrix.target }}'
110+
message-id: 'apisix-conformance-test-report'
110111
message-path: |
111112
report.md

.github/workflows/apisix-e2e-test.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,35 @@ jobs:
5353
ARCH: amd64
5454
ENABLE_PROXY: "false"
5555
BASE_IMAGE_TAG: "debug"
56+
ADC_VERSION: "dev"
5657
run: |
5758
echo "building images..."
5859
make build-image
5960
61+
- name: Extract adc binary
62+
run: |
63+
echo "Extracting adc binary..."
64+
docker create --name adc-temp api7/api7-ingress-controller:dev
65+
docker cp adc-temp:/bin/adc /usr/local/bin/adc
66+
docker rm adc-temp
67+
chmod +x /usr/local/bin/adc
68+
echo "ADC binary extracted to /usr/local/bin/adc"
69+
6070
- name: Launch Kind Cluster
6171
run: |
6272
make kind-up
6373
74+
- name: Loading Docker Image to Kind Cluster
75+
run: |
76+
make kind-load-ingress-image
77+
6478
- name: Install Gateway API And CRDs
6579
run: |
6680
make install
6781
6882
- name: Run E2E test suite
6983
shell: bash
84+
env:
85+
TEST_DIR: "./test/e2e/apisix/"
7086
run: |
71-
make e2e-test-standalone
87+
make e2e-test

.github/workflows/conformance-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ jobs:
125125
if: ${{ github.event_name == 'pull_request' }}
126126
uses: mshick/add-pr-comment@v2
127127
with:
128-
message-id: '${{ matrix.target }}'
128+
message-id: 'conformance-test-report'
129129
message-path: |
130130
report.md

.github/workflows/e2e-test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,13 @@ jobs:
7070
echo "building images..."
7171
make build-image
7272
73-
- name: Build Dockerfile.dev and extract adc binary
73+
- name: Extract adc binary
7474
run: |
75-
echo "Building Dockerfile.dev..."
76-
docker build -f Dockerfile.dev -t adc-builder:latest .
7775
echo "Extracting adc binary..."
78-
docker run --name adc-temp --entrypoint="" adc-builder:latest /bin/true
79-
docker cp adc-temp:/bin/adc ./bin/adc
76+
docker create --name adc-temp api7/api7-ingress-controller:dev
77+
docker cp adc-temp:/bin/adc /usr/local/bin/adc
8078
docker rm adc-temp
81-
chmod +x ./bin/adc
82-
mv ./bin/adc /usr/local/bin/adc
79+
chmod +x /usr/local/bin/adc
8380
echo "ADC binary extracted to /usr/local/bin/adc"
8481
8582
- name: Launch Kind Cluster

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ apisix-ingress-controller-conformance-report.yaml
3636
.env
3737

3838
charts/api7ee3
39+
docs/api

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
ARG ENABLE_PROXY=false
21
ARG BASE_IMAGE_TAG=nonroot
32

43
FROM debian:bullseye-slim AS deps
54
WORKDIR /workspace
65

7-
ARG ADC_VERSION=0.19.0
86
ARG TARGETARCH
7+
ARG ADC_VERSION
98

109
RUN apt update \
1110
&& apt install -y wget \

Dockerfile.dev

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ ARG ENABLE_PROXY=false
33
FROM node:22 AS node_builder
44

55
ARG TARGETARCH
6-
ARG ADC_COMMIT=e948079ed0576dbac29320ebfa01c9b7a298924c
76

87
WORKDIR /app
98

109
RUN apt update \
1110
&& apt install -y git \
1211
&& git clone --branch main https://github.com/api7/adc.git \
1312
&& cd adc \
14-
&& git checkout ${ADC_COMMIT} \
1513
&& corepack enable pnpm \
1614
&& pnpm install \
1715
&& NODE_ENV=production npx nx build cli \

Makefile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ IMAGE_TAG ?= dev
88
IMG ?= api7/api7-ingress-controller:$(IMAGE_TAG)
99
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
1010
ENVTEST_K8S_VERSION = 1.30.0
11-
1211
KIND_NAME ?= apisix-ingress-cluster
13-
GATEAY_API_VERSION ?= v1.2.0
1412

13+
GATEAY_API_VERSION ?= v1.2.0
1514
DASHBOARD_VERSION ?= dev
15+
ADC_VERSION ?= 0.19.0
16+
1617
TEST_TIMEOUT ?= 60m
18+
TEST_DIR ?= ./test/e2e/
1719

1820
# CRD Reference Documentation
1921
CRD_REF_DOCS_VERSION ?= v0.1.0
@@ -109,12 +111,7 @@ kind-e2e-test: kind-up build-image kind-load-images e2e-test
109111
.PHONY: e2e-test
110112
e2e-test:
111113
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
112-
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test ./test/e2e/ -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)"
113-
114-
.PHONY: e2e-test-standalone
115-
e2e-test-standalone:
116-
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
117-
go test ./test/e2e/apisix/ -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)"
114+
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test $(TEST_DIR) -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)"
118115

119116
.PHONY: download-api7ee3-chart
120117
download-api7ee3-chart:
@@ -207,11 +204,11 @@ build-multi-arch:
207204
.PHONY: build-multi-arch-image
208205
build-multi-arch-image: build-multi-arch
209206
# daemon.json: "features":{"containerd-snapshotter": true}
210-
@docker buildx build --load --platform linux/amd64,linux/arm64 -t $(IMG) .
207+
@docker buildx build --load --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
211208

212209
.PHONY: build-push-multi-arch-image
213210
build-push-multi-arch-image: build-multi-arch
214-
@docker buildx build --push --platform linux/amd64,linux/arm64 -t $(IMG) .
211+
@docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
215212

216213
.PHONY: run
217214
run: manifests generate fmt vet ## Run a controller from your host.
@@ -222,7 +219,12 @@ run: manifests generate fmt vet ## Run a controller from your host.
222219
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
223220
.PHONY: docker-build
224221
docker-build: set-e2e-goos build ## Build docker image with the manager.
225-
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile .
222+
@echo "Building with ADC_VERSION=$(ADC_VERSION)"
223+
@if [ "$(strip $(ADC_VERSION))" = "dev" ]; then \
224+
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile.dev . ; \
225+
else \
226+
$(CONTAINER_TOOL) build --build-arg ADC_VERSION=${ADC_VERSION} -t ${IMG} -f Dockerfile . ; \
227+
fi
226228

227229
.PHONY: docker-push
228230
docker-push: ## Push docker image with the manager.

api/v1alpha1/consumer_types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ type Consumer struct {
2525

2626
// ConsumerSpec defines the configuration for a consumer, including consumer name,
2727
// authentication credentials, and plugin settings.
28-
Spec ConsumerSpec `json:"spec,omitempty"`
29-
Status Status `json:"status,omitempty"`
28+
Spec ConsumerSpec `json:"spec,omitempty"`
29+
Status ConsumerStatus `json:"status,omitempty"`
3030
}
3131

32+
type ConsumerStatus struct {
33+
Status `json:",inline"`
34+
}
3235
type ConsumerSpec struct {
3336
// GatewayRef specifies the gateway details.
3437
GatewayRef GatewayRef `json:"gatewayRef,omitempty"`

api/v1alpha1/gatewayproxy_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ type ControlPlaneProvider struct {
117117
// +kubebuilder:validation:MinItems=1
118118
Endpoints []string `json:"endpoints"`
119119

120+
Service *ProviderService `json:"service,omitempty"`
120121
// TlsVerify specifies whether to verify the TLS certificate of the control plane.
121122
// +optional
122123
TlsVerify *bool `json:"tlsVerify,omitempty"`
@@ -126,6 +127,14 @@ type ControlPlaneProvider struct {
126127
Auth ControlPlaneAuth `json:"auth"`
127128
}
128129

130+
type ProviderService struct {
131+
Name string `json:"name"`
132+
133+
// +kubebuilder:validation:Minimum=1
134+
// +kubebuilder:validation:Maximum=65535
135+
Port int32 `json:"port,omitempty"`
136+
}
137+
129138
// +kubebuilder:object:root=true
130139
// GatewayProxy is the Schema for the gatewayproxies API.
131140
type GatewayProxy struct {

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/apisix.apache.org_gatewayproxies.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ spec:
119119
type: string
120120
minItems: 1
121121
type: array
122+
service:
123+
properties:
124+
name:
125+
type: string
126+
port:
127+
format: int32
128+
maximum: 65535
129+
minimum: 1
130+
type: integer
131+
required:
132+
- name
133+
type: object
122134
tlsVerify:
123135
description: TlsVerify specifies whether to verify the TLS
124136
certificate of the control plane.

config/samples/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ exec_adc_timeout: 15s # The timeout for the ADC to execute.
3232
# The default value is 15 seconds.
3333

3434
provider:
35+
type: "api7ee"
36+
3537
sync_period: 0s
3638
# The period between two consecutive syncs.
3739
# The default value is 0 seconds, which means the controller will not sync.

docs/crd/api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ _Appears in:_
202202
_Appears in:_
203203
- [Consumer](#consumer)
204204

205+
206+
205207
#### ControlPlaneAuth
206208

207209

@@ -228,6 +230,7 @@ ControlPlaneProvider defines the configuration for control plane provider.
228230
| Field | Description |
229231
| --- | --- |
230232
| `endpoints` _string array_ | Endpoints specifies the list of control plane endpoints. |
233+
| `service` _[ProviderService](#providerservice)_ | |
231234
| `tlsVerify` _boolean_ | TlsVerify specifies whether to verify the TLS certificate of the control plane. |
232235
| `auth` _[ControlPlaneAuth](#controlplaneauth)_ | Auth specifies the authentication configurations. |
233236

@@ -403,6 +406,22 @@ _Appears in:_
403406

404407

405408

409+
#### ProviderService
410+
411+
412+
413+
414+
415+
416+
| Field | Description |
417+
| --- | --- |
418+
| `name` _string_ | |
419+
| `port` _integer_ | |
420+
421+
422+
_Appears in:_
423+
- [ControlPlaneProvider](#controlplaneprovider)
424+
406425
#### ProviderType
407426
_Base type:_ `string`
408427

@@ -447,8 +466,21 @@ _Appears in:_
447466
_Appears in:_
448467
- [Credential](#credential)
449468

469+
#### Status
470+
471+
472+
473+
450474

451475

476+
| Field | Description |
477+
| --- | --- |
478+
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#condition-v1-meta) array_ | |
479+
480+
481+
_Appears in:_
482+
- [ConsumerStatus](#consumerstatus)
483+
452484
#### Timeout
453485

454486

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ require (
2727
go.uber.org/zap v1.27.0
2828
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
2929
golang.org/x/net v0.28.0
30+
google.golang.org/protobuf v1.34.2
3031
gopkg.in/yaml.v3 v3.0.1
3132
helm.sh/helm/v3 v3.15.4
3233
k8s.io/api v0.31.1
@@ -201,7 +202,6 @@ require (
201202
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
202203
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
203204
google.golang.org/grpc v1.66.2 // indirect
204-
google.golang.org/protobuf v1.34.2 // indirect
205205
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
206206
gopkg.in/fsnotify.v1 v1.4.7 // indirect
207207
gopkg.in/inf.v0 v0.9.1 // indirect

0 commit comments

Comments
 (0)