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 {

0 commit comments

Comments
 (0)