Skip to content

Commit b262562

Browse files
committed
Work-in-progress openfaas package
This works when run from within the package, but not outside. This is because we don't yet allow for embedding additional configuration files inside the package, or set the correct file path context when run from outside.
1 parent 4cd2f6a commit b262562

File tree

7 files changed

+290
-0
lines changed

7 files changed

+290
-0
lines changed
12 KB
Binary file not shown.
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
version: "3.3"
2+
services:
3+
gateway:
4+
ports:
5+
- ${ports.gateway}:8080
6+
image: openfaas/gateway:${versions.gateway}
7+
networks:
8+
- functions
9+
environment:
10+
functions_provider_url: "http://faas-swarm:8080/"
11+
read_timeout: "300s" # Maximum time to read HTTP request
12+
write_timeout: "300s" # Maximum time to write HTTP response
13+
upstream_timeout: "300s" # Maximum duration of upstream function call - should be more than read_timeout and write_timeout
14+
dnsrr: "true" # Temporarily use dnsrr in place of VIP while issue persists on PWD
15+
faas_nats_address: "nats"
16+
faas_nats_port: 4222
17+
direct_functions: "${direct_functions}" # Functions are invoked directly over the overlay network
18+
direct_functions_suffix: ""
19+
basic_auth: "${auth}"
20+
secret_mount_path: "/run/secrets/"
21+
scale_from_zero: "${scale_from_zero}"
22+
deploy:
23+
resources:
24+
# limits: # Enable if you want to limit memory usage
25+
# memory: 200M
26+
reservations:
27+
memory: 100M
28+
restart_policy:
29+
condition: on-failure
30+
delay: 5s
31+
max_attempts: 20
32+
window: 380s
33+
placement:
34+
constraints:
35+
- 'node.platform.os == linux'
36+
secrets:
37+
- basic-auth-user
38+
- basic-auth-password
39+
40+
faas-swarm:
41+
volumes:
42+
- "/var/run/docker.sock:/var/run/docker.sock"
43+
image: openfaas/faas-swarm:${versions.faas}
44+
networks:
45+
- functions
46+
environment:
47+
read_timeout: "300s" # set both here, and on your functions
48+
write_timeout: "300s" # set both here, and on your functions
49+
DOCKER_API_VERSION: "1.30"
50+
basic_auth: "${auth}"
51+
secret_mount_path: "/run/secrets/"
52+
deploy:
53+
placement:
54+
constraints:
55+
- 'node.role == manager'
56+
- 'node.platform.os == linux'
57+
resources:
58+
# limits: # Enable if you want to limit memory usage
59+
# memory: 100M
60+
reservations:
61+
memory: 100M
62+
restart_policy:
63+
condition: on-failure
64+
delay: 5s
65+
max_attempts: 20
66+
window: 380s
67+
secrets:
68+
- basic-auth-user
69+
- basic-auth-password
70+
71+
nats:
72+
image: nats-streaming:${versions.nats-streaming}
73+
# Uncomment the following port mappings if you wish to expose the
74+
# NATS client and/or management ports
75+
# ports:
76+
# - 4222:4222
77+
# - 8222:8222
78+
command: "--store memory --cluster_id faas-cluster"
79+
networks:
80+
- functions
81+
deploy:
82+
resources:
83+
limits:
84+
memory: 125M
85+
reservations:
86+
memory: 50M
87+
placement:
88+
constraints:
89+
- 'node.platform.os == linux'
90+
91+
queue-worker:
92+
image: openfaas/queue-worker:${versions.queue-worker}
93+
networks:
94+
- functions
95+
environment:
96+
max_inflight: "1"
97+
ack_wait: "300s" # Max duration of any async task / request
98+
basic_auth: "${auth}"
99+
secret_mount_path: "/run/secrets/"
100+
deploy:
101+
resources:
102+
limits:
103+
memory: 50M
104+
reservations:
105+
memory: 20M
106+
restart_policy:
107+
condition: on-failure
108+
delay: 5s
109+
max_attempts: 20
110+
window: 380s
111+
placement:
112+
constraints:
113+
- 'node.platform.os == linux'
114+
secrets:
115+
- basic-auth-user
116+
- basic-auth-password
117+
118+
prometheus:
119+
image: prom/prometheus:${versions.prometheus}
120+
environment:
121+
no_proxy: "gateway"
122+
configs:
123+
- source: prometheus_config
124+
target: /etc/prometheus/prometheus.yml
125+
- source: prometheus_rules
126+
target: /etc/prometheus/alert.rules.yml
127+
command:
128+
- '--config.file=/etc/prometheus/prometheus.yml'
129+
ports:
130+
- ${ports.prometheus}:9090
131+
networks:
132+
- functions
133+
deploy:
134+
placement:
135+
constraints:
136+
- 'node.role == manager'
137+
- 'node.platform.os == linux'
138+
resources:
139+
limits:
140+
memory: 500M
141+
reservations:
142+
memory: 200M
143+
144+
alertmanager:
145+
image: prom/alertmanager:${versions.alertmanager}
146+
environment:
147+
no_proxy: "gateway"
148+
command:
149+
- '--config.file=/alertmanager.yml'
150+
- '--storage.path=/alertmanager'
151+
networks:
152+
- functions
153+
ports:
154+
- ${ports.alertmanager}:9093
155+
deploy:
156+
resources:
157+
limits:
158+
memory: 50M
159+
reservations:
160+
memory: 20M
161+
placement:
162+
constraints:
163+
- 'node.role == manager'
164+
- 'node.platform.os == linux'
165+
configs:
166+
- source: alertmanager_config
167+
target: /alertmanager.yml
168+
169+
170+
configs:
171+
prometheus_config:
172+
file: ./prometheus/prometheus.yml
173+
prometheus_rules:
174+
file: ./prometheus/alert.rules.yml
175+
alertmanager_config:
176+
file: ./prometheus/alertmanager.yml
177+
178+
networks:
179+
functions:
180+
driver: overlay
181+
attachable: true
182+
labels:
183+
- "openfaas=true"
184+
185+
secrets:
186+
basic-auth-user:
187+
external: true
188+
basic-auth-password:
189+
external: true

