跳到主要内容

Apisix Ingress

警告
  • 不建议使用
  • 依赖 etcd
    • etcd 难维护
    • helm 直接启动的 etcd 可能会有各种问题 - 可能导致无法启动
    • 没必要为了 apisix 专门去维护 etcd
    • etcd 非常吃 IO - IO 慢的时候 CPU 非常高
  • 建议尝试 kong - 使用现有的 DB 作为 backend

IngressController

  • ApisixRoute
  • ApisixUpstream
    • 名字与 service 名字相同会自动匹配
  • ApisixTls
  • ApisixClusterConfig
    • 配置 prometheus、skywalking
  • ApisixConsumer
  • ApisixPluginConfig
    • ingress 通过 annotation 引用 k8s.apisix.apache.org/plugin-config-name: "echo-and-cors-apc"
apiVersion: apisix.apache.org/v2beta3
kind: ApisixRoute
metadata:
name: httpbin-route
spec:
http:
- name: rule1
match:
hosts:
- httpbin.com
paths:
- /ip
backends:
- serviceName: httpbin-service-e2e-test
servicePort: 80
annotations:
k8s.apisix.apache.org/enable-cors: 'true'
k8s.apisix.apache.org/cors-allow-origin: 'https://foo.com,http://bar.com:8080'
k8s.apisix.apache.org/cors-allow-headers: 'Host: https://bar.com:8080'
k8s.apisix.apache.org/cors-allow-methods: 'GET,POST'
k8s.apisix.apache.org/allowlist-source-range: '10.0.5.0/16,127.0.0.1,192.168.3.98'
k8s.apisix.apache.org/blocklist-source-range: '127.0.0.1,172.17.0.0/16'
k8s.apisix.apache.org/http-allow-methods: 'GET,POST'
k8s.apisix.apache.org/http-block-method: 'PUT,DELETE'
k8s.apisix.apache.org/rewrite-target-regex: '/app/(.*)'
k8s.apisix.apache.org/rewrite-target-regex-template: '/$1'
k8s.apisix.apache.org/http-to-https: 'true'
k8s.apisix.apache.org/use-regex: 'true'
k8s.apisix.apache.org/enable-websocket: 'true'
k8s.apisix.apache.org/enable-response-rewrite: 'true'
k8s.apisix.apache.org/response-rewrite-status-code: '404'
k8s.apisix.apache.org/response-rewrite-body: 'bar-body'
k8s.apisix.apache.org/response-rewrite-body-base64: 'true'
# 可以通过 Prefix 路由
# path: /helloworld.Greeter/SayHello
k8s.apisix.apache.org/upstream-scheme: grpcs
# 跨 namespace 引用
k8s.apisix.apache.org/svc-namespace: test