FAQ

This document describes FAQs when using OpenFunction.

Q: How to use private image repositories in OpenFunction?

A: OpenFunction uses Shipwright (which utilizes Tekton to integrate with Cloud Native Buildpacks) in the build phase to package the user function to the application image.

Users often choose to access a private image repository in an insecure way, which is not yet supported by the Cloud Native Buildpacks.

We offer a workaround as below to get around this limitation for now:

  1. Use IP address instead of hostname as access address for private image repository.
  2. You should skip tag-resolution when you run the Knative-runtime function.

For references:

buildpacks/lifecycle#524

buildpacks/tekton-integration#31

Q: How to access the Knative-runtime function without introducing a new ingress controller?

A: OpenFunction provides a unified entry point for function accessibility, which is based on the Ingress Nginx implementation. However, for some users, this is not necessary, and instead, introducing a new ingress controller may affect the current cluster.

In general, accessible addresses are for the sync(Knative-runtime) functions. Here are two ways to solve this problem:

  • Magic DNS

    You can follow this guide to config the DNS.

  • CoreDNS

    This is similar to using Magic DNS, with the difference that the configuration for DNS resolution is placed inside CoreDNS. Assume that the user has configured a domain named “openfunction.dev” in the ConfigMap config-domain under the knative-serving namespace (as shown below):

    1. $ kubectl -n knative-serving get cm config-domain -o yaml
    2. apiVersion: v1
    3. data:
    4. openfunction.dev: ""
    5. kind: ConfigMap
    6. metadata:
    7. annotations:
    8. knative.dev/example-checksum: 81552d0b
    9. labels:
    10. app.kubernetes.io/part-of: knative-serving
    11. app.kubernetes.io/version: 1.0.1
    12. serving.knative.dev/release: v1.0.1
    13. name: config-domain
    14. namespace: knative-serving

    Next, let’s add an A record for this domain. OpenFunction uses Kourier as the default network layer for Knative Serving, which is where the domain should flow to.

    1. $ kubectl -n kourier-system get svc
    2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    3. kourier LoadBalancer 10.233.7.202 <pending> 80:31655/TCP,443:30980/TCP 36m
    4. kourier-internal ClusterIP 10.233.47.71 <none> 80/TCP 36m

    Then the user only needs to configure this Wild-Card DNS resolution in CoreDNS to resolve the URL address of any Knative Service in the cluster.

    Where “10.233.47.71” is the address of the Service kourier-internal.

    1. $ kubectl -n kube-system get cm coredns -o yaml
    2. apiVersion: v1
    3. data:
    4. Corefile: |
    5. .:53 {
    6. errors
    7. health
    8. ready
    9. template IN A openfunction.dev {
    10. match .*\.openfunction\.dev
    11. answer "{{ .Name }} 60 IN A 10.233.47.71"
    12. fallthrough
    13. }
    14. kubernetes cluster.local in-addr.arpa ip6.arpa {
    15. pods insecure
    16. fallthrough in-addr.arpa ip6.arpa
    17. }
    18. hosts /etc/coredns/NodeHosts {
    19. ttl 60
    20. reload 15s
    21. fallthrough
    22. }
    23. prometheus :9153
    24. forward . /etc/resolv.conf
    25. cache 30
    26. loop
    27. reload
    28. loadbalance
    29. }
    30. ...

    If the user cannot resolve the URL address for this function outside the cluster, configure the hosts file as follows:

    Where “serving-sr5v2-ksvc-sbtgr.default.openfunction.dev” is the URL address obtained from the command “kubectl get ksvc”.

    1. 10.233.47.71 serving-sr5v2-ksvc-sbtgr.default.openfunction.dev

After the above configuration is done, you can get the URL address of the function with the following command. Then you can trigger the function via curl or your browser.

  1. $ kubectl get ksvc
  2. NAME URL
  3. serving-sr5v2-ksvc-sbtgr http://serving-sr5v2-ksvc-sbtgr.default.openfunction.dev

Q: How to enable and configure concurrency for functions?

A: OpenFunction categorizes function types into “sync runtime” and “async runtime” based on the type of request being handled. These two types of functions are driven by Knative Serving and Dapr + KEDA.

Therefore, to enable and configure the concurrency of functions, you need to refer to the specific implementation in the above components.

The following section describes how to enable and configure concurrency of functions in OpenFunction according to the “sync runtime” and “async runtime” sections.

Sync runtime

You can start by referring to this document in Knative Serving on enabling and configuring concurrency capabilities.

Knative Serving has Soft limit and Hard limit configurations for the concurrency feature.

Soft limit

You can refer to the Global(ConfigMap) and Global(Operator) sections of this document to configure global concurrency capabilities.

And for Per Revision you can configure it like this.

  1. apiVersion: core.openfunction.io/v1beta1
  2. kind: Function
  3. metadata:
  4. name: function-sample
  5. spec:
  6. serving:
  7. scaleOptions:
  8. knative:
  9. autoscaling:
  10. target: "200"

Hard limit

OpenFunction currently doesn’t support configuring Hard limit for Per Revision. You can refer to the Global(ConfigMap) and Global(Operator) sections of this document to configure global concurrency capabilities.

In summary

In a nutshell, you can configure Knative Serving’s Autoscaling-related configuration items for each function as follows, just as long as they can be passed in as Annotation, otherwise, you can only do global settings.

  1. # Configuration in Knative Serving
  2. apiVersion: serving.knative.dev/v1
  3. kind: Service
  4. metadata:
  5. name: helloworld-go
  6. namespace: default
  7. spec:
  8. template:
  9. metadata:
  10. annotations:
  11. autoscaling.knative.dev/<key>: "value"
  12. # Configuration in OpenFunction (recommended)
  13. apiVersion: core.openfunction.io/v1beta1
  14. kind: Function
  15. metadata:
  16. name: function-sample
  17. spec:
  18. serving:
  19. scaleOptions:
  20. knative:
  21. autoscaling:
  22. <key>: "value"
  23. # Alternative approach
  24. apiVersion: core.openfunction.io/v1beta1
  25. kind: Function
  26. metadata:
  27. name: function-sample
  28. spec:
  29. serving:
  30. annotations:
  31. autoscaling.knative.dev/<key>: "value"

Async runtime

You can start by referring to the document in Dapr on enabling and configuring concurrency capabilities.

Compared to the concurrency configuration of sync runtime, the concurrency configuration of async runtime is simpler.

  1. # Configuration in Dapr
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: nodesubscriber
  6. namespace: default
  7. spec:
  8. template:
  9. metadata:
  10. annotations:
  11. dapr.io/app-max-concurrency: "value"
  12. # Configuration in OpenFunction (recommended)
  13. apiVersion: core.openfunction.io/v1beta1
  14. kind: Function
  15. metadata:
  16. name: function-sample
  17. spec:
  18. serving:
  19. annotations:
  20. dapr.io/app-max-concurrency: "value"