CRD specification

In order to control the behavior of the proxy (Apache APISIX), the following CRDs should be defined.

CRD Types

ApisixRoute

ApisixRoute corresponds to the Route object in Apache APISIX. The Route matches the client's request by defining rules, then loads and executes the corresponding plugin based on the matching result, and forwards the request to the specified Upstream. To learn more, please check the Apache APISIX architecture-design docs.

Structure example:

apiVersion: apisix.apache.org/v1
kind: ApisixRoute
metadata:
  name: httpserverRoute
  namespace: cloud
spec:
  rules:
  - host: test.apisix.apache.org
    http:
      paths:
      - backend:
          serviceName: httpserver
          servicePort: 8080
        path: /hello*
        plugins:
          - name: limit-count
            enable: true
            config:
              count: 2
              time_window: 60
              rejected_code: 503
              key: remote_addr
FieldTypeDescription
rulesarrayApisixRoute's request matching rules.
hoststringThe requested host.
httpobjectRoute rules are applied to the scope of layer 7 traffic.
pathsarrayPath-based route rule matching.
backendobjectBackend service information configuration.
serviceNamestringThe name of backend service. namespace + serviceName + servicePort form an unique identifier to match the back-end service.
servicePortintThe port of backend service. namespace + serviceName + servicePort form an unique identifier to match the back-end service.
pathstringThe URI matched by the route. Supports exact match and prefix match. Example,exact match: /hello, prefix match: /hello*.
pluginsarrayCustom plugin collection (Plugins defined in the route level). For more plugin information, please refer to the Apache APISIX plugin docs.
namestringThe name of the plugin. For more information about the example plugin, please check the limit-count docs.
enablebooleanWhether to enable the plugin, true: means enable, false: means disable.
configobjectConfiguration of plugin information. Note: The check of configuration schema is missing now, so please be careful when editing.

Support partial annotation

Structure example:

apiVersion: apisix.apache.org/v1
kind: ApisixRoute
metadata:
  annotations:
    k8s.apisix.apache.org/ingress.class: apisix_group
    k8s.apisix.apache.org/ssl-redirect: 'false'
    k8s.apisix.apache.org/whitelist-source-range:
      - 1.2.3.4/16
      - 4.3.2.1/8
  name: httpserverRoute
  namespace: cloud
spec:
FieldTypeDescription
k8s.apisix.apache.org/ssl-redirectbooleanWhether to force http redirect to https. ture: means to force conversion to https, false: means not to convert.
k8s.apisix.apache.org/ingress.classstringGrouping of ingress.
k8s.apisix.apache.org/whitelist-source-rangearrayWhitelist of IPs allowed to be accessed.

ApisixService

ApisixService corresponds to the Service object in Apache APISIX. A Service is an abstraction of an API (which can also be understood as a set of Route abstractions). It usually corresponds to the upstream service abstraction. Between Route and Service, usually the relationship of N:1. To learn more, please check the Apache APISIX architecture-design docs.

Structure example:

apiVersion: apisix.apache.org/v1
kind: ApisixService
metadata:
  name: httpserver
  namespace: cloud  
spec:
  upstream: httpserver
  port: 8080
  plugins:
    - name: limit-count
      enable: true
      config:
        count: 2
        time_window: 60
        rejected_code: 503
        key: remote_addr
FieldTypeDescription
upstreamstringThe name of the upstream service.
portintThe port number of the upstream service.
pluginsarrayCustom plugin collection (Plugins defined in the service level). For more plugin information, please refer to the Apache APISIX plugins docs.
namestringThe name of the plugin. For more information about the example plugin, please check the limit-count docs.
enablebooleanWhether to enable the plugin, true: means enable, false: means disable.
configobjectConfiguration of plugin information. Note: The check of configuration schema is missing now, so please be careful when editing.

ApisixUpstream

ApisixUpstream corresponds to the Upstream object in Apache APISIX. Upstream is a virtual host abstraction that performs load balancing on a given set of service nodes according to configuration rules. Upstream address information can be directly configured to Route (or Service). When Upstream has duplicates, you need to use “reference” to avoid duplication. To learn more, please check the Apache APISIX architecture-design docs.

Structure example:

apiVersion: apisix.apache.org/v1
kind: ApisixUpstream
metadata:
  name: httpserver
  namespace: cloud
spec:
  ports:
    - port: 8080
      loadbalancer: roundrobin
FieldTypeDescription
portsarrayCustom upstream collection.
portintUpstream service port number.
loadbalancerstring/objectThe load balance algorithm of this upstream service, optional value can be roundrobin or chash.

ApisixTls

ApisixTls corresponds to the SSL load matching route in Apache APISIX. To learn more, please check the Apache APISIX architecture-design docs.

Structure example:

apiVersion: apisix.apache.org/v1
kind: ApisixSSL
metadata:
  name: duiopen
spec:
  hosts:
  - asr.duiopen.com
  - tts.duiopen.com
  secret:
    name: all.duiopen.com
    namespace: cloud
FieldTypeDescription
hostsarrayThe domain list to identify which hosts (matched with SNI) can use the TLS certificate stored in the Secret.
secretobjectThe definition of the related Secret object with current ApisixTls object.
namestringThe name of secret, the secret contains key and cert for TLS.
namespacestringThe namespace of secret , the secret contains key and cert for TLS.

Back to top