Skip to content

Commit e82446e

Browse files
committed
fix: apisix deployer
Signed-off-by: ashing <[email protected]>
1 parent 15ed9cf commit e82446e

File tree

12 files changed

+385
-69
lines changed

12 files changed

+385
-69
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ e2e-test:
111111
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
112112
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test ./test/e2e/ -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)"
113113

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)"
118+
114119
.PHONY: download-api7ee3-chart
115120
download-api7ee3-chart:
116121
@helm repo add api7 https://charts.api7.ai || true

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ require (
187187
go.opentelemetry.io/otel/trace v1.28.0 // indirect
188188
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
189189
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
190-
go.uber.org/goleak v1.3.0 // indirect
191190
golang.org/x/arch v0.6.0 // indirect
192191
golang.org/x/crypto v0.26.0 // indirect
193192
golang.org/x/mod v0.20.0 // indirect
@@ -199,7 +198,6 @@ require (
199198
golang.org/x/time v0.5.0 // indirect
200199
golang.org/x/tools v0.24.0 // indirect
201200
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
202-
google.golang.org/appengine v1.6.7 // indirect
203201
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
204202
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
205203
google.golang.org/grpc v1.66.2 // indirect

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY=
251251
github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo=
252252
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM=
253253
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
254-
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
255254
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
256255
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
257256
github.com/gruntwork-io/go-commons v0.8.0 h1:k/yypwrPqSeYHevLlEDmvmgQzcyTwrlZGRaxEM6G0ro=
@@ -603,7 +602,6 @@ golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73r
603602
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
604603
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
605604
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
606-
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
607605
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
608606
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
609607
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -663,7 +661,6 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
663661
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
664662
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
665663
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
666-
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
667664
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
668665
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
669666
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
@@ -693,8 +690,6 @@ gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw
693690
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
694691
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
695692
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
696-
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
697-
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
698693
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
699694
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
700695
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=

test/conformance/suite_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ func TestMain(m *testing.M) {
155155

156156
f.DeployIngress(framework.IngressDeployOpts{
157157
ControllerName: "apisix.apache.org/apisix-ingress-controller",
158-
AdminKey: adminKey,
159-
AdminTLSVerify: false,
160158
Namespace: namespace,
161-
AdminEnpoint: framework.DashboardTLSEndpoint,
162159
StatusAddress: address,
163160
InitSyncDelay: 1 * time.Minute,
164161
})

test/e2e/apisix/basic.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
13+
package apisix
14+
15+
import (
16+
. "github.com/onsi/ginkgo/v2"
17+
. "github.com/onsi/gomega"
18+
19+
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
20+
)
21+
22+
var _ = Describe("APISIX Standalone Basic Tests", func() {
23+
s := scaffold.NewScaffold(&scaffold.Options{
24+
ControllerName: "apisix.apache.org/apisix-ingress-controller",
25+
})
26+
27+
Describe("APISIX HTTP Proxy", func() {
28+
It("should handle basic HTTP requests", func() {
29+
httpClient := s.NewAPISIXClient()
30+
Expect(httpClient).NotTo(BeNil())
31+
32+
// Test basic connectivity
33+
httpClient.GET("/anything").
34+
Expect().
35+
Status(404).Body().Contains("404 not found")
36+
})
37+
})
38+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package framework
2+
3+
import (
4+
_ "embed"
5+
"text/template"
6+
7+
"github.com/Masterminds/sprig/v3"
8+
)
9+
10+
var (
11+
//go:embed manifests/apisix-standalone.yaml
12+
apisixStandaloneTemplate string
13+
APISIXStandaloneTpl *template.Template
14+
)
15+
16+
func init() {
17+
tpl, err := template.New("apisix-standalone").Funcs(sprig.TxtFuncMap()).Parse(apisixStandaloneTemplate)
18+
if err != nil {
19+
panic(err)
20+
}
21+
APISIXStandaloneTpl = tpl
22+
}

test/e2e/framework/framework.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ func NewFramework() *Framework {
8585

8686
_framework = f
8787

88-
GinkgoWriter.Println("Another debug message")
89-
9088
return f
9189
}
9290

test/e2e/framework/ingress.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ func init() {
4040

4141
type IngressDeployOpts struct {
4242
ControllerName string
43-
AdminKey string
44-
AdminTLSVerify bool
4543
Namespace string
46-
AdminEnpoint string
4744
StatusAddress string
4845
Replicas int
4946
InitSyncDelay time.Duration
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: apisix-conf
5+
data:
6+
config.yaml: |
7+
apisix:
8+
enable_admin: true
9+
admin_key:
10+
- name: admin
11+
key: {{ .AdminKey }}
12+
role: admin
13+
ssl:
14+
enabled: true
15+
nginx_config:
16+
worker_processes: 2
17+
error_log_level: info
18+
deployment:
19+
role: traditional
20+
role_traditional:
21+
config_provider: yaml
22+
---
23+
apiVersion: apps/v1
24+
kind: Deployment
25+
metadata:
26+
name: apisix
27+
labels:
28+
app.kubernetes.io/name: apisix
29+
spec:
30+
replicas: 1
31+
selector:
32+
matchLabels:
33+
app.kubernetes.io/name: apisix
34+
template:
35+
metadata:
36+
labels:
37+
app.kubernetes.io/name: apisix
38+
spec:
39+
containers:
40+
- name: apisix
41+
image: apache/apisix:dev
42+
ports:
43+
- name: http
44+
containerPort: 9080
45+
protocol: TCP
46+
- name: https
47+
containerPort: 9443
48+
protocol: TCP
49+
- name: admin
50+
containerPort: 9180
51+
protocol: TCP
52+
volumeMounts:
53+
- name: conf
54+
mountPath: /usr/local/apisix/conf/config.yaml
55+
subPath: config.yaml
56+
volumes:
57+
- name: conf
58+
configMap:
59+
name: apisix-conf
60+
---
61+
apiVersion: v1
62+
kind: Service
63+
metadata:
64+
name: {{ .ServiceName }}
65+
labels:
66+
app.kubernetes.io/name: apisix
67+
spec:
68+
ports:
69+
- port: {{ .ServiceHTTPPort}}
70+
name: http
71+
protocol: TCP
72+
targetPort: 9080
73+
- port: {{ .ServiceHTTPSPort }}
74+
name: https
75+
protocol: TCP
76+
targetPort: 9443
77+
- port: 9180
78+
name: admin
79+
protocol: TCP
80+
targetPort: 9180
81+
selector:
82+
app.kubernetes.io/name: apisix
83+
type: {{ .ServiceType | default "NodePort" }}

test/e2e/scaffold/api7_deployer.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package scaffold
22

33
import (
4+
"context"
45
"fmt"
56
"os"
67
"time"
@@ -10,6 +11,7 @@ import (
1011
. "github.com/onsi/gomega" //nolint:staticcheck
1112
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1213

14+
"github.com/apache/apisix-ingress-controller/pkg/dashboard"
1315
"github.com/apache/apisix-ingress-controller/pkg/utils"
1416
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
1517
)
@@ -153,21 +155,43 @@ func (s *API7Deployer) newAPISIXTunnels() error {
153155
func (s *API7Deployer) DeployIngress() {
154156
s.Framework.DeployIngress(framework.IngressDeployOpts{
155157
ControllerName: s.opts.ControllerName,
156-
AdminKey: s.AdminKey(),
157-
AdminTLSVerify: false,
158158
Namespace: s.namespace,
159-
AdminEnpoint: framework.DashboardTLSEndpoint,
160159
Replicas: 1,
161160
})
162161
}
163162

164163
func (s *API7Deployer) ScaleIngress(replicas int) {
165164
s.Framework.DeployIngress(framework.IngressDeployOpts{
166165
ControllerName: s.opts.ControllerName,
167-
AdminKey: s.AdminKey(),
168-
AdminTLSVerify: false,
169166
Namespace: s.namespace,
170-
AdminEnpoint: framework.DashboardTLSEndpoint,
171167
Replicas: replicas,
172168
})
173169
}
170+
171+
func (s *API7Deployer) initDataPlaneClient() {
172+
var err error
173+
s.apisixCli, err = dashboard.NewClient()
174+
Expect(err).NotTo(HaveOccurred(), "creating apisix client")
175+
176+
url := fmt.Sprintf("http://%s/apisix/admin", s.GetDashboardEndpoint())
177+
178+
s.Logf("apisix admin: %s", url)
179+
180+
err = s.apisixCli.AddCluster(context.Background(), &dashboard.ClusterOptions{
181+
Name: "default",
182+
ControllerName: s.opts.ControllerName,
183+
Labels: map[string]string{"k8s/controller-name": s.opts.ControllerName},
184+
BaseURL: url,
185+
AdminKey: s.AdminKey(),
186+
})
187+
Expect(err).NotTo(HaveOccurred(), "adding cluster")
188+
189+
httpsURL := fmt.Sprintf("https://%s/apisix/admin", s.GetDashboardEndpointHTTPS())
190+
err = s.apisixCli.AddCluster(context.Background(), &dashboard.ClusterOptions{
191+
Name: "default-https",
192+
BaseURL: httpsURL,
193+
AdminKey: s.AdminKey(),
194+
SkipTLSVerify: true,
195+
})
196+
Expect(err).NotTo(HaveOccurred(), "adding cluster")
197+
}

0 commit comments

Comments
 (0)