From 6199c61178bc34a09d99a2c9a23b631c703deacc Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Thu, 21 Dec 2017 20:34:24 +0000 Subject: [PATCH] Remove non-async deployment option Signed-off-by: Alex Ellis --- api-docs/swagger.yml | 1 - deploy_extended.sh | 9 ---- docker-compose.yml | 47 ++++++++++++++++++++- guide/asynchronous.md | 15 +------ sample-functions/BaseFunctions/R/README.Rmd | 4 +- 5 files changed, 49 insertions(+), 27 deletions(-) delete mode 100755 deploy_extended.sh diff --git a/api-docs/swagger.yml b/api-docs/swagger.yml index a412a469..2a857121 100644 --- a/api-docs/swagger.yml +++ b/api-docs/swagger.yml @@ -149,7 +149,6 @@ paths: post: summary: 'Invoke a function asynchronously in OpenFaaS' description: >- - ### This endpoint requires the asynchronous stack. See https://github.com/openfaas/faas/blob/master/guide/asynchronous.md. parameters: - in: path diff --git a/deploy_extended.sh b/deploy_extended.sh deleted file mode 100755 index 8a45834d..00000000 --- a/deploy_extended.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -if ! [ -x "$(command -v docker)" ]; then - echo 'Unable to find docker command, please install Docker (https://www.docker.com/) and retry' >&2 - exit 1 -fi - -echo "Deploying extended stack" -docker stack deploy func --compose-file docker-compose.extended.yml diff --git a/docker-compose.yml b/docker-compose.yml index d197be43..a7344d62 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,8 @@ services: read_timeout: 10 # set both here, and on your functions write_timeout: 10 # set both here, and on your functions dnsrr: "true" # Temporarily use dnsrr in place of VIP while issue persists on PWD + faas_nats_address: "nats" + faas_nats_port: 4222 deploy: resources: limits: @@ -27,6 +29,49 @@ services: constraints: - 'node.role == manager' - 'node.platform.os == linux' + + nats: + image: nats-streaming:0.6.0 + # Uncomment the following port mappings if you wish to expose the + # NATS client and/or management ports + # ports: + # - 4222:4222 + # - 8222:8222 + command: "--store memory --cluster_id faas-cluster" + networks: + - functions + deploy: + resources: + limits: + memory: 125M + reservations: + memory: 50M + placement: + constraints: + - 'node.platform.os == linux' + + queue-worker: + image: functions/queue-worker:0.4 + networks: + - functions + environment: + max_inflight: "1" + ack_timeout: "30s" # Max duration of any async task / request + deploy: + resources: + limits: + memory: 50M + reservations: + memory: 20M + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 20 + window: 380s + placement: + constraints: + - 'node.platform.os == linux' + # End # Start monitoring @@ -209,4 +254,4 @@ services: networks: functions: driver: overlay - #attachable: true + attachable: true diff --git a/guide/asynchronous.md b/guide/asynchronous.md index 9174adb1..c83f8a35 100644 --- a/guide/asynchronous.md +++ b/guide/asynchronous.md @@ -39,22 +39,9 @@ You can also use asynchronous calls with a callback URL screen shot 2017-10-26 at 15 55 06 -## Deploy the async stack - The reference implementation for asychronous processing uses NATS Streaming, but you are free to extend OpenFaaS and write your own [queue-worker](https://github.com/open-faas/nats-queue-worker). -Swarm: - -``` -$ ./deploy_extended.sh -``` - -K8s: - -``` -$ kubectl delete -f ./faas.yml -$ kubectl apply -f./faas.async.yml,nats.yml -``` +> The asynchronous stack is now built-in by default. Previously it was an optional configuration. ## Call a function diff --git a/sample-functions/BaseFunctions/R/README.Rmd b/sample-functions/BaseFunctions/R/README.Rmd index d3619082..b10f10bb 100644 --- a/sample-functions/BaseFunctions/R/README.Rmd +++ b/sample-functions/BaseFunctions/R/README.Rmd @@ -7,11 +7,11 @@ output: github_document knitr::opts_chunk$set(echo = TRUE) ``` -Use this FaaS function using R. +Use this OpenFaaS function using R. **Deploy the base R function** -(Make sure you have already deployed FaaS with ./deploy_stack.sh in the root of this Github repository. +(Make sure you have already deployed OpenFaaS with ./deploy_stack.sh in the root of this Github repository. * Option 1 - click *Create a new function* on the FaaS UI