openfaas.dockerapp/metadata.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 0.1.0
2+
name: openfaas
3+
description: Severless functions made simple
4+
namespace: garethr
5+
maintainers:
6+
- name: gareth rushgrove
7+
email: gareth@morethanseven.net
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
groups:
2+
- name: prometheus/alert.rules
3+
rules:
4+
- alert: service_down
5+
expr: up == 0
6+
- alert: APIHighInvocationRate
7+
expr: sum(rate(gateway_function_invocation_total{code="200"}[10s])) BY (function_name) > 5
8+
for: 5s
9+
labels:
10+
service: gateway
11+
severity: major
12+
value: '{{$value}}'
13+
annotations:
14+
description: High invocation total on {{ $labels.instance }}
15+
summary: High invocation total on {{ $labels.instance }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
route:
2+
group_by: ['alertname', 'cluster', 'service']
3+
group_wait: 5s
4+
group_interval: 10s
5+
repeat_interval: 30s
6+
receiver: scale-up
7+
routes:
8+
- match:
9+
service: gateway
10+
receiver: scale-up
11+
severity: major
12+
inhibit_rules:
13+
- source_match:
14+
severity: 'critical'
15+
target_match:
16+
severity: 'warning'
17+
equal: ['alertname', 'cluster', 'service']
18+
receivers:
19+
- name: 'scale-up'
20+
webhook_configs:
21+
- url: http://gateway:8080/system/alert
22+
send_resolved: true
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# my global config
2+
global:
3+
scrape_interval: 15s # By default, scrape targets every 15 seconds.
4+
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
5+
# scrape_timeout is set to the global default (10s).
6+
7+
# Attach these labels to any time series or alerts when communicating with
8+
# external systems (federation, remote storage, Alertmanager).
9+
external_labels:
10+
monitor: 'faas-monitor'
11+
12+
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
13+
rule_files:
14+
- 'alert.rules.yml'
15+
16+
17+
# A scrape configuration containing exactly one endpoint to scrape:
18+
# Here it's Prometheus itself.
19+
scrape_configs:
20+
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
21+
- job_name: 'prometheus'
22+
23+
# Override the global default and scrape targets from this job every 5 seconds.
24+
scrape_interval: 5s
25+
26+
# metrics_path defaults to '/metrics'
27+
# scheme defaults to 'http'.
28+
static_configs:
29+
- targets: ['localhost:9090']
30+
31+
- job_name: "gateway"
32+
scrape_interval: 5s
33+
dns_sd_configs:
34+
- names: ['tasks.gateway']
35+
port: 8080
36+
type: A
37+
refresh_interval: 5s
38+
39+
alerting:
40+
alertmanagers:
41+
- static_configs:
42+
- targets:
43+
- alertmanager:9093

openfaas.dockerapp/settings.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
auth: true
2+
scale_from_zero: false
3+
direct_functions: true
4+
ports:
5+
gateway: 8080
6+
prometheus: 9090
7+
alertmanager: 9093
8+
versions:
9+
gateway: 0.9.2
10+
faas: 0.4.2
11+
nats-streaming: 0.6.0
12+
queue-worker: 0.5.2
13+
prometheus: v2.3.1
14+
alertmanager: v0.15.0

0 commit comments

Comments
 (0)