OpenFunction Gateway

Inside OpenFunction Gateway

Backed by the Kubernetes Gateway, an OpenFunction Gateway defines how users can access sync functions.

Whenever an OpenFunction Gateway is created, the gateway controller will:

  • Add a default listener named ofn-http-internal to gatewaySpec.listeners if there isn’t one there.

  • Generate gatewaySpec.listeners.[*].hostname based on domain or clusterDomain.

  • Inject gatewaySpec.listenters to the existing Kubernetes Gateway defined by the gatewayRef of the OpenFunction Gateway.

  • Create an new Kubernetes Gateway based on the gatewaySpec.listenters field in gatewayDef of the OpenFunction Gateway.

  • Create a service named gateway.openfunction.svc.cluster.local that defines a unified entry for sync functions.

After an OpenFunction Gateway is deployed, you’ll be able to find the status of Kubernetes Gateway and its listeners in OpenFunction Gateway status:

  1. status:
  2. conditions:
  3. - lastTransitionTime: "2022-08-04T10:20:57Z"
  4. message: Gateway is scheduled
  5. observedGeneration: 2
  6. reason: Scheduled
  7. status: "True"
  8. type: Scheduled
  9. - lastTransitionTime: "2022-08-04T10:20:57Z"
  10. message: Valid Gateway
  11. observedGeneration: 2
  12. reason: Valid
  13. status: "True"
  14. type: Ready
  15. listeners:
  16. - attachedRoutes: 0
  17. conditions:
  18. - lastTransitionTime: "2022-08-04T10:20:57Z"
  19. message: Valid listener
  20. observedGeneration: 2
  21. reason: Ready
  22. status: "True"
  23. type: Ready
  24. name: ofn-http-internal
  25. supportedKinds:
  26. - group: gateway.networking.k8s.io
  27. kind: HTTPRoute
  28. - attachedRoutes: 0
  29. conditions:
  30. - lastTransitionTime: "2022-08-04T10:20:57Z"
  31. message: Valid listener
  32. observedGeneration: 2
  33. reason: Ready
  34. status: "True"
  35. type: Ready
  36. name: ofn-http-external
  37. supportedKinds:
  38. - group: gateway.networking.k8s.io
  39. kind: HTTPRoute

The Default OpenFunction Gateway

OpenFunction Gateway uses Contour as the default Kubernetes Gateway implementation. The following OpenFunction Gateway will be created automatically once you install OpenFunction:

  1. apiVersion: networking.openfunction.io/v1alpha1
  2. kind: Gateway
  3. metadata:
  4. name: openfunction
  5. namespace: openfunction
  6. spec:
  7. domain: ofn.io
  8. clusterDomain: cluster.local
  9. hostTemplate: "{{.Name}}.{{.Namespace}}.{{.Domain}}"
  10. pathTemplate: "{{.Namespace}}/{{.Name}}"
  11. httpRouteLabelKey: "app.kubernetes.io/managed-by"
  12. gatewayRef:
  13. name: contour
  14. namespace: projectcontour
  15. gatewaySpec:
  16. listeners:
  17. - name: ofn-http-internal
  18. hostname: "*.cluster.local"
  19. protocol: HTTP
  20. port: 80
  21. allowedRoutes:
  22. namespaces:
  23. from: All
  24. - name: ofn-http-external
  25. hostname: "*.ofn.io"
  26. protocol: HTTP
  27. port: 80
  28. allowedRoutes:
  29. namespaces:
  30. from: All

You can customize the default OpenFunction Gateway like below:

  1. kubectl edit gateway openfunction -n openfunction

Switch to a different Kubernetes Gateway

You can switch to any gateway implementations that support Kubernetes Gateway API such as Contour, Istio, Apache APISIX, Envoy Gateway (in the future) and more in an easier and vendor-neutral way.

Here you can find more details.

Multiple OpenFunction Gateway

Multiple Gateway are meaningless for OpenFunction, we currently only support one OpenFunction Gateway.