Skip to content

Commit db7c703

Browse files
weltekialexellis
authored andcommitted
Add optional HPA configuration example for the gateway
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
1 parent 6d4abef commit db7c703

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

docs/architecture/production.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,44 @@ It is recommended that you have high-availability for the OpenFaaS components in
4949

5050
* OpenFaaS gateway
5151

52-
For a production environment, we recommend a minimum of three replicas of the gateway. You can set an additional auto-scaling rule with HPAv2 if you have purchased additional licenses for that environment.
52+
For a production environment, we recommend a minimum of three replicas of the gateway.
5353

54-
By default, the OpenFaaS gateway includes a Topology Spread Constraints to ensure that replicas are spread across different nodes. This means that if a node were to be reclaimed or any reason, the gateway would still be available, since at least one replica would be running on another node.
54+
By default, the OpenFaaS gateway includes a Topology Spread Constraints to ensure that replicas are spread across different nodes. This means that if a node were to be reclaimed or any reason, the gateway would still be available, since at least one replica would be running on another node
55+
56+
Optionally, you can set an additional auto-scaling rule with HPAv2 to scale the gateway automatically based on CPU and memory usage. The percentage values are based upon the requests and limits set for the gateway pod, and should be tuned to suit your own workload:
57+
58+
```yaml
59+
# 50% CPU or 50% RAM is only a guide, and you need to
60+
# tune this to suit your own needs
61+
62+
# 3 replicas are required for HA
63+
64+
apiVersion: autoscaling/v2
65+
kind: HorizontalPodAutoscaler
66+
metadata:
67+
name: gateway-hpa
68+
namespace: openfaas
69+
spec:
70+
scaleTargetRef:
71+
apiVersion: apps/v1
72+
kind: Deployment
73+
name: gateway
74+
minReplicas: 3
75+
maxReplicas: 6
76+
metrics:
77+
- type: Resource
78+
resource:
79+
name: cpu
80+
target:
81+
type: Utilization
82+
averageUtilization: 50
83+
- type: Resource
84+
resource:
85+
name: memory
86+
target:
87+
type: Utilization
88+
averageUtilization: 50
89+
```
5590
5691
* OpenFaaS queue-worker
5792

0 commit comments

Comments
 (0)