Skip to content

Commit 1774afb

Browse files
committed
fix: r
Signed-off-by: ashing <[email protected]>
1 parent 63075e1 commit 1774afb

File tree

5 files changed

+109
-14
lines changed

5 files changed

+109
-14
lines changed

api/v1alpha1/gatewayproxy_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ type ControlPlaneProvider struct {
113113
// +kubebuilder:validation:MinItems=1
114114
Endpoints []string `json:"endpoints"`
115115

116+
// TlsVerify specifies whether to verify the TLS certificate of the control plane
117+
// +optional
118+
TlsVerify *bool `json:"tlsVerify,omitempty"`
119+
116120
// Auth specifies the authentication configuration
117121
// +kubebuilder:validation:Required
118122
Auth ControlPlaneAuth `json:"auth"`

config/samples/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
log_level: "info" # The log level of the API7 Ingress Controller.
1+
log_level: "debug" # The log level of the API7 Ingress Controller.
22
# the default value is "info".
33

44
controller_name: gateway.api7.io/api7-ingress-controller # The controller name of the API7 Ingress Controller,
@@ -12,9 +12,9 @@ ingress_status_address: [] # The status address of the ingress.
1212
gateway_configs: # The configuration of the API7 Gateway.
1313
- name: api7 # The name of the Gateway in the Gateway API.
1414
control_plane:
15-
admin_key: "${ADMIN_KEY}" # The admin key of the control plane.
15+
admin_key: "a7adm-qqEncKkktQFWrSdF8bGpDzjcRDbVFYgRXSBSPCzpVZZkc7pags-70be7645fdf94c3c8e4d656c2334bd8b" # The admin key of the control plane.
1616
endpoints:
17-
- ${ENDPOINT} # The endpoint of the control plane.
17+
- https://172.18.0.6:7443 # The endpoint of the control plane.
1818
tls_verify: false
1919
addresses: # record the status address of the gateway-api gateway
2020
- "172.18.0.4" # The LB IP of the gateway service.

internal/controller/ingress_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ func (r *IngressReconciler) processBackendService(ctx context.Context, tctx *pro
461461
func (r *IngressReconciler) updateStatus(ctx context.Context, ingress *networkingv1.Ingress) error {
462462
var loadBalancerStatus networkingv1.IngressLoadBalancerStatus
463463

464+
// todo: remove using default config, use the StatusAddress And PublishService in the gateway proxy
465+
464466
// 1. use the IngressStatusAddress in the config
465467
statusAddresses := config.GetIngressStatusAddress()
466468
if len(statusAddresses) > 0 {

internal/provider/adc/adc.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,22 @@ func (d *adcClient) sync(task Task) error {
270270
args = append(args, "--include-resource-type", t)
271271
}
272272

273-
// todo: use adc config
274-
// for _, config := range task.configs {
275-
// if err := d.execADC(config, args); err != nil {
276-
// return err
277-
// }
278-
// }
279-
if err := d.execADC(adcConfig{
280-
ServerAddr: d.ServerAddr,
281-
Token: d.Token,
282-
}, args); err != nil {
283-
return err
273+
if len(task.configs) > 0 {
274+
log.Debugw("syncing resources with multiple configs", zap.Any("configs", task.configs))
275+
for _, config := range task.configs {
276+
if err := d.execADC(config, args); err != nil {
277+
return err
278+
}
279+
}
280+
} else {
281+
// todo: remove using default config
282+
log.Debugw("syncing resources with default config")
283+
if err := d.execADC(adcConfig{
284+
ServerAddr: d.ServerAddr,
285+
Token: d.Token,
286+
}, args); err != nil {
287+
return err
288+
}
284289
}
285290

286291
return nil

test/e2e/ingress/ingress.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,88 @@ spec:
188188
Status(200)
189189
})
190190
})
191+
192+
Context("IngressClass with GatewayProxy", func() {
193+
gatewayProxyYaml := `
194+
apiVersion: gateway.apisix.io/v1alpha1
195+
kind: GatewayProxy
196+
metadata:
197+
name: api7-proxy-config
198+
namespace: default
199+
spec:
200+
provider:
201+
type: ControlPlane
202+
controlPlane:
203+
endpoints:
204+
- %s
205+
auth:
206+
type: AdminKey
207+
adminKey:
208+
value: "%s"
209+
`
210+
211+
var ingressClassWithProxy = `
212+
apiVersion: networking.k8s.io/v1
213+
kind: IngressClass
214+
metadata:
215+
name: api7-with-proxy
216+
annotations:
217+
ingressclass.kubernetes.io/is-default-class: "true"
218+
spec:
219+
controller: "gateway.api7.io/api7-ingress-controller"
220+
parameters:
221+
apiGroup: "gateway.apisix.io"
222+
kind: "GatewayProxy"
223+
name: "api7-proxy-config"
224+
namespace: "default"
225+
scope: "Namespace"
226+
`
227+
228+
var testIngress = `
229+
apiVersion: networking.k8s.io/v1
230+
kind: Ingress
231+
metadata:
232+
name: api7-ingress-with-proxy
233+
spec:
234+
ingressClassName: api7-with-proxy
235+
rules:
236+
- host: proxy.example.com
237+
http:
238+
paths:
239+
- path: /
240+
pathType: Prefix
241+
backend:
242+
service:
243+
name: httpbin-service-e2e-test
244+
port:
245+
number: 80
246+
`
247+
248+
It("Test IngressClass with GatewayProxy", func() {
249+
By("create GatewayProxy")
250+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
251+
252+
By("create GatewayProxy")
253+
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
254+
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
255+
time.Sleep(5 * time.Second)
256+
257+
By("create IngressClass with GatewayProxy reference")
258+
err = s.CreateResourceFromStringWithNamespace(ingressClassWithProxy, "")
259+
Expect(err).NotTo(HaveOccurred(), "creating IngressClass with GatewayProxy")
260+
time.Sleep(5 * time.Second)
261+
262+
By("create Ingress with GatewayProxy IngressClass")
263+
err = s.CreateResourceFromString(testIngress)
264+
Expect(err).NotTo(HaveOccurred(), "creating Ingress with GatewayProxy IngressClass")
265+
time.Sleep(5 * time.Second)
266+
267+
By("verify HTTP request")
268+
s.NewAPISIXClient().
269+
GET("/get").
270+
WithHost("proxy.example.com").
271+
Expect().
272+
Status(200)
273+
})
274+
})
191275
})

0 commit comments

Comments
 (0)