Gateway API is dedicated to achieving expressive and scalable Kubernetes service networking through many custom resources.
Apache APISIX Ingress controller can realize richer functions by adding support for Gateway API, including Gateway management, multi-cluster support and other features.
Add support from the definition of HTTP routing. Mainly cover the following resources:
We need to add a separate switch for the Gateway API to control whether to enable this feature, and add corresponding controllers for various resources.
pkg/ingress/gateway_class.go
pkg/ingress/gateway.go
pkg/ingress/http_route.go
These controllers can handle gateway.networking.k8s.io/v1alpha2
version of GatewayClass
, Gateway
and HTTPRoute
resources.
For real traffic definition rules, it needs to be translated into rules in Apache APISIX.
For GatewayClass
resources, we need to have a unique identifier. We can define controllerName = apisix.apache.org/gateway-controller
in the code.
apiVersion: gateway.networking.k8s.io/v1alpha2 kind: GatewayClass metadata: name: apisix-lb spec: controllerName: apisix.apache.org/gateway-controller
After the creation is successful, you will see the following results.
➜ ~ kubectl get gatewayclass NAME CONTROLLER AGE apisix-lb apisix.apache.org/gateway-controller 7m
We need to update its Status.
For the Gateway
resource, we have two stages:
apiVersion: gateway.networking.k8s.io/v1alpha2 kind: Gateway metadata: name: my-gateway spec: gatewayClassName: apisix-lb listeners: - name: http protocol: HTTP port: 80
After correct processing, you will get the following results:
➜ ~ kubectl get gateway NAME CLASS ADDRESS READY AGE my-gateway apisix-lb 6.6.6.6 True 12m
For the HTTPRoute
resource, we need to complete its translation to APISIX.
apiVersion: gateway.networking.k8s.io/v1alpha2 kind: HTTPRoute metadata: name: http-app-1 spec: parentRefs: - name: my-gateway hostnames: - "foo.com" rules: - matches: - path: type: PathPrefix value: /bar backendRefs: - name: my-service1 port: 8080 - matches: - headers: - type: Exact name: magic value: foo queryParams: - type: Exact name: great value: example path: type: PathPrefix value: /some/thing method: GET backendRefs: - name: my-service2 port: 8080
Need to create the corresponding route on Apache APISIX.
TBD
TBD
TBD
TBD