Knative Functions client API and CLI
Go to file
Luke K cc016db990
build: update container latest tag when releasing
2020-07-28 14:52:49 +00:00
.chglog actions: add CHANGELOG.md and a release target to Makefile (#45) 2020-07-28 09:14:45 -04:00
.github/workflows build: update container latest tag when releasing 2020-07-28 14:52:49 +00:00
appsody rename Service Function to simply Function 2020-07-02 14:52:27 +00:00
buildpacks update language references to associated runtime 2020-07-02 13:18:19 +00:00
cmd enable build from tag 2020-07-08 12:22:27 +00:00
docker docker-based pusher implementation 2020-04-11 19:43:38 +00:00
embedded update language references to associated runtime 2020-07-02 13:18:19 +00:00
k8s moved cluster config notes and yamls to dedicated config repo 2020-04-15 16:57:44 +00:00
kn references to client now faas root package 2020-05-11 00:21:17 +00:00
knative Merge remote-tracking branch 'matej/imprv-deploy' into develop 2020-07-08 01:59:46 +00:00
kubectl final url print placeholder 2020-05-23 01:25:12 +00:00
mock tests to runtime 2020-07-02 14:36:48 +00:00
progress pass in ticker channel 2020-05-29 13:57:38 +00:00
prompt add vars to prompt tests 2020-06-16 14:30:46 +00:00
templates feat: http template for Quarkus stack 2020-07-27 16:03:55 +02:00
testdata tests to runtime 2020-07-02 14:36:48 +00:00
.dockerignore ignore local bin for docker image 2020-07-08 02:46:51 +00:00
.gitignore init: add Node.js HTTP template 2020-07-09 15:14:32 -04:00
CHANGELOG.md actions: add CHANGELOG.md and a release target to Makefile (#45) 2020-07-28 09:14:45 -04:00
Dockerfile docker image 2020-07-08 03:08:30 +00:00
LICENSE Apache 2.0 License 2020-07-09 12:22:59 +00:00
Makefile build: update container latest tag when releasing 2020-07-28 14:52:49 +00:00
README.md docs: improved description and initial setup 2020-07-09 13:44:31 +00:00
client.go rename Service Function to simply Function 2020-07-02 14:52:27 +00:00
client_test.go rename Service Function to simply Function 2020-07-02 14:52:27 +00:00
client_unit_test.go separate function from client to enable contextless methods such as List 2020-05-11 00:12:19 +00:00
config.go rename language to runtime 2020-07-02 13:06:54 +00:00
function.go rename language to runtime 2020-07-02 13:06:54 +00:00
function_unit_test.go rename Service Function to simply Function 2020-07-02 14:52:27 +00:00
go.mod actions: add CHANGELOG.md and a release target to Makefile (#45) 2020-07-28 09:14:45 -04:00
go.sum actions: add CHANGELOG.md and a release target to Makefile (#45) 2020-07-28 09:14:45 -04:00
pkged.go feat: http template for Quarkus stack 2020-07-27 16:03:55 +02:00

README.md

faas

Main Build Status Develop Build Status Documentation GitHub Issues License Release

Function as a Service CLI and Client Library for KNative-enabled Kubernetes Clusters.

Local Setup and Configuration

Docker is required unless the --local flag is explicitly provided on creation of a new function.

It is recommended to set your preferred image registry for publishing Functions by setting the following environment variables:

export FAAS_REGISTRY=quay.io
export FAAS_NAMESPACE=alice

Alternately, these values can be provided using the --namespace and --registry flags when running the CLI.

Cluster Setup and Configuration

It is assumed that the local system has a kubectl configuration set up to connect to a Kubernetes cluster with the following configuration:

  • Knative Serving and Eventing Installed
  • Knative Domains patched to enable your chosen domain
  • Knative Network patched to enable subdomains
  • Kourier
  • (optionally) Cert-manager for HTTPS routes

See https://github.com/boson-project/config for cluster setup and configuration notes.

Running the CLI

The CLI can be run either by building and installing manually, by running one of the published containers, or using the appropriate pre-built binary releases.

Build and Install

With Go 1.13+ installed, build and install the binary to your path:

go install ./cmd/faas

Docker

Each tag has an assoicated container which can be run via:

docker run quay.io/boson/faas:v0.2.2

Pre-built Binary Releases

Coming soon.

Usage

See help:

faas

Examples

Create a new Function:

> mkdir -p example.com/www
> cd example.com/www
> faas create go
https://www.example.com
> curl https://www.example.com
OK

Using the Client Library

To create a Client which uses the included buildpacks-based function builder, pushes to a Quay.io repository function container artifacts and deploys to a Knative enabled cluster:

package main

import (
  "log"

  "github.com/boson-project/faas"
  "github.com/boson-project/faas/buildpacks"
  "github.com/boson-project/faas/docker"
  "github.com/boson-project/faas/embedded"
  "github.com/boson-project/faas/knative"
)

func main() {
  // A client which uses embedded function templates,
  // Quay.io/alice for interstitial build artifacts.
  // Docker to build and push, and a Knative client for deployment.
  client, err := faas.New(
    faas.WithInitializer(embedded.NewInitializer("")),
    faas.WithBuilder(buildpacks.NewBuilder("quay.io", "alice")),
    faas.WithPusher(docker.NewPusher()),
    faas.WithDeployer(knative.NewDeployer()))

  // Create a Go function which listens for CloudEvents.
  // Publicly routable as https://www.example.com.
  // Local implementation is written to the current working directory.
  if err := client.Create("go", "events", "www.example.com", "."); err != nil {
    log.Fatal(err)
  }
}