规则

我们定义了一种资源,称为规则,用于描述 ALB 实例应如何处理第七层请求。

CRD

  spec:
    properties:
      backendProtocol:
        description: backendProtocol 定义后端服务器使用的协议,支持 https/http/grpc
        type: string
      certificate_name:
        description: certificate_name 定义在 https 前端规则中与指定主机名一起使用的证书
        type: string
      corsAllowHeaders:
        description: corsAllowHeaders 定义在 enableCORS 为 true 时允许的跨域请求头
        type: string
      corsAllowOrigin:
        description: corsAllowOrigin 定义在 enableCORS 为 true 时允许的跨域来源
        type: string
      description:
        type: string
      domain:
        type: string
      dsl:
        description: 用于在 UI 界面上进行搜索
        type: string
      dslx:
        description: dslx 定义匹配标准
        items:
          properties:
            key:
              type: string
            type:
              type: string
            values:
              items:
                items:
                  type: string
                type: array
              type: array
          type: object
        type: array
      enableCORS:
        description: enableCORS 是开启跨域请求的开关,当 EnableCORS 为 false 时,ALB2 将信息传输给后端服务器,由其决定是否允许跨域
        type: boolean
      priority:
        description: 优先级范围为 [1,10],如果多个规则匹配,值越小优先级越高
        type: integer
      rewrite_base:
        type: string
      rewrite_target:
        type: string
      serviceGroup:
        properties:
          services:
            items:
              properties:
                name:
                  type: string
                namespace:
                  type: string
                port:
                  type: integer
                weight:
                  type: integer
              type: object
            type: array
          session_affinity_attribute:
            type: string
          session_affinity_policy:
            type: string
        type: object
      source:
        description: source 表示前端或规则的来源。其类型可以是为服务注解创建的 "bind",并在规则被 Ingress 泛化时携带有关 ingress 的信息
        properties:
          name:
            type: string
          namespace:
            type: string
          type:
            type: string
        type: object
      type:
        description: type 已弃用
        type: string
      url:
        type: string
      vhost:
        description: vhost 允许用户覆盖请求 Host
        type: string
    type: object

dslx

dslx 是一种特定领域语言,用于描述匹配标准。

例如,以下规则匹配满足以下所有条件的请求:

  • URL 以 /app-a 或 /app-b 开头
  • 方法为 POST
  • URL 参数的 group 为 vip
  • 主机为 *.app.com
  • 头部的 location 为 east-1 或 east-2
  • 具有名为 uid 的 cookie
  • 源 IP 范围来自 1.1.1.1-1.1.1.100
  dslx:                                     
  - type: METHOD
    values:
    - - EQ
      - POST
  - type: URL
    values:
    - - STARTS_WITH
      - /app-a
    - - STARTS_WITH
      - /app-b
  - type: PARAM
    key: group
    values:
    - - EQ
      - vip
  - type: HOST 
    values:
    - - ENDS_WITH
      - .app.com
  - type: HEADER
    key: LOCATION 
    values:
    - - IN
      - east-1
      - east-2
  - type: COOKIE
    key: uid
    values:
    - - EXIST 
  - type: SRC_IP
    values:
    - - RANGE
      - "1.1.1.1"
      - "1.1.1.100"

配置

实际上,规则 .spec.config 包含更多字段。

本页概览