Remove Swarm resources from faas repo

This is part of the following activity:

https://github.com/openfaas/docs/pull/249

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd) 2020-12-16 09:58:26 +00:00
parent a2bdc94f00
commit 8a5b3123e0
63 changed files with 11 additions and 2217 deletions

8
DEV.md
View File

@ -1,13 +1,5 @@
## Develop your own function
### TestDrive
Before you start development, you may want to take FaaS for a test drive which sets up a stack of sample functions from docker-compose.yml. You can then build your own functions and add them to the stack.
> You can test-drive FaaS with a set of sample functions as defined in docker-compose.yml on play-with-docker.com for free, or on your own laptop.
* [Begin the TestDrive instructions](https://github.com/openfaas/faas/blob/master/TestDrive.md)
### Working on the API Gateway or Watchdog
To work on either of the FaaS Golang components checkout the "./build.sh" scripts and acompanying Dockerfiles.

View File

@ -5,6 +5,6 @@ NS?=openfaas
build-gateway:
(cd gateway; docker buildx build --platform linux/amd64 -t $NS/gateway:latest-dev .)
.PHONY: test-ci
test-ci:
./contrib/ci.sh
# .PHONY: test-ci
# test-ci:
# ./contrib/ci.sh

View File

@ -16,16 +16,12 @@ The core services which make up OpenFaaS need to run on a Linux master, but Wind
Platforms: the x86_64 platform has first class support, with 32-bit arm and 64-bit arm provided on a best-effort basis.
Orchestrators: there is official support for Kubernetes & Docker Swarm with the community providing support for AWS Fargate, Hashicorp Nomad and others.
Orchestrators: there is official support for Kubernetes & faasd (containerd) with the community providing support for AWS Fargate, Hashicorp Nomad and others.
### OpenFaaS Cloud
OpenFaaS Cloud is a multi-user distribution of OpenFaaS with a built-in CI/CD pipeline, OAuth delegation, a dashboard and a git-based workflow with public/private GitHub and self-hosted GitLab.
Platforms: only the x86_64 platform has support.
Orchestrators: there is official support for Kubernetes and for Docker Swarm. Kubernetes has better support for multiple users / tenants than Swarm.
## What is coming next?
Proposals and feature requests are tracked [on the 2020 Roadmap on Trello](https://trello.com/invite/b/5OpMyrBP/ade103a10ae1e38eb5d3eee7955260a9/2020-openfaas-roadmap) and through the GitHub issue tracker of each project in the two organisations.

View File

@ -1,315 +0,0 @@
# OpenFaaS - TestDrive
## TestDrive (v2)
The TestDrive has been replaced by the OpenFaaS workshop which is a set of self-paced labs developed by the community to teach you the basics of building Serverless Functions with OpenFaaS.
Please start [Lab 1 here](https://github.com/openfaas/workshop)
## TestDrive (v1)
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
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 "Deploy Function" in the UI or head over to the CLI tutorial:
* [Morning coffee with the OpenFaaS CLI](https://blog.alexellis.io/quickstart-openfaas-cli/)
## Pre-reqs
The guide makes use of a cloud playground service called [Play with Docker.com](https://labs.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.
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 [https://labs.play-with-docker.com/](https://labs.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.8.0 && \
./deploy_stack.sh && \
docker service ls
```
*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 ports at the top of the screen:
* 8080 - the API Gateway and OpenFaaS UI
* 9090 - the Prometheus metrics endpoint
![](https://user-images.githubusercontent.com/6358735/31058899-b34f2108-a6f3-11e7-853c-6669ffacd320.jpg)
## Sample functions
Deploy the sample functions by deploying the `stack.yml` file in the `faas/` repo folder:
```
faas deploy
```
You don't need to specify a `-f` or `--yaml` option to the `faas` command. By default the `stack.yml` file is used if it is present.
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)
## Install FaaS-CLI
We will also install the OpenFaaS CLI which can be used to create, list, invoke and remove functions.
```shell
$ 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
```shell
$ faas-cli --help
```
### Invoke the sample functions with curl or Postman:
Head over to the [Github and Star the project](https://github.com/openfaas/faas), or read on to see the input/output from the sample functions.
### Working with the sample functions
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
<h1>Test <em>Drive</em></h1>
```
* List your functions
```
$ faas-cli list
Function Invocations Replicas
func_echoit 0 1
func_base64 0 1
func_decodebase64 0 1
func_markdown 3 1
func_nodeinfo 0 1
func_wordcount 0 1
func_hubstats 0 1
func_webhookstash 0 1
```
**UI portal:**
The UI portal is accessible on: http://127.0.0.1:8080/ - it show a list of functions deployed on your swarm and allows you to test them out.
View screenshot:
<a href="https://pbs.twimg.com/media/C3hDUkyWEAEgciP.jpg"><img src="https://pbs.twimg.com/media/C3hDUkyWEAEgciP.jpg" width="800"></img></a>
You can find out which services are deployed like this:
```
# docker stack ls
NAME SERVICES
func 3
# docker stack ps func
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE
rhzej73haufd func_gateway.1 alexellis2/faas-gateway:latest moby Running Running 26 minutes ago
fssz6unq3e74 func_hubstats.1 alexellis2/faas-dockerhubstats:latest moby Running Running 27 minutes ago
nnlzo6u3pilg func_prometheus.1 quay.io/prometheus/prometheus:latest moby Running Running 27 minutes ago
```
* Head over to http://127.0.0.1:9090 for your Prometheus metrics
* A saved Prometheus view is available here: [metrics overview](http://127.0.0.1:9090/graph?g0.range_input=15m&g0.expr=rate(gateway_function_invocation_total%5B20s%5D)&g0.tab=0&g1.range_input=15m&g1.expr=gateway_functions_seconds_sum+%2F+gateway_functions_seconds_counts&g1.tab=0&g2.range_input=15m&g2.expr=gateway_service_count&g2.tab=0)
* Your functions can be accessed via the gateway UI or read on for `curl`
## Build functions from templates and the CLI
The following guides show how to use the CLI and code templates to build functions.
Using a template means you only have to write a handler file in your chosen programming language such as:
* Ruby
* Node.js
* Python
* CSharp
* Or propose a template for another programming languae
Guides:
* [Your first serverless Python function with OpenFaaS](https://blog.alexellis.io/first-faas-python-function/)
* [Your first serverless .NET / C# function with OpenFaaS](https://medium.com/@rorpage/your-first-serverless-net-function-with-openfaas-27573017dedb)
## Package a custom Docker image
Read the developer guide:
* [Packaging a function](https://github.com/openfaas/faas/blob/master/DEV.md)
The original blog post also walks through creating a function:
* [FaaS blog post](http://blog.alexellis.io/functions-as-a-service/)
## Add new functions to FaaS at runtime
**Option 1: via the FaaS CLI**
The FaaS CLI can be used to build functions very quickly though the use of templates. See more details on the FaaS CLI [here](https://github.com/openfaas/faas-cli).
**Option 2: via FaaS UI portal**
To attach a function at runtime you can use the "Create New Function" button on the portal UI at http://127.0.0.1:8080/
<a href="https://pbs.twimg.com/media/C8opW3RW0AAc9Th.jpg:large"><img src="https://pbs.twimg.com/media/C8opW3RW0AAc9Th.jpg:large" width="600"></img></a>
Creating a function via the UI:
| Option | Usage |
|------------------------|--------------|
| `Image` | The name of the image you want to use for the function. A good starting point is functions/alpine |
| `Service Name` | Describe the name of your service. The Service Name format is: [a-zA-Z_0-9] |
| `fProcess` | The process to invoke for each function call. This must be a UNIX binary and accept input via STDIN and output via STDOUT. |
| `Network` | The network `func_functions` is the default network. |
Once the create button is clicked, faas will provision a new Docker Swarm service. The newly created function will shortly be available in the list of functions on the left hand side of the UI.
**Option 3: Through docker-compose.yml stack file**
Edit the docker-compose stack file, then run ./deploy_stack.sh - this will only update changed/added services, not existing ones.
**Option 4: Programatically through a HTTP POST to the API Gateway**
A HTTP post can also be sent via `curl` etc to the endpoint used by the UI (HTTP post to `/system/functions`)
```
// CreateFunctionRequest create a function in the swarm.
type CreateFunctionRequest struct {
Service string `json:"service"`
Image string `json:"image"`
Network string `json:"network"`
EnvProcess string `json:"envProcess"`
}
```
Example:
For a quote-of-the-day type of application:
```
curl 127.0.0.1:8080/system/functions -d '
{"service": "oblique", "image": "vielmetti/faas-oblique", "envProcess": "/usr/bin/oblique", "network": "func_functions"}'
```
For a hashing algorithm:
```
curl 127.0.0.1:8080/system/functions -d '
{"service": "stronghash", "image": "functions/alpine", "envProcess": "sha512sum", "network": "func_functions"}'
```
### Delete a function at runtime
You can delete a function through the FaaS-CLI or with the Docker CLI
```
$ docker service rm func_echoit
```
### Exploring the functions with `curl`
**Sample function: Docker Hub Stats (hubstats)**
```
# curl -X POST http://127.0.0.1:8080/function/func_hubstats -d "alexellis2"
The organisation or user alexellis2 has 99 repositories on the Docker hub.
```
The `-d` value passes in the argument for your function. This is read via STDIN and used to query the Docker Hub to see how many images you've created/pushed.
You can also invoke functions using the OpenFaaS CLI:
```
# echo -n "library" | faas-cli invoke func_hubstats
The organisation or user library has 128 repositories on the Docker hub.
```
**Sample function: Node OS Info (nodeinfo)**
Grab OS, CPU and other info via a Node.js container using the `os` module.
If you invoke this method in a while loop or with a load-generator tool then it will auto-scale to 5, 10, 15 and finally 20 replicas due to the load. You will then be able to see the various Docker containers responding with a different Hostname for each request as the work is distributed evenly.
Here is a loop that can be used to invoke the function in a loop to trigger auto-scaling.
```
while [ true ] ; do curl -X POST http://127.0.0.1:8080/function/func_nodeinfo -d ''; done
```
Example:
```
# curl -X POST http://127.0.0.1:8080/function/func_nodeinfo -d ''
Hostname: 9b077a81a489
Platform: linux
Arch: arm
CPU count: 1
Uptime: 776839
```
To control scaling behaviour you can set a min/max scale value with a label when deploying your function via the CLI or the API:
```
labels:
"com.openfaas.scale.min": "5"
"com.openfaas.scale.max": "15"
```
**Sample function: webhook stasher (webhookstash)**
Another cool sample function is the Webhook Stasher which saves the body of any data posted to the service to the container's filesystem. Each file is written with the filename of the UNIX time.
```
# curl -X POST http://127.0.0.1:8080/function/func_webhookstash -d '{"event": "fork", "repo": "alexellis2/faas"}'
Webhook stashed
# docker ps|grep stash
d769ca70729d alexellis2/faas-webhookstash@sha256:b378f1a144202baa8fb008f2c8896f5a8
# docker exec d769ca70729d find .
.
./1483999546817280727.txt
./1483999702130689245.txt
./1483999702533419188.txt
./1483999702978454621.txt
./1483999703284879767.txt
./1483999719981227578.txt
./1483999720296180414.txt
./1483999720666705381.txt
./1483999720961054638.txt
```
> Why not start the code on play-with-docker.com and then configure a Github repository to send webhooks to the API Gateway?

View File

@ -404,10 +404,10 @@ definitions:
properties:
provider:
type: string
example: faas-swarm
example: faas-netes
orchestration:
type: string
example: swarm
example: kubernetes
version:
type: object
description: Version of the OpenFaaS Provider

View File

@ -603,8 +603,7 @@ Official providers developed and supported by the OpenFaaS project
| Project name and description | Author | Site | Status |
|----------------------------------------------------------------------|------------|-----------|-------------|
| **faas-netes**- Kubernetes provider | OpenFaaS | [github.com](https://github.com/openfaas/faas-netes) | Supported |
| **faas-swarm** - Docker Swarm provider | OpenFaaS | [github.com](https://github.com/openfaas/faas-swarm) | Supported |
| **openfaas-operator** - Kubernetes Operator provider | OpenFaaS | [github.com](https://github.com/openfaas-incubator/openfaas-operator) | Incubation |
| **faasd**- containerd single-host provider | OpenFaaS | [github.com](https://github.com/openfaas/faasd) | Supported |
Community providers actively being developed and/or supported by a third-party
@ -615,12 +614,12 @@ Community providers actively being developed and/or supported by a third-party
| **faas-federation** - federation provider to route between one or more providers | Ed Wilde / Alex Ellis | [github.com](https://github.com/openfaas-incubator/faas-federation) | Inception |
| **faas-fargate** - AWS Fargate provider | Edward Wilde | [github.com](https://github.com/ewilde/faas-fargate) | Incubation |
| **faas-lambda** - AWS Lambda provider | Ed Wilde / Alex Ellis | [sales@openfaas.com](mailto:sales@openfaas.com) | Incubation |
| **faas-containerd** - containerd provider for single node / edge | Alex Ellis | [github.com](https://github.com/alexellis/faas-containerd) | Inception |
Community providers no-longer being maintained
| Project name and description | Author | Site | Status |
|----------------------------------------------------------------------|------------|-----------|-------------|
| **faas-swarm** - Docker Swarm provider | OpenFaaS | [github.com](https://github.com/openfaas/faas-swarm) | Deprecated |
| **faas-rancher** - Rancher/Cattle provider | Ken Fukuyama | [github.com](https://github.com/kenfdev/faas-rancher) | Inception |
| **faas-dcos** - DCOS provider | Alberto Quario | [github.com](https://github.com/realbot/faas-dcos) | Inception |
| **faas-hyper** - Hyper.sh provider | Hyper | [github.com](https://github.com/hyperhq/faas-hyper) | Inception |

View File

@ -1,71 +0,0 @@
# UI development
The OpenFaaS UI consists of static pages built in Angular 1.x. These call the OpenFaaS API gateway for operations such as listing / creating and deleting functions.
The [Function Store](https://github.com/openfaas/store) is stored on GitHub as a JSON file which is fecthed by the browser over HTTPS. A CORS exception is maintained for GitHub's RAW CDN for this purpose within the [gateway code](https://github.com/openfaas/faas/blob/master/gateway/server.go).
## Multi-browser testing
UI changes should be tested in:
* Safari
* Chrome
* FireFox
* IE11
### Testing on Windows
Windows VMs are available from Microsoft for free - for testing pages/projects with their browsers:
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
[VirtualBox](https://www.virtualbox.org/wiki/Downloads) can run these VMs at no cost.
## Build a development API Gateway
1. Build a new development Docker image:
```
$ cd gateway/
$ ./build.sh
```
This creates a Docker image with the name `openfaas/gateway:latest-dev`, but if you want to use something else then pass the tag as an argument to the `./build.sh` script. I.e. `./build.sh labels-pr`.
3. Now edit the Docker image for the `gateway` service in your `docker-compose.yml` file.
4. Redeploy the stack.
Test. Repeat.
## Work on the UI the quick way
Working on the UI with the procedure above could take up to a minute to iterate between changing code and testing the changes. This section of the post shows how to bind-mount the UI assets into the API gateway as a separate container.
Remove the Docker stack, then re-define the faas network as "attachable":
```
$ docker stack rm func
$ docker network create func_functions --driver=overlay --attachable=true
```
Now edit the `docker-compose.yml` file and replace the existing networks block with:
```
networks:
functions:
external:
name: func_functions
```
Now deploy the rest of the stack with: `./deploy_stack.sh`.
Now you can run the gateway as its own container via `docker run` and bind-mount in the HTML assets.
```
$ docker service rm func_gateway
$ docker run --name func_gateway -e "functions_provider_url=http://faas-swarm:8080/" \
-v `pwd`/gateway/assets:/home/app/assets \
-v "/var/run/docker.sock:/var/run/docker.sock" \
-p 8080:8080 --network=func_functions \
-d openfaas/gateway:latest-dev
```

78
contrib/Vagrantfile vendored
View File

@ -1,78 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "generic/ubuntu1604"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 8080, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.50.2"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "../", "/vagrant"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
# Customize the amount of memory on the VM:
vb.memory = "2048"
end
config.vm.provider "vmware_fusion" do |vmf|
vmf.gui = false
vmf.memory = "2048"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "docker"
config.vm.provision "shell", inline: <<-SHELL
docker swarm init --advertise-addr 192.168.50.2
cd /vagrant
sh deploy_stack.sh
SHELL
end

View File

@ -1,17 +0,0 @@
FROM alpine:3.8
WORKDIR /root
RUN apk add --update libarchive-tools
ADD https://github.com/prometheus/alertmanager/releases/download/v0.15.0/alertmanager-0.15.0.linux-arm64.tar.gz /root/
RUN bsdtar -xvf *.tar.gz -C ./ --strip-components=1
RUN mkdir /etc/alertmanager
RUN cp alertmanager /bin/alertmanager
RUN cp alertmanager.yml /etc/alertmanager/alertmanager.yml
EXPOSE 9093
VOLUME [ "/alertmanager" ]
WORKDIR /alertmanager
ENTRYPOINT [ "/bin/alertmanager" ]
CMD [ "--config.file=/etc/alertmanager/alertmanager.yml", \
"--storage.path=/alertmanager" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-arm64-build ci-arm64-push
.PHONY: ci-arm64-build
ci-arm64-build:
docker build -t functions/alertmanager:0.15.0-arm64 .
.PHONY: ci-arm64-push
ci-arm64-push:
docker push functions/alertmanager:0.15.0-arm64

View File

@ -1,13 +0,0 @@
# Alertmanager for ARM64
## Building:
```bash
make ci-arm64-build
```
## Pushing:
```bash
make ci-arm64-push
```

View File

@ -1,18 +0,0 @@
FROM alpine:3.9
WORKDIR /root
RUN apk add --update libarchive-tools
ADD https://github.com/prometheus/alertmanager/releases/download/v0.16.1/alertmanager-0.16.1.linux-arm64.tar.gz /root/
RUN bsdtar -xvf *.tar.gz -C ./ --strip-components=1
RUN mkdir /etc/alertmanager
RUN cp alertmanager /bin/alertmanager
RUN cp alertmanager.yml /etc/alertmanager/alertmanager.yml
EXPOSE 9093
VOLUME [ "/alertmanager" ]
WORKDIR /alertmanager
ENTRYPOINT [ "/bin/alertmanager" ]
CMD [ "--config.file=/etc/alertmanager/alertmanager.yml", \
"--storage.path=/alertmanager" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-arm64-build ci-arm64-push
.PHONY: ci-arm64-build
ci-arm64-build:
docker build -t functions/alertmanager:0.16.1-arm64 .
.PHONY: ci-arm64-push
ci-arm64-push:
docker push functions/alertmanager:0.16.1-arm64

View File

@ -1,13 +0,0 @@
# Alertmanager for ARM64
## Building:
```bash
make ci-arm64-build
```
## Pushing:
```bash
make ci-arm64-push
```

View File

@ -1,17 +0,0 @@
FROM alpine:3.8
WORKDIR /root
RUN apk add --update libarchive-tools
ADD https://github.com/prometheus/alertmanager/releases/download/v0.15.0/alertmanager-0.15.0.linux-armv7.tar.gz /root/
RUN bsdtar -xvf *.tar.gz -C ./ --strip-components=1
RUN mkdir /etc/alertmanager
RUN cp alertmanager /bin/alertmanager
RUN cp alertmanager.yml /etc/alertmanager/alertmanager.yml
EXPOSE 9093
VOLUME [ "/alertmanager" ]
WORKDIR /alertmanager
ENTRYPOINT [ "/bin/alertmanager" ]
CMD [ "--config.file=/etc/alertmanager/alertmanager.yml", \
"--storage.path=/alertmanager" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-armhf-build ci-armhf-push
.PHONY: ci-armhf-build
ci-armhf-build:
docker build -t functions/alertmanager:0.15.0-armhf .
.PHONY: ci-armhf-push
ci-armhf-push:
docker push functions/alertmanager:0.15.0-armhf

View File

@ -1,13 +0,0 @@
# Alertmanager for ARMHF
## Building:
```bash
make ci-armhf-build
```
## Pushing:
```bash
make ci-armhf-push
```

View File

@ -1,17 +0,0 @@
FROM alpine:3.8
WORKDIR /root
RUN apk add --update libarchive-tools
ADD https://github.com/prometheus/alertmanager/releases/download/v0.16.1/alertmanager-0.16.1.linux-armv7.tar.gz /root/
RUN bsdtar -xvf *.tar.gz -C ./ --strip-components=1
RUN mkdir /etc/alertmanager
RUN cp alertmanager /bin/alertmanager
RUN cp alertmanager.yml /etc/alertmanager/alertmanager.yml
EXPOSE 9093
VOLUME [ "/alertmanager" ]
WORKDIR /alertmanager
ENTRYPOINT [ "/bin/alertmanager" ]
CMD [ "--config.file=/etc/alertmanager/alertmanager.yml", \
"--storage.path=/alertmanager" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-armhf-build ci-armhf-push
.PHONY: ci-armhf-build
ci-armhf-build:
docker build -t functions/alertmanager:0.16.1-armhf .
.PHONY: ci-armhf-push
ci-armhf-push:
docker push functions/alertmanager:0.16.1-armhf

View File

@ -1,13 +0,0 @@
# Alertmanager for ARMHF
## Building:
```bash
make ci-armhf-build
```
## Pushing:
```bash
make ci-armhf-push
```

View File

@ -1,14 +0,0 @@
FROM docker:dind
WORKDIR /root/
RUN apk --no-cache add git && \
git clone https://github.com/openfaas/faas
WORKDIR /root/faas/
EXPOSE 8080
EXPOSE 9090
COPY entry.sh .
RUN chmod +x ./entry.sh
CMD ["./entry.sh"]

View File

@ -1,11 +0,0 @@
#/bin/sh
dockerd &
while [ ! -e /var/run/docker.sock ] ; do sleep 0.25 && echo "Waiting for Docker socket" ; done
docker swarm init
./deploy_stack.sh
tail -f /dev/null

View File

@ -1,11 +0,0 @@
#!/bin/bash
docker rm -f faas
docker run --name faas --privileged -p 8080:8080 -p 9090:9090 -d alexellis2/faas-dind:0.6.5
./test.sh
echo "Quitting after 120 seconds."
sleep 120
docker rm -f faas

View File

@ -1,73 +0,0 @@
#!/bin/bash
function test_gateway {
for i in {1..100}
do
curl -s localhost:8080 |grep "angular"
if [ ! 0 -eq $? ]
then
echo "Gateway not ready"
sleep 5
else
break
fi
done
echo
}
function test_function_output {
for i in {1..100}
do
out=$(curl --fail -s localhost:8080/function/$1 -d "$2")
echo $out
if [ "$out" == "$3" ]
then
echo "Service $1 is ready"
break
else
echo "Service $1 not ready"
sleep 1
fi
done
echo
}
function test_function {
for i in {1..100}
do
curl -s --fail localhost:8080/function/$1 -d "$2"
if [ ! 0 -eq $? ]
then
echo "Service $1 not ready"
sleep 1
else
echo "Service $1 is ready"
break
fi
done
echo
}
function create_function {
echo "Creating function: " $1
curl -s --fail localhost:8080/system/functions -d "$1"
}
test_gateway
test_function func_echoit hi
test_function func_webhookstash hi
test_function func_base64 hi
test_function func_markdown "*salut*"
create_function '{"service": "stronghash", "image": "functions/alpine", "envProcess": "sha512sum", "network": "func_functions"}'
test_function_output stronghash "hi" "150a14ed5bea6cc731cf86c41566ac427a8db48ef1b9fd626664b3bfbb99071fa4c922f33dde38719b8c8354e2b7ab9d77e0e67fc12843920a712e73d558e197 -"

View File

@ -1,11 +0,0 @@
FROM debian:stretch
RUN mkdir -p /usr/local/go
ENV PATH=$PATH:/usr/local/go/bin
RUN apt update && apt -qy install curl \
&& curl -SL https://storage.googleapis.com/golang/go1.9.linux-arm64.tar.gz > go1.9.linux-arm64.tar.gz \
&& tar -xvf go1.9.linux-arm64.tar.gz -C /usr/local/go --strip-components=1
RUN go version
CMD ["/bin/sh"]

View File

@ -1 +0,0 @@
openfaas.htpasswd

View File

@ -1,4 +0,0 @@
FROM nginx:latest
COPY gateway.conf /etc/nginx/conf.d/default.conf

View File

@ -1,85 +0,0 @@
### Basic auth in 5 seconds
This guide shows you how to protect your cluster with "Basic Auth" which involves setting a username
and password. This method will prevent tampering but for production usage will also need TLS
enabling. Free TLS certificates can be generated with LetsEncrypt.
Steps:
* Generate a password file
* Push file into secret store
* Unexpose the gateway
* Create an Nginx proxy container with the new secret
* Test it out.
### Create a .htaccess:
```
$ sudo apt-get install apache2-utils
```
```
$ htpasswd -c openfaas.htpasswd admin
New password:
Re-type new password:
Adding password for user admin
```
Example:
```
$ cat openfaas.htpasswd
admin:$apr1$BgwAfB5i$dfzQPXy6VliPCVqofyHsT.
```
### Create a secret in the cluster
```
$ docker secret create --label openfaas openfaas_htpasswd openfaas.htpasswd
q70h0nsj9odbtv12vrsijcutx
```
You can now see the secret created:
```
$ docker secret ls
ID NAME DRIVER CREATED UPDATED
q70h0nsj9odbtv12vrsijcutx openfaas_htpasswd 13 seconds ago 13 seconds ago
```
### Remove the exposed port on the gateway
```
$ docker service update func_gateway --publish-rm 8080
```
### Build an Nginx container (optional)
Build gwnginx from contrib directory if you need customizations.
```
$ docker build -t alexellis/gwnginx:0.1 .
```
### Launch nginx
Deploy Nginx
```
$ docker service rm gwnginx ; \
docker service create --network=func_functions \
--secret openfaas_htpasswd \
--publish 8080:8080 \
--name gwnginx alexellis/gwnginx:0.1
```
### Connect to the UI
You can now connect to the UI on port 8080. If you use a web-browser you will be prompted for a password.
**API/CLI**
The API will require Basic Auth but can stil be used with `curl`. We have work under testing to support basic auth inside the `faas-cli` natively.

View File

@ -1,25 +0,0 @@
server {
listen 8080;
location /async-function/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://gateway:8080/async-function/;
}
location /function/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://gateway:8080/function/;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://gateway:8080/;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /var/run/secrets/openfaas_htpasswd; #For Basic Auth
}
}

View File

@ -1,31 +0,0 @@
FROM alpine:3.8
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.3.1/prometheus-2.3.1.linux-arm64.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,2 +0,0 @@
build:
docker build -t functions/prometheus:2.3.1-arm64 .

View File

@ -1,31 +0,0 @@
FROM alpine:3.8
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.6.1/prometheus-2.6.1.linux-arm64.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-arm64-build ci-arm64-push
.PHONY: ci-arm64-build
ci-arm64-build:
docker build -t functions/prometheus:2.6.1-arm64 .
.PHONY: ci-arm64-push
ci-arm64-push:
docker push functions/prometheus:2.6.1-arm64

View File

@ -1,13 +0,0 @@
# Prometheus for ARM64
## Building:
```bash
make ci-arm64-build
```
## Pushing:
```bash
make ci-arm64-push
```

View File

@ -1,31 +0,0 @@
FROM alpine:3.8
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.7.0/prometheus-2.7.0.linux-arm64.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-arm64-build ci-arm64-push
.PHONY: ci-arm64-build
ci-arm64-build:
docker build -t functions/prometheus:2.7.0-arm64 .
.PHONY: ci-arm64-push
ci-arm64-push:
docker push functions/prometheus:2.7.0-arm64

View File

@ -1,13 +0,0 @@
# Prometheus for ARM64
## Building:
```bash
make ci-arm64-build
```
## Pushing:
```bash
make ci-arm64-push
```

View File

@ -1,31 +0,0 @@
FROM alpine:3.9
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.7.1/prometheus-2.7.1.linux-arm64.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,11 +0,0 @@
.PHONY: all
all: ci-arm64-build ci-arm64-push
.PHONY: ci-arm64-build
ci-arm64-build:
docker build -t functions/prometheus:2.7.1-arm64 .
.PHONY: ci-arm64-push
ci-arm64-push:
docker push functions/prometheus:2.7.1-arm64

View File

@ -1,13 +0,0 @@
# Prometheus for ARM64
## Building:
```bash
make ci-arm64-build
```
## Pushing:
```bash
make ci-arm64-push
```

View File

@ -1,31 +0,0 @@
FROM alpine:3.6
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-armv7.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,31 +0,0 @@
FROM alpine:3.6
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.1.0/prometheus-2.1.0.linux-armv7.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,31 +0,0 @@
FROM alpine:3.8
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.2.0/prometheus-2.2.0.linux-armv7.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,3 +0,0 @@
build:
docker build -t alexellis2/prometheus:2.2.0-armhf .

View File

@ -1,5 +0,0 @@
Building:
```
docker build -t functions/prometheus:2.2.0-armhf .
```

View File

@ -1,31 +0,0 @@
FROM alpine:3.8
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.6.1/prometheus-2.6.1.linux-armv7.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-armhf-build ci-armhf-push
.PHONY: ci-armhf-build
ci-armhf-build:
docker build -t functions/prometheus:2.6.1-armhf .
.PHONY: ci-armhf-push
ci-armhf-push:
docker push functions/prometheus:2.6.1-armhf

View File

@ -1,13 +0,0 @@
# Prometheus for ARMHF
## Building:
```bash
make ci-armhf-build
```
## Pushing:
```bash
make ci-armhf-push
```

View File

@ -1,31 +0,0 @@
FROM alpine:3.8
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.7.0/prometheus-2.7.0.linux-armv7.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-armhf-build ci-armhf-push
.PHONY: ci-armhf-build
ci-armhf-build:
docker build -t functions/prometheus:2.7.0-armhf .
.PHONY: ci-armhf-push
ci-armhf-push:
docker push functions/prometheus:2.7.0-armhf

View File

@ -1,13 +0,0 @@
# Prometheus for ARMHF
## Building:
```bash
make ci-armhf-build
```
## Pushing:
```bash
make ci-armhf-push
```

View File

@ -1,31 +0,0 @@
FROM alpine:3.8
WORKDIR /root/
RUN apk add --update libarchive-tools curl \
&& curl -sLf https://github.com/prometheus/prometheus/releases/download/v2.7.1/prometheus-2.7.1.linux-armv7.tar.gz > prometheus.tar.gz \
&& bsdtar -xvf prometheus.tar.gz -C ./ --strip-components=1 \
&& apk del libarchive-tools curl \
&& mkdir /etc/prometheus \
&& mkdir -p /usr/share/prometheus \
&& cp prometheus /bin/prometheus \
&& cp promtool /bin/promtool \
&& cp prometheus.yml /etc/prometheus/ \
&& cp -r console_libraries /usr/share/prometheus/ \
&& cp -r consoles /usr/share/prometheus/ \
&& rm -rf /root/*
RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/
RUN mkdir -p /prometheus && \
chown -R nobody:nogroup /etc/prometheus /prometheus
USER nobody
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles" ]

View File

@ -1,10 +0,0 @@
.PHONY: all
all: ci-armhf-build ci-armhf-push
.PHONY: ci-armhf-build
ci-armhf-build:
docker build -t functions/prometheus:2.7.1-armhf .
.PHONY: ci-armhf-push
ci-armhf-push:
docker push functions/prometheus:2.7.1-armhf

View File

@ -1,13 +0,0 @@
# Prometheus for ARMHF
## Building:
```bash
make ci-armhf-build
```
## Pushing:
```bash
make ci-armhf-push
```

View File

@ -3,7 +3,7 @@
# "openfaas/nats-queue-worker"
# ^ Already multi-arch
declare -a repos=("openfaas/faas-idler" "openfaas/faas" "openfaas/faas-cli" "openfaas/faas-swarm")
declare -a repos=("openfaas/faas")
HERE=`pwd`
ARCH=$(uname -m)

View File

@ -1,15 +0,0 @@
### Debug information
This is a useful Prometheus query to show:
* Service replicas
* Rate of invocation
* Execution time of events
http://localhost:9090/graph?g0.range_input=15m&g0.expr=gateway_service_count&g0.tab=0&g1.range_input=15m&g1.expr=rate(gateway_function_invocation_total%5B20s%5D)&g1.tab=0&g2.range_input=15m&g2.expr=gateway_functions_seconds_sum+%2F+gateway_functions_seconds_count&g2.tab=0
```
$ docker service ls -q |xargs -n 1 -I {} docker service scale {}=10;docker service scale func_gateway=1 ;
$ docker service scale func_prometheus=1 ; docker service scale func_alertmanager=1
```

View File

@ -1,95 +0,0 @@
#!ps1
param (
[switch] $noAuth,
[switch] $noHash,
[switch] $n,
[switch] $help,
[switch] $h
)
if ($help -Or $h) {
Write-Host "Usage: "
Write-Host " [default]`tdeploy the OpenFaaS core services"
Write-Host " -noAuth [-n]`tdisable basic authentication"
Write-Host " -noHash`tprevents the password from being hashed (optional)"
Write-Host " -help [-h]`tdisplays this screen"
Exit
}
if (Get-Command docker -errorAction SilentlyContinue)
{
docker node ls 2>&1 | out-null
if(-Not $?)
{
throw "Docker not in swarm mode, please initialise the cluster (`docker swarm init`) and retry"
}
# AE: would be nice to avoid this dependency.
Add-Type -AssemblyName System.Web
$password = [System.Web.Security.Membership]::GeneratePassword(24,5)
$secret = ""
if (-Not $noHash)
{
$sha256 = [System.Security.Cryptography.HashAlgorithm]::Create('sha256')
$hash = $sha256.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($password))
$secret = [System.BitConverter]::ToString($hash).Replace('-', '').toLower()
} else {
$secret =$password
}
$user = 'admin'
Write-Host "Attempting to create credentials for gateway.."
$user_secret = "basic-auth-user"
docker secret inspect $user_secret 2>&1 | out-null
if($?)
{
Write-Host "$user_secret secret exists"
}
else
{
$user | docker secret create $user_secret - | out-null
}
$password_secret = "basic-auth-password"
docker secret inspect $password_secret 2>&1 | out-null
if($?)
{
Write-Host "$password_secret secret exists"
}
else
{
$secret | docker secret create $password_secret - | out-null
Write-Host "[Credentials]"
Write-Host " username: admin"
Write-Host " password: $secret"
Write-Host " Write-Output `"$secret`" | faas-cli login --username=$user --password-stdin"
}
if ($noAuth -Or $n) {
Write-Host ""
Write-Host "Disabling basic authentication for gateway.."
Write-Host ""
$env:BASIC_AUTH="false";
$env:AUTH_URL=""
}
else
{
Write-Host ""
Write-Host "Enabling basic authentication for gateway.."
Write-Host ""
$env:BASIC_AUTH="true";
$env:AUTH_URL="http://basic-auth-plugin:8080/validate"
}
Write-Host "Deploying OpenFaaS core services"
docker stack deploy func --compose-file ./docker-compose.yml
}
else
{
throw "Unable to find docker command, please install Docker (https://www.docker.com/) and retry"
}

View File

@ -1,68 +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
export BASIC_AUTH="true"
export AUTH_URL="http://basic-auth-plugin:8080/validate"
sha_cmd="shasum -a 256"
if ! command -v shasum >/dev/null; then
sha_cmd="sha256sum"
fi
while [ ! $# -eq 0 ]
do
case "$1" in
--no-auth | -n)
export BASIC_AUTH="false"
export AUTH_URL=""
;;
--help | -h)
printf "Usage: \n [default]\tdeploy the OpenFaaS core services\n --no-auth [-n]\tdisable basic authentication.\n --help\tdisplays this screen"
exit
;;
esac
shift
done
# Secrets should be created even if basic-auth is disabled.
echo "Attempting to create credentials for gateway.."
echo "admin" | docker secret create basic-auth-user -
secret=$(head -c 16 /dev/urandom| $sha_cmd | cut -d " " -f 1)
echo "$secret" | docker secret create basic-auth-password -
if [ $? = 0 ];
then
printf "[Credentials]\n username: admin \n password: $secret\n echo -n ""$secret"" | faas-cli login --username=admin --password-stdin"
else
printf "[Credentials]\n already exist, not creating"
fi
if [ $BASIC_AUTH = "true" ];
then
echo ""
echo "Enabling basic authentication for gateway.."
echo ""
else
echo ""
echo "Disabling basic authentication for gateway.."
echo ""
fi
arch=$(uname -m)
case "$arch" in
"armv7l") echo "Deploying OpenFaaS core services for ARM"
composefile="docker-compose.armhf.yml"
;;
"aarch64") echo "Deploying OpenFaaS core services for ARM64"
composefile="docker-compose.arm64.yml"
;;
*) echo "Deploying OpenFaaS core services"
composefile="docker-compose.yml"
;;
esac
docker stack deploy func --compose-file $composefile

View File

@ -1,232 +0,0 @@
version: "3.3"
services:
gateway:
ports:
- 8080:8080
image: openfaas/gateway:0.18.18-arm64
networks:
- functions
environment:
functions_provider_url: "http://faas-swarm:8080/"
read_timeout: "5m5s" # Maximum time to read HTTP request
write_timeout: "5m5s" # Maximum time to write HTTP response
upstream_timeout: "5m" # Maximum duration of upstream function call - should be more than read_timeout and write_timeout
dnsrr: "true" # Temporarily use dnsrr in place of VIP while issue persists on PWD
faas_nats_address: "nats"
faas_nats_port: 4222
direct_functions: "true" # Functions are invoked directly over the overlay network
direct_functions_suffix: ""
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
scale_from_zero: "true" # Enable if you want functions to scale from 0/0 to min replica count upon invoke
max_idle_conns: 1024
max_idle_conns_per_host: 1024
auth_proxy_url: "${AUTH_URL:-}"
auth_proxy_pass_body: "false"
deploy:
resources:
# limits: # Enable if you want to limit memory usage
# memory: 200M
reservations:
memory: 100M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
placement:
constraints:
- "node.platform.os == linux"
secrets:
- basic-auth-user
- basic-auth-password
# auth service provide basic-auth plugin for system APIs
basic-auth-plugin:
image: openfaas/basic-auth-plugin:0.18.18-arm64
networks:
- functions
environment:
secret_mount_path: "/run/secrets/"
user_filename: "basic-auth-user"
pass_filename: "basic-auth-password"
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
# limits: # Enable if you want to limit memory usage
# memory: 100M
reservations:
memory: 50M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
secrets:
- basic-auth-user
- basic-auth-password
# Docker Swarm provider
faas-swarm:
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
image: openfaas/faas-swarm:0.9.0-arm64
networks:
- functions
environment:
read_timeout: "5m5s" # set both here, and on your functions
write_timeout: "5m5s" # set both here, and on your functions
DOCKER_API_VERSION: "1.30"
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
# limits: # Enable if you want to limit memory usage
# memory: 100M
reservations:
memory: 100M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
secrets:
- basic-auth-user
- basic-auth-password
nats:
image: nats-streaming:0.17.0
# Uncomment the following port mappings if you wish to expose the
# NATS client and/or management ports you must also add `-m 8222` to the command
# 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: openfaas/queue-worker:0.11.2
networks:
- functions
environment:
max_inflight: "1"
ack_wait: "5m5s" # Max duration of any async task / request
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
gateway_invoke: "true"
faas_gateway_address: "gateway"
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"
secrets:
- basic-auth-user
- basic-auth-password
# End services
# Start monitoring
prometheus:
image: prom/prometheus:v2.11.0
environment:
no_proxy: "gateway"
configs:
- source: prometheus_config
target: /etc/prometheus/prometheus.yml
- source: prometheus_rules
target: /etc/prometheus/alert.rules.yml
command:
- "--config.file=/etc/prometheus/prometheus.yml"
# - '-storage.local.path=/prometheus'
ports:
- 9090:9090
networks:
- functions
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
limits:
memory: 500M
reservations:
memory: 200M
alertmanager:
image: prom/alertmanager:v0.18.0
environment:
no_proxy: "gateway"
command:
- "--config.file=/alertmanager.yml"
- "--storage.path=/alertmanager"
networks:
- functions
# Uncomment the following port mapping if you wish to expose the Prometheus
# Alertmanager UI.
# ports:
# - 9093:9093
deploy:
resources:
limits:
memory: 50M
reservations:
memory: 20M
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
configs:
- source: alertmanager_config
target: /alertmanager.yml
secrets:
- basic-auth-password
configs:
prometheus_config:
file: ./prometheus/prometheus.yml
prometheus_rules:
file: ./prometheus/alert.rules.yml
alertmanager_config:
file: ./prometheus/alertmanager.yml
networks:
functions:
driver: overlay
attachable: true
labels:
- "openfaas=true"
secrets:
basic-auth-user:
external: true
basic-auth-password:
external: true

View File

@ -1,232 +0,0 @@
version: "3.3"
services:
gateway:
ports:
- 8080:8080
image: openfaas/gateway:0.18.18-armhf
networks:
- functions
environment:
functions_provider_url: "http://faas-swarm:8080/"
read_timeout: "5m5s" # Maximum time to read HTTP request
write_timeout: "5m5s" # Maximum time to write HTTP response
upstream_timeout: "5m" # Maximum duration of upstream function call - should be more than read_timeout and write_timeout
dnsrr: "true" # Temporarily use dnsrr in place of VIP while issue persists on PWD
faas_nats_address: "nats"
faas_nats_port: 4222
direct_functions: "true" # Functions are invoked directly over the overlay network
direct_functions_suffix: ""
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
scale_from_zero: "true" # Enable if you want functions to scale from 0/0 to min replica count upon invoke
max_idle_conns: 1024
max_idle_conns_per_host: 1024
auth_proxy_url: "${AUTH_URL:-}"
auth_proxy_pass_body: "false"
deploy:
resources:
# limits: # Enable if you want to limit memory usage
# memory: 200M
reservations:
memory: 100M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
placement:
constraints:
- "node.platform.os == linux"
secrets:
- basic-auth-user
- basic-auth-password
# auth service provide basic-auth plugin for system APIs
basic-auth-plugin:
image: openfaas/basic-auth-plugin:0.18.18-armhf
networks:
- functions
environment:
secret_mount_path: "/run/secrets/"
user_filename: "basic-auth-user"
pass_filename: "basic-auth-password"
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
# limits: # Enable if you want to limit memory usage
# memory: 100M
reservations:
memory: 50M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
secrets:
- basic-auth-user
- basic-auth-password
# Docker Swarm provider
faas-swarm:
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
image: openfaas/faas-swarm:0.9.0-armhf
networks:
- functions
environment:
read_timeout: "5m5s" # set both here, and on your functions
write_timeout: "5m5s" # set both here, and on your functions
DOCKER_API_VERSION: "1.30"
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
# limits: # Enable if you want to limit memory usage
# memory: 100M
reservations:
memory: 100M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
secrets:
- basic-auth-user
- basic-auth-password
nats:
image: nats-streaming:0.17.0
# Uncomment the following port mappings if you wish to expose the
# NATS client and/or management ports you must also add `-m 8222` to the command
# 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: openfaas/queue-worker:0.11.2
networks:
- functions
environment:
max_inflight: "1"
ack_wait: "5m5s" # Max duration of any async task / request
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
gateway_invoke: "true"
faas_gateway_address: "gateway"
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"
secrets:
- basic-auth-user
- basic-auth-password
# End services
# Start monitoring
prometheus:
image: prom/prometheus:v2.11.0
environment:
no_proxy: "gateway"
configs:
- source: prometheus_config
target: /etc/prometheus/prometheus.yml
- source: prometheus_rules
target: /etc/prometheus/alert.rules.yml
command:
- "--config.file=/etc/prometheus/prometheus.yml"
# - '-storage.local.path=/prometheus'
ports:
- 9090:9090
networks:
- functions
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
limits:
memory: 500M
reservations:
memory: 200M
alertmanager:
image: prom/alertmanager:v0.18.0
environment:
no_proxy: "gateway"
command:
- "--config.file=/alertmanager.yml"
- "--storage.path=/alertmanager"
networks:
- functions
# Uncomment the following port mapping if you wish to expose the Prometheus
# Alertmanager UI.
# ports:
# - 9093:9093
deploy:
resources:
limits:
memory: 50M
reservations:
memory: 20M
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
configs:
- source: alertmanager_config
target: /alertmanager.yml
secrets:
- basic-auth-password
configs:
prometheus_config:
file: ./prometheus/prometheus.yml
prometheus_rules:
file: ./prometheus/alert.rules.yml
alertmanager_config:
file: ./prometheus/alertmanager.yml
networks:
functions:
driver: overlay
attachable: true
labels:
- "openfaas=true"
secrets:
basic-auth-user:
external: true
basic-auth-password:
external: true

View File

@ -1,232 +0,0 @@
version: "3.3"
services:
gateway:
ports:
- 8080:8080
image: openfaas/gateway:0.18.18
networks:
- functions
environment:
functions_provider_url: "http://faas-swarm:8080/"
read_timeout: "5m5s" # Maximum time to read HTTP request
write_timeout: "5m5s" # Maximum time to write HTTP response
upstream_timeout: "5m" # Maximum duration of upstream function call - should be more than read_timeout and write_timeout
dnsrr: "true" # Temporarily use dnsrr in place of VIP while issue persists on PWD
faas_nats_address: "nats"
faas_nats_port: 4222
direct_functions: "true" # Functions are invoked directly over the overlay network
direct_functions_suffix: ""
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
scale_from_zero: "true" # Enable if you want functions to scale from 0/0 to min replica count upon invoke
max_idle_conns: 1024
max_idle_conns_per_host: 1024
auth_proxy_url: "${AUTH_URL:-}"
auth_proxy_pass_body: "false"
deploy:
resources:
# limits: # Enable if you want to limit memory usage
# memory: 200M
reservations:
memory: 100M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
placement:
constraints:
- "node.platform.os == linux"
secrets:
- basic-auth-user
- basic-auth-password
# auth service provide basic-auth plugin for system APIs
basic-auth-plugin:
image: openfaas/basic-auth-plugin:0.18.18
networks:
- functions
environment:
secret_mount_path: "/run/secrets/"
user_filename: "basic-auth-user"
pass_filename: "basic-auth-password"
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
# limits: # Enable if you want to limit memory usage
# memory: 100M
reservations:
memory: 50M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
secrets:
- basic-auth-user
- basic-auth-password
# Docker Swarm provider
faas-swarm:
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
image: openfaas/faas-swarm:0.9.0
networks:
- functions
environment:
read_timeout: "5m5s" # set both here, and on your functions
write_timeout: "5m5s" # set both here, and on your functions
DOCKER_API_VERSION: "1.30"
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
# limits: # Enable if you want to limit memory usage
# memory: 100M
reservations:
memory: 100M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 20
window: 380s
secrets:
- basic-auth-user
- basic-auth-password
nats:
image: nats-streaming:0.17.0
# Uncomment the following port mappings if you wish to expose the
# NATS client and/or management ports you must also add `-m 8222` to the command
# 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: openfaas/queue-worker:0.11.2
networks:
- functions
environment:
max_inflight: "1"
ack_wait: "5m5s" # Max duration of any async task / request
basic_auth: "${BASIC_AUTH:-false}"
secret_mount_path: "/run/secrets/"
gateway_invoke: "true"
faas_gateway_address: "gateway"
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"
secrets:
- basic-auth-user
- basic-auth-password
# End services
# Start monitoring
prometheus:
image: prom/prometheus:v2.11.0
environment:
no_proxy: "gateway"
configs:
- source: prometheus_config
target: /etc/prometheus/prometheus.yml
- source: prometheus_rules
target: /etc/prometheus/alert.rules.yml
command:
- "--config.file=/etc/prometheus/prometheus.yml"
# - '-storage.local.path=/prometheus'
ports:
- 9090:9090
networks:
- functions
deploy:
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
resources:
limits:
memory: 500M
reservations:
memory: 200M
alertmanager:
image: prom/alertmanager:v0.18.0
environment:
no_proxy: "gateway"
command:
- "--config.file=/alertmanager.yml"
- "--storage.path=/alertmanager"
networks:
- functions
# Uncomment the following port mapping if you wish to expose the Prometheus
# Alertmanager UI.
# ports:
# - 9093:9093
deploy:
resources:
limits:
memory: 50M
reservations:
memory: 20M
placement:
constraints:
- "node.role == manager"
- "node.platform.os == linux"
configs:
- source: alertmanager_config
target: /alertmanager.yml
secrets:
- basic-auth-password
configs:
prometheus_config:
file: ./prometheus/prometheus.yml
prometheus_rules:
file: ./prometheus/alert.rules.yml
alertmanager_config:
file: ./prometheus/alertmanager.yml
networks:
functions:
driver: overlay
attachable: true
labels:
- "openfaas=true"
secrets:
basic-auth-user:
external: true
basic-auth-password:
external: true

View File

@ -94,7 +94,7 @@ func (e *Exporter) StartServiceWatcher(endpointURL url.URL, metricsOptions Metri
services := []types.FunctionStatus{}
// Providers like Docker Swarm for instance have no namespaces.
// Providers like faasd for instance have no namespaces.
if len(namespaces) == 0 {
services, err = e.getFunctions(endpointURL, e.FunctionNamespace)
if err != nil {

View File

@ -251,7 +251,7 @@ func (g *GatewayConfig) UseNATS() bool {
g.NATSAddress != nil
}
// UseExternalProvider decide whether to bypass built-in Docker Swarm engine
// UseExternalProvider is now required for all providers
func (g *GatewayConfig) UseExternalProvider() bool {
return g.FunctionsProviderURL != nil
}