Declarative application specifications for Fission (#422)

This change enables users to have declarative specifications for Fission resources. Users can specify their "app" in a set of spec files, and use a new fission CLI command to "apply" these specs to a running cluster.

The new "spec" CLI also includes archiving of local source files, and a file watcher that re-builds archives and uploads them on file changes, and a package build watcher that waits for package builds on the CLI. 

A "--spec" option is also added to "function create", and will be added to other resources in future changes.  This option causes a YAML to be outputted to the specs directory instead of the resource being created on the cluster.

The CLI "fission spec --help" outputs usage information.
This commit is contained in:
Soam Vasani
2018-02-05 21:58:44 -08:00
committed by GitHub
parent 6af13e7e29
commit 07c7b759d2
26 changed files with 2013 additions and 85 deletions
+11 -34
View File
@@ -1,40 +1,17 @@
# Go examples
# Hello World in Go on Fission
The `go` runtime uses the [`plugin` package](https://golang.org/pkg/plugin/) to dynamically load an HTTP handler.
## Requirements
First, set up your fission deployment with the go environment.
```
fission env create --name go-env --image fission/go-env:1.8.1
```
To ensure that you build functions using the same version as the
runtime, fission provides a docker image and helper script for
building functions.
## Example Usage
### hello.go
`hello.go` is an very basic HTTP handler returning `"Hello, World!"`.
`hello.go` is an very simple fission function that says "Hello, World!".
```bash
# Download the build helper script
$ curl https://raw.githubusercontent.com/fission/fission/master/environments/go/builder/go-function-build > go-function-build
$ chmod +x go-function-build
# This command creates the environment and function, and waits for the
# function build. Look at the YAML files in specs/ for details about
# how those are specified.
$ fission spec apply --wait
1 environment created
1 package created
1 function created
# Build the function as a plugin. Outputs result to 'function.so'
$ go-function-build hello.go
# Upload the function to fission
$ fission function create --name hello --env go-env --package function.so
# Map /hello to the hello function
$ fission route create --method GET --url /hello --function hello
# Run the function
$ curl http://$FISSION_ROUTER/hello
# This run the function and prints its output
$ fission function test --name hello
Hello, World!
```