mirror of
https://github.com/openfaas/faas.git
synced 2025-06-16 21:06:54 +00:00
Mention ports and CLI
This commit is contained in:
parent
291f2fe0a6
commit
32d6c21d36
73
TestDrive.md
73
TestDrive.md
@ -1,52 +1,77 @@
|
||||
## OpenFaaS - TestDrive
|
||||
# OpenFaaS - TestDrive
|
||||
|
||||
OpenFaaS (or Functions as a Service) is a framework for building serverless functions on Docker Swarm and Kubernetes with first class metrics. Any UNIX process can be packaged as a function in FaaS enabling you to consume a range of web events without repetitive boiler-plate coding.
|
||||
|
||||
> Please support the project and put a **Star** on the repo.
|
||||
|
||||
**Overview**
|
||||
# Overview
|
||||
|
||||
A Docker stack file with a number of sample functions is provided so that you can get up and running within minutes. You can also clone the code to hack on it or package your own functions.
|
||||
We have provided several sample functions which are built-into the *Docker Stack* file we deploy during the test drive. You'll be up and running in a few minutes and invoking functions via the Web UI or `curl`. When you're ready to deploy your own function click "Create Function" in the UI or head over to the CLI tutorial:
|
||||
|
||||
The guide makes use of a free testing/cloud service, but if you want to try it on your own laptop just follow the guide in the README file on Github. There is also a [blog post](http://blog.alexellis.io/functions-as-a-service/) that goes into the background of the project.
|
||||
* [Morning coffee with the OpenFaaS CLI](https://blog.alexellis.io/quickstart-openfaas-cli/)
|
||||
|
||||
* So let's head over to http://play-with-docker.com/ and start a new session.
|
||||
## Pre-reqs
|
||||
|
||||
* Click "Add new Instance" to create a Docker host, more can be added later.
|
||||
The guide makes use of a cloud playground service called [play-with-docker.com](http://play-with-docker.com/) that provides free Docker hosts for around 5 hours. If you want to try this on your own laptop just follow along.
|
||||
|
||||
This one-shot script clones the code, initialises Docker swarm mode and then deploys the FaaS sample stack.
|
||||
Background info:
|
||||
|
||||
* There is also a [blog post](http://blog.alexellis.io/functions-as-a-service/) that goes into the background of the project.
|
||||
|
||||
## Start here
|
||||
|
||||
* So let's head over to http://play-with-docker.com/ and start a new session. You will probably have to fill out a Captcha.
|
||||
|
||||
* Click "Add New Instance" to create a single Docker host (more can be added later)
|
||||
|
||||
This one-shot script clones the code, sets up a Docker Swarm master node then deploys OpenFaaS with the sample stack:
|
||||
|
||||
```
|
||||
# docker swarm init --advertise-addr eth0 && \
|
||||
git clone https://github.com/openfaas/faas && \
|
||||
cd faas && \
|
||||
git checkout 0.6.6-beta && \
|
||||
git checkout 0.6.6-beta1 && \
|
||||
./deploy_stack.sh && \
|
||||
docker service ls
|
||||
```
|
||||
|
||||
*The shell script makes use of a v3 docker-compose.yml file*
|
||||
*The shell script makes use of a v3 docker-compose.yml file - read the `deploy_stack.sh` file for more details.*
|
||||
|
||||
> If you are not testing on play-with-docker then remove `--advertise-addr eth0` from first line of the script.
|
||||
|
||||
* Now that everything's deployed take note of the two DNS entries at the top of the screen.
|
||||
* Now that everything's deployed take note of the two ports at the top of the screen:
|
||||
|
||||
* 8080 - the API Gateway and OpenFaaS UI
|
||||
* 9090 - the Prometheus metrics endpoint
|
||||
|
||||

|
||||
|
||||
## Sample functions
|
||||
|
||||
Some of the sample functions are:
|
||||
We have packaged some simple starter functions in the Docker stack, so as soon as you open the OpenFaaS UI you will see them listed down the left-hand side.
|
||||
|
||||
Here are a few of the functions:
|
||||
|
||||
* Markdown to HTML renderer (markdownrender) - takes .MD input and produces HTML (Golang)
|
||||
* Docker Hub Stats function (hubstats) - queries the count of images for a user on the Docker Hub (Golang)
|
||||
* Node Info (nodeinfo) function - gives you the OS architecture and detailled info about the CPUS (Node.js)
|
||||
* Webhook stasher function (webhookstash) - saves webhook body into container's filesystem - even binaries (Golang)
|
||||
|
||||
Newly added sample functions (not included in the sample stack)
|
||||
## Install FaaS-CLI
|
||||
|
||||
* Hello world in - [Java/.NET core/Python/Node/Go and more](https://github.com/alexellis/faas/tree/master/sample-functions/BaseFunctions)
|
||||
* [Resize images with Image Magick](https://github.com/alexellis/faas/tree/master/sample-functions/ResizeImageMagick)
|
||||
* [Function protected by API key in HTTP Header](https://github.com/alexellis/faas/tree/master/sample-functions/ApiKeyProtected)
|
||||
We will also install the OpenFaaS CLI which can be used to create, list, invoke and remove functions.
|
||||
|
||||
```
|
||||
$ curl -sL cli.openfaas.com | sh
|
||||
```
|
||||
|
||||
On your own machine change `| sh` to `| sudo sh`, for MacOS you can just use `brew install faas-cli`.
|
||||
|
||||
* Find out what you can do
|
||||
|
||||
```
|
||||
$ faas-cli --help
|
||||
```
|
||||
|
||||
### Invoke the sample functions with curl or Postman:
|
||||
|
||||
@ -54,7 +79,19 @@ Head over to the [Github and Star the project](https://github.com/alexellis/faas
|
||||
|
||||
### Working with the sample functions
|
||||
|
||||
You can access the sample functions via the command line with a HTTP POST request or by using the built-in UI portal.
|
||||
You can access the sample functions via the command line with a HTTP POST request, the FaaS-CLI or by using the built-in UI portal.
|
||||
|
||||
* Invoke the markdown function with the CLI:
|
||||
|
||||
```
|
||||
$ echo "# Test *Drive*"| faas-cli invoke func_markdown
|
||||
```
|
||||
|
||||
* List your functions
|
||||
|
||||
```
|
||||
$ faas-cli list
|
||||
```
|
||||
|
||||
**UI portal:**
|
||||
|
||||
@ -83,7 +120,7 @@ nnlzo6u3pilg func_prometheus.1 quay.io/prometheus/prometheus:latest moby Ru
|
||||
|
||||
* Your functions can be accessed via the gateway UI or read on for `curl`
|
||||
|
||||
## Building functions from templates and the CLI
|
||||
## Build functions from templates and the CLI
|
||||
|
||||
The following guides show how to use the CLI and code templates to build functions.
|
||||
|
||||
@ -101,7 +138,7 @@ Guides:
|
||||
|
||||
* [Your first serverless .NET / C# function with OpenFaaS](https://medium.com/@rorpage/your-first-serverless-net-function-with-openfaas-27573017dedb)
|
||||
|
||||
## Packaging a custom Docker image
|
||||
## Package a custom Docker image
|
||||
|
||||
Read the developer guide:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user