CI/CD

Overview

Previously users can use OpenFunction to build function or application source code into container images and then deploy the built image directly to the underlying sync/async Serverless runtime without user intervention.

But OpenFunction can neither rebuild the image and then redeploy it whenever the function or application source code changes nor redeploy the image whenever this image changes (When the image is built and pushed manually or in another function)

Starting from v1.0.0, OpenFunction adds the ability to detect source code or image changes and then rebuilt and/or redeploy the new built image in a new component called Revision Controller. The Revision Controller is able to:

  • Detect source code changes in github, gitlab or gitee, then rebuild and redeploy the new built image whenever the source code changes.
  • Detect the bundle container image (image containing the source code) changes, then rebuild and redeploy the new built image whenever the bundle image changes.
  • Detect the function or application image changes, then redeploy the new image whenever the function or application image changes.

Quick start

Install Revision Controller

You can enable Revision Controller when installing OpenFunction by simply adding the following flag to the helm command.

  1. --set revisionController.enable=true

You can also enable Revision Controller after OpenFunction is installed:

  1. kubectl apply -f https://raw.githubusercontent.com/OpenFunction/revision-controller/release-1.0/deploy/bundle.yaml

The Revision Controller will be installed to the openfunction namespace by default. You can download bundle.yaml and change the namespace manually if you want to install it to another namespace.

Detect source code or image changes

To detect source code or image changes, you’ll need to add revision controller switch and params like below to a function’s annotation.

  1. apiVersion: core.openfunction.io/v1beta1
  2. kind: Function
  3. metadata:
  4. annotations:
  5. openfunction.io/revision-controller: enable
  6. openfunction.io/revision-controller-params: |
  7. type: source
  8. repo-type: github
  9. polling-interval: 1m
  10. name: function-http-java
  11. namespace: default
  12. spec:
  13. build:
  14. ...
  15. serving:
  16. ...

Annotations

KeyDescription
openfunction.io/revision-controllerWhether to enable revision controller to detect source code or image changes for this function, can be set to either enable or disable.
openfunction.io/revision-controller-paramsParameters for revision controller.

Parameters

NameDescription
typeThe change type to detect including source, source-image, and image.
polling-intervalThe interval to polling the image digest or source code head.
repo-typeThe type of the git repo including github, gitlab, and gitee. Default to github.
base-urlThe base url of the gitlab server.
auth-typeThe auth type of the gitlab server.
project-idThe project id of a gitlab repo.
insecure-registryIf the image registy is insecure, you should set this to true.