一、Admin API 描述¶
Admin API 是一组用于配置 Apache APISIX 路由、上游、服务、SSL 证书等功能的 RESTful API。 你可以通过 Admin API 来获取、创建、更新以及删除资源。同时得益于 APISIX 的热加载能力,资源配置完成后 APISIX 将会自动更新配置,无需重启服务。
官方数据:https://apisix.apache.org/docs/apisix/admin-api/
二、Apisix 组件描述¶
| 概念/组件 | 描述 |
| ------------- | ------------------------------------------------------------ |
| Route | 创建、查询、更新、删除路由规则,定义请求如何映射到对应的上游服务,最后把请求转发给到指定的上游应用。 |
| Upstream | 上游的作用是按照配置规则对服务节点进行负载均衡,它的地址信息可以直接配置到路由或服务上。 |
| Service | 服务由路由中公共的插件配置、上游目标信息组合而成。服务与路由、上游关联,一个服务可对应一组上游节点、可被多条路由绑定。 |
| Consumer | 消费者是路由的消费方,形式包括开发者、最终用户、API 调用等。创建消费者时,需绑定至少一个认证类插件。 |
| Admin API | 用户可以通过 Admin API 控制 APISIX 实例。 |
三、Apisix路由Route¶
Route 也称之为路由,可以通过定义一些规则来匹配客户端的请求,然后根据匹配结果加载并执行相应 的插件,并把请求转发给到指定 Upstream(上游)。
所有的 Admin API 都采用 Restful 风格,路由资源请求地址为: /apisix/admin/routes/{id}? ttl=0 ,我们可以通过不同的 HTTP 方法来查询、新增、编辑或删除路由资源。
3.1 请求方法¶
| 名称 | 请求 URI | 请求 body | 描述 |
| -------- | -------------------------------- | :------------ | ------------------------------------------------------------ |
| GET | /apisix/admin/routes | 无 | 获取资源列表。 |
| GET | /apisix/admin/routes/{id} | 无 | 获取某个 id 的 routes 资源。 |
| PUT | /apisix/admin/routes/{id} | {...} | 根据 id 创建 routes 资源。 |
| POST | /apisix/admin/routes | {...} | id 将会自动生成。创建资源, |
| DELETE | /apisix/admin/routes/{id} | 无 | 删除指定 routes id 资源。 |
| PATCH | /apisix/admin/routes/{id} | {...} | 标准 PATCH,修改指定 Route 的部 分属性,其他不涉及的属性会原样保 留;如果你需要删除某个属性,可以 将该属性的值设置为 null ;当需要 修改属性的值为数组时,该属性将全量更新。 |
| PATCH | /apisix/admin/routes/{id}/{path} | {...} | SubPath PATCH,通过 {path} 指定Route 要更新的属性,全量更新 该属性的数据,其他不涉及的属性会 原样保留。 |
3.2 常规查询操作命令¶
1)首先,需要先获取当前集群中部署 APISIX 的 API-KEY ?
[root@master01 16]# kubectl get configmap apisix -ningress-apisix -oyaml
...
...
admin_key:
# admin: can everything for configuration data
- name: "admin"
key: <admin-api-key>
role: admin
# viewer: only can view configuration data
- name: "viewer"
key: <viewer-api-key>
role: viewer
...
...
2)如何操作基于Kubernetes 的 APISIX 的 Admin API ?
[root@master01 16]# kubectl get svc -ningress-apisix | grep apisix-admin
apisix-admin ClusterIP <apisix-admin-cluster-ip> <none> 9180/TCP 6h9m
3)将内部服务通过域名暴漏
[root@master01 16]# vim apisix-admin-ing.yaml
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: apisix-admin
namespace: ingress-apisix
spec:
http:
- name: root
match:
hosts:
- apisix-admin.example.com
paths:
- '/*'
backends:
- serviceName: apisix-admin
servicePort: 9180
# 应用
[root@master01 16]# kaf apisix-admin-ing.yaml
# 查看
[root@master01 16]# kg -f apisix-admin-ing.yaml
NAME HOSTS URIS AGE
apisix-admin ["apisix-admin.example.com"] ["/*"] 18s
4)测试验证
[root@master01 16]# ping apisix-admin.example.com
PING apisix-admin.example.com (<gateway-ip>) 56(84) bytes of data.
From <gateway-ip> (<gateway-ip>) icmp_seq=1 Destination Port Unreachable
From <gateway-ip> (<gateway-ip>) icmp_seq=2 Destination Port Unreachable
...
...
下面介绍一些常用的流程操作
转换json格式的网址:www.json.cn
1、查询service列表
curl http://apisix-admin.example.com/apisix/admin/services -H 'X-API-KEY: <admin-api-key>'
回显内容
{"total":0,"list":[]}
2、查询route列表
curl http://apisix-admin.example.com/apisix/admin/routes -H 'X-API-KEY: <admin-api-key>'
回显内容
{"total":5,"list":[{"key":"/apisix/routes/1936ab91","value":{"labels":{"managed-by":"apisix-ingress-controller"},"uris":["/apisix/prometheus/metrics"],"status":1,"priority":0,"create_time":1745150648,"upstream_id":"a5f6bfda","update_time":1745150648,"id":"1936ab91","hosts":["metrics.example.com"],"name":"ingress-apisix_metrics-route_metrics-route","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":149,"modifiedIndex":149},{"key":"/apisix/routes/50e6793a","value":{"labels":{"managed-by":"apisix-ingress-controller"},"uris":["/tls*","/v1*"],"status":1,"priority":0,"create_time":1745141909,"upstream_id":"2fdb2747","update_time":1745154011,"id":"50e6793a","hosts":["whoami.example.com"],"name":"default_whoami-apisix_whoami-root","plugins":{"proxy-rewrite":{"regex_uri":["^/v1(/|$)(.*)","/"],"use_real_request_uri_unsafe":false},"redirect":{"ret_code":302,"append_query_string":false,"regex_uri":["^(/tls)$","/"],"encode_uri":false},"basic-auth":{"hide_credentials":false}},"desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":68,"modifiedIndex":160},{"key":"/apisix/routes/51e11523","value":{"labels":{"managed-by":"apisix-ingress-controller"},"uris":["/*"],"status":1,"priority":0,"create_time":1745154778,"upstream_id":"ff9d87bf","update_time":1745154778,"id":"51e11523","hosts":["apisix-admin.example.com"],"name":"ingress-apisix_apisix-admin_root","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":162,"modifiedIndex":162},{"key":"/apisix/routes/bc3a78e6","value":{"labels":{"managed-by":"apisix-ingress-controller"},"uris":["/*"],"status":1,"priority":0,"create_time":1745133027,"upstream_id":"65e49f92","update_time":1745133027,"id":"bc3a78e6","hosts":["apisix.example.com"],"name":"ingress-apisix_dashboard_root","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":17,"modifiedIndex":17},{"key":"/apisix/routes/f5505b85","value":{"labels":{"managed-by":"apisix-ingress-controller"},"uris":["/httpbin*","/spec.json"],"status":1,"priority":0,"create_time":1745135568,"upstream_id":"5ce57b8e","update_time":1745151611,"id":"f5505b85","hosts":["httpbin.example.com"],"name":"default_default-route_httpbin-route","plugins":{"proxy-rewrite":{"regex_uri":["^/httpbin(/|$)(.*)","/"],"use_real_request_uri_unsafe":false}},"desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":19,"modifiedIndex":150}]}
3、查询upstream列表
curl http://apisix-admin.example.com/apisix/admin/upstreams -H 'X-API-KEY: <admin-api-key>'
回显内容
{"total":5,"list":[{"key":"/apisix/upstreams/2fdb2747","value":{"pass_host":"pass","labels":{"managed-by":"apisix-ingress-controller"},"create_time":1745141909,"type":"roundrobin","scheme":"http","update_time":1745141909,"id":"2fdb2747","nodes":[{"weight":100,"priority":0,"port":80,"host":"<whoami-pod-ip>"}],"name":"default_whoami_80","hash_on":"vars","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":67,"modifiedIndex":67},{"key":"/apisix/upstreams/5ce57b8e","value":{"pass_host":"pass","labels":{"managed-by":"apisix-ingress-controller"},"create_time":1745135568,"type":"roundrobin","scheme":"http","update_time":1745147331,"id":"5ce57b8e","nodes":[{"weight":100,"priority":0,"port":80,"host":"<httpbin-pod-ip>"}],"name":"default_httpbin_80","hash_on":"vars","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":18,"modifiedIndex":91},{"key":"/apisix/upstreams/65e49f92","value":{"pass_host":"pass","labels":{"managed-by":"apisix-ingress-controller"},"create_time":1745133027,"type":"roundrobin","scheme":"http","update_time":1745153386,"id":"65e49f92","nodes":[{"weight":100,"port":9000,"priority":0,"host":"<dashboard-pod-ip>"}],"name":"ingress-apisix_apisix-dashboard_80","hash_on":"vars","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":16,"modifiedIndex":159},{"key":"/apisix/upstreams/a5f6bfda","value":{"pass_host":"pass","labels":{"managed-by":"apisix-ingress-controller"},"create_time":1745150648,"type":"roundrobin","scheme":"http","update_time":1745150648,"id":"a5f6bfda","nodes":[{"weight":100,"port":9091,"priority":0,"host":"<apisix-pod-ip>"}],"name":"ingress-apisix_apisix-prometheus-metrics_9091","hash_on":"vars","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":148,"modifiedIndex":148},{"key":"/apisix/upstreams/ff9d87bf","value":{"pass_host":"pass","labels":{"managed-by":"apisix-ingress-controller"},"create_time":1745154778,"type":"roundrobin","scheme":"http","update_time":1745154778,"id":"ff9d87bf","nodes":[{"weight":100,"port":9180,"priority":0,"host":"<apisix-pod-ip>"}],"name":"ingress-apisix_apisix-admin_9180","hash_on":"vars","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":161,"modifiedIndex":161}]}
4、查询consumer列表
curl http://apisix-admin.example.com/apisix/admin/consumers -H 'X-API-KEY: <admin-api-key>'
回显内容
{"total":1,"list":[{"key":"/apisix/consumers/default_whoamibauth","value":{"labels":{"managed-by":"apisix-ingress-controller"},"update_time":1745141330,"create_time":1745141330,"plugins":{"basic-auth":{"username":"admin","password":"<basic-auth-password>"}},"username":"default_whoamibauth","desc":"Created by apisix-ingress-controller, DO NOT modify it manually"},"createdIndex":57,"modifiedIndex":57}]}
四、创建路由Route及上游Upstream¶
环境准备
# 定义资源
[root@master01 16]#
cat > httpbin-dp-svc.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
labels:
app: httpbin
name: httpbin
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: httpbin
template:
metadata:
labels:
app: httpbin
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/abroad_images/httpbin:latest
imagePullPolicy: Always
name: httpbin
dnsPolicy: ClusterFirst
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
labels:
app: httpbin
name: httpbin
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: httpbin
sessionAffinity: None
type: ClusterIP
EOF
# 定义资源
[root@master01 16]#
cat > httpbin-ing.yaml <<EOF
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: default-route
namespace: default
spec:
http:
- backends:
- serviceName: httpbin
servicePort: 80
match:
hosts:
- httpbin.example.com
paths:
- /httpbin*
- /spec.json
name: httpbin-route
plugins:
- config:
regex_uri:
- ^/httpbin(/|$)(.*)
- /
enable: true
name: proxy-rewrite
EOF
# 应用
[root@master01 16]# kubectl apply -f httpbin-dp-svc.yaml
[root@master01 16]# kubectl apply -f httpbin-ing.yaml
# 删除之前创建名为default-route的ar
[root@master01 16]# k delete ar default-route
1、仍然使用上节课实验中的 httpbin 服务,查看 httpbin 服务的 svc。从输出中获取 Service 的 IP、端口、标签等信息,以便在创建路由时使用。
# 查看svc
[root@master01 16]# kubectl get svc | grep httpbin
httpbin ClusterIP <httpbin-service-ip> <none> 80/TCP 5h16m
# 以json格式导出名为httpbin的svc
[root@master01 16]# kubectl get svc httpbin -o json
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"app\":\"httpbin\"},\"name\":\"httpbin\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"port\":80,\"protocol\":\"TCP\",\"targetPort\":80}],\"selector\":{\"app\":\"httpbin\"},\"sessionAffinity\":\"None\",\"type\":\"ClusterIP\"}}\n"
},
"creationTimestamp": "2025-04-20T08:05:55Z",
"labels": {
"app": "httpbin"
},
"name": "httpbin",
"namespace": "default",
"resourceVersion": "1724022",
"uid": "6951bdd8-7ce7-4766-a101-0f761d82c206"
},
"spec": {
"clusterIP": "<httpbin-service-ip>",
"clusterIPs": [
"<httpbin-service-ip>"
],
"internalTrafficPolicy": "Cluster",
"ipFamilies": [
"IPv4"
],
"ipFamilyPolicy": "SingleStack",
"ports": [
{
"port": 80,
"protocol": "TCP",
"targetPort": 80
}
],
"selector": {
"app": "httpbin"
},
"sessionAffinity": "None",
"type": "ClusterIP"
},
"status": {
"loadBalancer": {}
}
}
2、直接创建包含 upstream 的 Route
curl -X POST http://apisix-admin.example.com/apisix/admin/routes \
-H 'X-API-KEY: <admin-api-key>' \
-H 'Content-Type: application/json' \
-d '{
"hosts": ["httpbin.example.com"],
"uri": "/*",
"methods": ["GET"],
"plugins": {
},
"labels": {
"managed-by": "apisix-ingress-controller"
},
"upstream": {
"type": "roundrobin",
"nodes": [
{
"host": "<httpbin-service-ip>",
"port": 80,
"weight": 1
}
]
}
}'
回显内容
{"key":"/apisix/routes/00000000000000000165","value":{"labels":{"managed-by":"apisix-ingress-controller"},"upstream":{"pass_host":"pass","nodes":[{"weight":1,"port":80,"host":"<httpbin-service-ip>","priority":0}],"scheme":"http","hash_on":"vars","type":"roundrobin"},"status":1,"priority":0,"create_time":1745155616,"uri":"/*","update_time":1745155616,"methods":["GET"],"hosts":["httpbin.example.com"],"plugins":{},"id":"00000000000000000165"}}
3、访问验证
[root@master01 16]# curl httpbin.example.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>httpbin.org</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700"
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/flasgger_static/swagger-ui.css">
<link rel="icon" type="image/png" href="/static/favicon.ico" sizes="64x64 32x32 16x16" />
...
...
4、小结
其实如上做法是不符合 APISIX 定义的,不建议直接通过 APISIX Admin API 创建,之所以通过这种方式的目的是让大家熟悉下 APISIX 的接口魅力!
通常建议使用 Ingress 资源和 apisix-ingress-controller 以充分利用Kubernetes 原生的管理和扩展能力。
五、创建路由Route及消费者Consumer¶
1、创建基于 key-auth 插件的认证 consumer
[root@master01 16]#
curl http://apisix-admin.example.com/apisix/admin/consumers \
-H 'X-API-KEY: <admin-api-key>' \
-X PUT \
-d '{
"username": "zhdya",
"plugins": {
"key-auth": {
"key": "<consumer-key>"
}
}
}'
回显内容
{"key":"/apisix/consumers/zhdya","value":{"create_time":1745155889,"plugins":{"key-auth":{"key":"<consumer-key>"}},"update_time":1745155889,"username":"zhdya"}}
2、绑定 Consumer 与 Route
[root@master01 16]#
curl -X POST http://apisix-admin.example.com/apisix/admin/routes \
-H 'X-API-KEY: <admin-api-key>' \
-H 'Content-Type: application/json' \
-d '{
"hosts": ["httpbin.example.com"],
"uri": "/*",
"methods": ["GET"],
"plugins": {
"key-auth": {
"username": "zhdya",
"key": "<consumer-key>"
}
},
"labels": {
"managed-by": "apisix-ingress-controller"
},
"upstream": {
"type": "roundrobin",
"nodes": [
{
"host": "<httpbin-service-ip>",
"port": 80,
"weight": 1
}
]
}
}'
回显内容
{"key":"/apisix/routes/00000000000000000169","value":{"labels":{"managed-by":"apisix-ingress-controller"},"upstream":{"pass_host":"pass","nodes":[{"weight":1,"port":80,"host":"<httpbin-service-ip>","priority":0}],"scheme":"http","hash_on":"vars","type":"roundrobin"},"status":1,"priority":0,"create_time":1745155960,"uri":"/*","update_time":1745155960,"methods":["GET"],"hosts":["httpbin.example.com"],"plugins":{"key-auth":{"query":"apikey","header":"apikey","key":"<consumer-key>","hide_credentials":false,"username":"zhdya"}},"id":"00000000000000000169"}}
六、删除操作¶
1)查询
查询 APISIX 所有路由配置(核心请求转发规则)
[root@master01 16]#
curl http://apisix-admin.example.com/apisix/admin/routes -H 'X-API-KEY: <admin-api-key>'
# 回显内容
{
"total": 6,
"list": [
{
"key": "/apisix/routes/00000000000000000165",
"value": {
"labels": {
"managed-by": "apisix-ingress-controller"
},
"upstream": {
"pass_host": "pass",
"nodes": [
{
"weight": 1,
"port": 80,
"priority": 0,
"host": "<httpbin-service-ip>"
}
],
"scheme": "http",
"hash_on": "vars",
"type": "roundrobin"
},
"status": 1,
"priority": 0,
"create_time": 1745155616,
"uri": "/*",
"update_time": 1745155616,
"methods": [
"GET"
],
"hosts": [
"httpbin.example.com"
],
"plugins": {
},
"id": "00000000000000000165"
},
"createdIndex": 166,
"modifiedIndex": 166
},
{
"key": "/apisix/routes/00000000000000000169",
"value": {
"labels": {
"managed-by": "apisix-ingress-controller"
},
"upstream": {
"pass_host": "pass",
"nodes": [
{
"weight": 1,
"port": 80,
"priority": 0,
"host": "<httpbin-service-ip>"
}
],
"scheme": "http",
"hash_on": "vars",
"type": "roundrobin"
},
"status": 1,
"priority": 0,
"create_time": 1745155960,
"uri": "/*",
"update_time": 1745155960,
"methods": [
"GET"
],
"hosts": [
"httpbin.example.com"
],
"plugins": {
"key-auth": {
"query": "apikey",
"header": "apikey",
"hide_credentials": false,
"key": "<consumer-key>",
"username": "zhdya"
}
},
"id": "00000000000000000169"
},
"createdIndex": 170,
"modifiedIndex": 170
},
{
"key": "/apisix/routes/1936ab91",
"value": {
"labels": {
"managed-by": "apisix-ingress-controller"
},
"uris": [
"/apisix/prometheus/metrics"
],
"status": 1,
"priority": 0,
"create_time": 1745150648,
"upstream_id": "a5f6bfda",
"update_time": 1745150648,
"id": "1936ab91",
"hosts": [
"metrics.example.com"
],
"name": "ingress-apisix_metrics-route_metrics-route",
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 149,
"modifiedIndex": 149
},
{
"key": "/apisix/routes/50e6793a",
"value": {
"labels": {
"managed-by": "apisix-ingress-controller"
},
"uris": [
"/tls*",
"/v1*"
],
"status": 1,
"priority": 0,
"create_time": 1745141909,
"upstream_id": "2fdb2747",
"update_time": 1745154011,
"id": "50e6793a",
"hosts": [
"whoami.example.com"
],
"name": "default_whoami-apisix_whoami-root",
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"^/v1(/|$)(.*)",
"/"
],
"use_real_request_uri_unsafe": false
},
"redirect": {
"ret_code": 302,
"append_query_string": false,
"regex_uri": [
"^(/tls)$",
"/"
],
"encode_uri": false
},
"basic-auth": {
"hide_credentials": false
}
},
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 68,
"modifiedIndex": 160
},
{
"key": "/apisix/routes/51e11523",
"value": {
"labels": {
"managed-by": "apisix-ingress-controller"
},
"uris": [
"/*"
],
"status": 1,
"priority": 0,
"create_time": 1745154778,
"upstream_id": "ff9d87bf",
"update_time": 1745154778,
"id": "51e11523",
"hosts": [
"apisix-admin.example.com"
],
"name": "ingress-apisix_apisix-admin_root",
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 162,
"modifiedIndex": 162
},
{
"key": "/apisix/routes/bc3a78e6",
"value": {
"labels": {
"managed-by": "apisix-ingress-controller"
},
"uris": [
"/*"
],
"status": 1,
"priority": 0,
"create_time": 1745133027,
"upstream_id": "65e49f92",
"update_time": 1745133027,
"id": "bc3a78e6",
"hosts": [
"apisix.example.com"
],
"name": "ingress-apisix_dashboard_root",
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 17,
"modifiedIndex": 17
}
]
}
查询 APISIX 所有上游配置(后端服务节点池)
[root@master01 16]#
curl http://apisix-admin.example.com/apisix/admin/upstreams -H 'X-API-KEY: <admin-api-key>'
# 回显内容
{
"total": 4,
"list": [
{
"key": "/apisix/upstreams/2fdb2747",
"value": {
"pass_host": "pass",
"labels": {
"managed-by": "apisix-ingress-controller"
},
"create_time": 1745141909,
"type": "roundrobin",
"scheme": "http",
"update_time": 1745141909,
"id": "2fdb2747",
"nodes": [
{
"weight": 100,
"priority": 0,
"port": 80,
"host": "<whoami-pod-ip>"
}
],
"name": "default_whoami_80",
"hash_on": "vars",
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 67,
"modifiedIndex": 67
},
{
"key": "/apisix/upstreams/65e49f92",
"value": {
"pass_host": "pass",
"labels": {
"managed-by": "apisix-ingress-controller"
},
"create_time": 1745133027,
"type": "roundrobin",
"scheme": "http",
"update_time": 1745155811,
"id": "65e49f92",
"nodes": [
{
"weight": 100,
"port": 9000,
"priority": 0,
"host": "<dashboard-pod-ip>"
}
],
"name": "ingress-apisix_apisix-dashboard_80",
"hash_on": "vars",
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 16,
"modifiedIndex": 167
},
{
"key": "/apisix/upstreams/a5f6bfda",
"value": {
"pass_host": "pass",
"labels": {
"managed-by": "apisix-ingress-controller"
},
"create_time": 1745150648,
"type": "roundrobin",
"scheme": "http",
"update_time": 1745150648,
"id": "a5f6bfda",
"nodes": [
{
"weight": 100,
"port": 9091,
"priority": 0,
"host": "<apisix-pod-ip>"
}
],
"name": "ingress-apisix_apisix-prometheus-metrics_9091",
"hash_on": "vars",
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 148,
"modifiedIndex": 148
},
{
"key": "/apisix/upstreams/ff9d87bf",
"value": {
"pass_host": "pass",
"labels": {
"managed-by": "apisix-ingress-controller"
},
"create_time": 1745154778,
"type": "roundrobin",
"scheme": "http",
"update_time": 1745154778,
"id": "ff9d87bf",
"nodes": [
{
"weight": 100,
"port": 9180,
"priority": 0,
"host": "<apisix-pod-ip>"
}
],
"name": "ingress-apisix_apisix-admin_9180",
"hash_on": "vars",
"desc": "Created by apisix-ingress-controller, DO NOT modify it manually"
},
"createdIndex": 161,
"modifiedIndex": 161
}
]
}
2)删除 Route 和 upstream
通过 route_id 进行删除
[root@master01 16]# curl -X DELETE http://apisix-admin.example.com/apisix/admin/routes/00000000000000000165 -H 'X-API-KEY: <admin-api-key>'
# 回显内容
{"key":"/apisix/routes/00000000000000000165","deleted":"1"}
通过 upstream_id 进行删除
[root@master01 16]# curl -X DELETE http://apisix-admin.example.com/apisix/admin/upstreams/5ce57b8e -H 'X-API-KEY: <admin-api-key>'
# 回显内容
{"key":"/apisix/upstreams/5ce57b8e","deleted":"1"}