How to deploy functions automatically in CI?
Closed this issue · 3 comments
Hello,
I'm tring to deploy functions automatically using tekton, and ci is expected to be triggered by git commits. I could not find any document mentioning the way to deploy functions in ci, I think there might be a few options:
- Since
func deploy --remote
will create a pipeline to deploy the function, we can reuse the created pipeline and configure a tekton trigger to initialize the pipelinerun - May be it's possible to run
func deploy --remote
directly inside a tekton task? - Build the image locally and push to a registry. But then how to deploy the image?
Whic one is recommended?
Hello @drriguz,
Yes, this is a use-case which we think is core to the usage of Functions. I am sorry we don't have documentation or additional resources yet available, but they are on the way!
For now you really have one best option: Run func deploy --remote
from within CI/CD (a GitHub Action, for exampple) which will trigger the build and deploy tekton task. You will of course need Tekton installed in your cluster. You will also need to have a container registry ready to go such as docker.io (unless you're running OpenShift which has one built in).
When your CI/CD action runs func deploy --remote
, it will send all of the local source code to the cluster for packaging and deployment (no need to run func...
from within the cluster; that's automatic.
So if you have been able to build and deploy your Function from your local machine, it will have the registry already set. Commit everything (including the func.yaml). Then, your CI/CD action should have the following pseudocode:
On Merge to main:
Check out your Function's source code (its current state)
Pull the latest `func` binary
run `func deploy --remote`
Please re-open if this did not answer your question @drriguz, or join us in the CNCF Slack channel to help put together your CI/CD task.
Please re-open if this did not answer your question @drriguz, or join us in the CNCF Slack channel to help put together your CI/CD task.
Thanks, this solves my problem. In my case, I have a problem building the source in CI because it's air-gapped network, my choice is currently running build on local device and use func deploy --image=xxx
option.