apisix-ingress-controller
apisix-ingress-controller copied to clipboard
help request: how to define public-api in ApisixRoute CRD
Description
Here below is my yaml file of CRD ApisixRoute
I want to implement keyAuth
but some path will should be excluded to the keyAuth
But the config below didn't work.
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: status-tracker
namespace: launcher
spec:
http:
- name: status-tracker-rule
match:
hosts:
- api.xxx.cc
paths:
- /status-tracker*
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri:
- ^/status-tracker/(.*)
- /$1
- name: public-api
enable: true
config:
uri: /metrics
backends:
- serviceName: status-tracker
servicePort: 8000
authentication:
enable: true
type: keyAuth
keyAuth:
header: Authentication
Environment
apache/apisix:2.15.0-alpine apache/apisix-ingress-controller:1.4.1 docker.io/bitnami/etcd:3.5.4-debian-11-r14
Kubernetes cluster version: Client Version: v1.24.0 Kustomize Version: v4.5.4 Server Version: v1.21.12-gke.2200
you can refer to this one.
https://github.com/apache/apisix-ingress-controller/blob/cccad72a1e0ef60525c69371b4b27c4598c587c1/test/e2e/suite-features/global_rule.go#L44-L61
If you don't understand how public-api works, then you can go to APISIX documentation
Hey, the yaml above of mine is to explain:
I have a service proxy all /status/*
to the service
However, I just want to expose /status/metrics
to public without keyauth.
Can I finish this in one yaml config ?
I've tried to seperate this to two file
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: status-tracker
namespace: launcher
spec:
http:
- name: status-tracker-rule
match:
hosts:
- api.xxx.cc
paths:
- /status-tracker*
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri:
- ^/status-tracker/(.*)
- /$1
backends:
- serviceName: status-tracker
servicePort: 8000
authentication:
enable: true
type: keyAuth
keyAuth:
header: Authentication
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: status-tracker-public
namespace: launcher
spec:
http:
- name: status-tracker-public
match:
hosts:
- api.xxx.cc
paths:
- /status-tracker/metrics
plugins:
- name: proxy-rewrite
enable: true
config:
uri: /metrics
- name: public-api
enable: true
backends:
- serviceName: status-tracker
servicePort: 8000
authentication:
enable: false
But when I visit api.xxx.cc/status-tracker/metrics
It also responsed {"message":"Missing API key found in request"}
Sorry for delay.
Your scenario doesn't need to be done using public-api
This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.