Skip to content

Commit fa25717

Browse files
committed
feat: support apisix standalone
Signed-off-by: ashing <axingfly@gmail.com>
1 parent 5326028 commit fa25717

File tree

125 files changed

+16721
-779
lines changed

Some content is hidden

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

125 files changed

+16721
-779
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ apisix-ingress-controller-conformance-report.yaml
3434
*.mdx
3535
.cursor/
3636
.env
37+
38+
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: 4 additions & 3 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=78484e87a0168e0f86d130bfae8f808d0d1a1e41
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 \
@@ -22,10 +20,13 @@ RUN apt update \
2220
&& rm -rf /app
2321

2422
FROM debian:bullseye-slim
23+
24+
ARG TARGETARCH
25+
2526
WORKDIR /app
2627

2728
COPY --from=node_builder /bin/adc /bin/adc
28-
COPY ./bin/apisix-ingress-controller .
29+
COPY ./bin/apisix-ingress-controller_${TARGETARCH} ./apisix-ingress-controller
2930
COPY ./config/samples/config.yaml ./conf/config.yaml
3031

3132
ENTRYPOINT ["/app/apisix-ingress-controller"]

Makefile

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
VERSION ?= 2.0.0
44

5-
65
IMAGE_TAG ?= dev
76

87
IMG ?= apache/apisix-ingress-controller:$(IMAGE_TAG)
98
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
109
ENVTEST_K8S_VERSION = 1.30.0
11-
1210
KIND_NAME ?= apisix-ingress-cluster
11+
1312
GATEAY_API_VERSION ?= v1.2.0
13+
ADC_VERSION ?= 0.19.0
1414

15-
TEST_TIMEOUT ?= 45m
15+
TEST_TIMEOUT ?= 60m
16+
TEST_DIR ?= ./test/e2e/apisix/
1617

1718
# CRD Reference Documentation
1819
CRD_REF_DOCS_VERSION ?= v0.1.0
@@ -104,6 +105,21 @@ test: manifests generate fmt vet envtest ## Run tests.
104105
.PHONY: kind-e2e-test
105106
kind-e2e-test: kind-up build-image kind-load-images e2e-test
106107

108+
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
109+
.PHONY: e2e-test
110+
e2e-test:
111+
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
112+
go test $(TEST_DIR) -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)"
113+
114+
.PHONY: conformance-test
115+
conformance-test:
116+
go test -v ./test/conformance -tags=conformance -timeout 60m
117+
118+
.PHONY: conformance-test-standalone
119+
conformance-test-standalone:
120+
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
121+
go test -v ./test/conformance/apisix -tags=conformance -timeout 60m
122+
107123
.PHONY: lint
108124
lint: sort-import golangci-lint ## Run golangci-lint linter
109125
$(GOLANGCI_LINT) run
@@ -164,11 +180,11 @@ build-multi-arch:
164180
.PHONY: build-multi-arch-image
165181
build-multi-arch-image: build-multi-arch
166182
# daemon.json: "features":{"containerd-snapshotter": true}
167-
@docker buildx build --load --platform linux/amd64,linux/arm64 -t $(IMG) .
183+
@docker buildx build --load --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
168184

169185
.PHONY: build-push-multi-arch-image
170186
build-push-multi-arch-image: build-multi-arch
171-
@docker buildx build --push --platform linux/amd64,linux/arm64 -t $(IMG) .
187+
@docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
172188

173189
.PHONY: run
174190
run: manifests generate fmt vet ## Run a controller from your host.
@@ -179,7 +195,12 @@ run: manifests generate fmt vet ## Run a controller from your host.
179195
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
180196
.PHONY: docker-build
181197
docker-build: set-e2e-goos build ## Build docker image with the manager.
182-
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile .
198+
@echo "Building with ADC_VERSION=$(ADC_VERSION)"
199+
@if [ "$(strip $(ADC_VERSION))" = "dev" ]; then \
200+
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile.dev . ; \
201+
else \
202+
$(CONTAINER_TOOL) build --build-arg ADC_VERSION=${ADC_VERSION} -t ${IMG} -f Dockerfile . ; \
203+
fi
183204

184205
.PHONY: docker-push
185206
docker-push: ## Push docker image with the manager.
@@ -255,7 +276,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
255276

256277
## Tool Versions
257278
KUSTOMIZE_VERSION ?= v5.4.2
258-
CONTROLLER_TOOLS_VERSION ?= v0.15.0
279+
CONTROLLER_TOOLS_VERSION ?= v0.17.2
259280
ENVTEST_VERSION ?= release-0.18
260281
GOLANGCI_LINT_VERSION ?= v2.1.5
261282

@@ -281,6 +302,10 @@ $(GOLANGCI_LINT): $(LOCALBIN)
281302

282303
gofmt: ## Apply go fmt
283304
@gofmt -w -r 'interface{} -> any' .
305+
@gofmt -w -r 'FIt -> It' test
306+
@gofmt -w -r 'FContext -> Context' test
307+
@gofmt -w -r 'FDescribe -> Describe' test
308+
@gofmt -w -r 'FDescribeTable -> DescribeTable' test
284309
@go fmt ./...
285310
.PHONY: gofmt
286311

PROJECT

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,57 @@ resources:
3434
kind: HTTPRoutePolicy
3535
path: github.com/apache/apisix-ingress-controller/api/v1alpha1
3636
version: v1alpha1
37+
- api:
38+
crdVersion: v1
39+
namespaced: true
40+
controller: true
41+
domain: github.com
42+
group: apisix.apache.org
43+
kind: ApisixRoute
44+
path: github.com/apache/apisix-ingress-controller/api/v2
45+
version: v2
46+
- api:
47+
crdVersion: v1
48+
namespaced: true
49+
controller: true
50+
domain: github.com
51+
group: apisix.apache.org
52+
kind: ApisixConsumer
53+
path: github.com/apache/apisix-ingress-controller/api/v2
54+
version: v2
55+
- api:
56+
crdVersion: v1
57+
namespaced: true
58+
controller: true
59+
domain: github.com
60+
group: apisix.apache.org
61+
kind: ApisixGlobalRule
62+
path: github.com/apache/apisix-ingress-controller/api/v2
63+
version: v2
64+
- api:
65+
crdVersion: v1
66+
namespaced: true
67+
controller: true
68+
domain: github.com
69+
group: apisix.apache.org
70+
kind: ApisixTls
71+
path: github.com/apache/apisix-ingress-controller/api/v2
72+
version: v2
73+
- api:
74+
crdVersion: v1
75+
namespaced: true
76+
controller: true
77+
domain: github.com
78+
group: apisix.apache.org
79+
kind: ApisixUpstream
80+
path: github.com/apache/apisix-ingress-controller/api/v2
81+
version: v2
82+
- api:
83+
crdVersion: v1
84+
namespaced: true
85+
domain: github.com
86+
group: apisix.apache.org
87+
kind: ApisixPluginConfig
88+
path: github.com/apache/apisix-ingress-controller/api/v2
89+
version: v2
3790
version: "3"

api/adc/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ func (g *GlobalRule) DeepCopy() GlobalRule {
103103
return GlobalRule(copied)
104104
}
105105

106+
// +k8s:deepcopy-gen=true
107+
type GlobalRuleItem struct {
108+
Metadata `json:",inline" yaml:",inline"`
109+
110+
Plugins Plugins `json:"plugins" yaml:"plugins"`
111+
}
112+
106113
type PluginMetadata Plugins
107114

108115
func (p *PluginMetadata) DeepCopy() PluginMetadata {

api/adc/zz_generated.deepcopy.go

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

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: 38 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)