Environment:
- AKS v1.25.6
- apisix helm deployed: https://artifacthub.io/packages/helm/apisix/apisix
- chart version: 2.1.0
- apisix-ingress-controller:1.6.0
- apisix:3.4.0
I were trying this configuration
apiVersion: v1
kind: Service
metadata:
name: chuck-norris-api-external-service
namespace: api-gateway
spec:
type: ExternalName
externalName: api.chucknorris.io
ports:
- port: 443
---
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
name: chuck-norris-api-upstream
namespace: api-gateway
spec:
externalNodes:
- name: chuck-norris-api-external-service
type: Service
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: chuck-norris-api-route
namespace: api-gateway
spec:
http:
- name: chuck-norris-api
match:
hosts:
- gateway.api-gateway.svc
- api.dev.dom
paths:
- /external/chucknorrisapi/*
upstreams:
- name: chuck-norris-api-upstream
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri:
- '^/external/chucknorrisapi/(.*)'
- '/jokes/$1'
The configuration is applied successfully but when requesting to: [GET] 'https://api.dev.dom/external/chucknorrisapi/random', I got a 500 Internal Server Error. In apisix pod logs it can be seen some ssl related problem:
2023/08/16 13:06:17 [error] 51#51: *1756996 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/init.lua:332: attempt to index local 'matched_ssl' (a nil value)
stack traceback:
coroutine 0:
/usr/local/apisix/apisix/init.lua: in function 'verify_https_client'
/usr/local/apisix/apisix/init.lua:560: in function 'http_access_phase'
access_by_lua(nginx.conf:408):2: in main chunk, client: 172.23.148.7, server: _, request: "GET /external/chucknorrisapi/random HTTP/1.1", host: "api.dev.dom:443"
I'm aware of kubernetes disclaimer: https://kubernetes.io/docs/concepts/services-networking/service/#externalname but i would need some help workaround it.
I'm also tried with no success to rewrite the host in the proxy-rewrite plugin, but I'm not able to override the upstream config with something like this, with the purpose of remove the ApisixUpstream and Service configuration:
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: chuck-norris-api-route
namespace: api-gateway
spec:
http:
- name: chuck-norris-api
match:
hosts:
- gateway.api-gateway.svc
- api.dev.dom
paths:
- /external/chucknorrisapi/*
upstreams:
nodes: {
"127.0.0.1:80": 1
}
type: "roundrobin"
plugins:
- name: proxy-rewrite
enable: true
config:
host: 'https://api.chucknorris.io'
regex_uri:
- '^/external/chucknorrisapi/(.*)'
- '/jokes/$1'
This config complains about the syntax of upstreams.
I'm open mind to any workaround, I just want to define an apisix route to an external-kubernetes api. Thank you all.