From 922247644469305ad134bde4888e0c989584960b Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 24 Jul 2021 22:20:42 -0400 Subject: [PATCH] Expose it as a service. --- kubernetes/autoscale/k8s/autoscale.yaml | 14 +++++++++++++- kubernetes/autoscale/service/gunicorn.conf.py | 3 +-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/kubernetes/autoscale/k8s/autoscale.yaml b/kubernetes/autoscale/k8s/autoscale.yaml index cda317f..6d19918 100644 --- a/kubernetes/autoscale/k8s/autoscale.yaml +++ b/kubernetes/autoscale/k8s/autoscale.yaml @@ -4,7 +4,6 @@ metadata: name: autoscale-test namespace: default spec: - replicas: 3 selector: matchLabels: app: autoscale-test @@ -33,3 +32,16 @@ spec: requests: cpu: "250m" memory: "256Mi" +--- +apiVersion: v1 +kind: Service +metadata: + name: autoscale-test + namespace: default +spec: + selector: + app: autoscale-test + type: LoadBalancer + ports: + - port: 80 + targetPort: "http" diff --git a/kubernetes/autoscale/service/gunicorn.conf.py b/kubernetes/autoscale/service/gunicorn.conf.py index 0a4a199..984946b 100644 --- a/kubernetes/autoscale/service/gunicorn.conf.py +++ b/kubernetes/autoscale/service/gunicorn.conf.py @@ -1,10 +1,9 @@ -import multiprocessing import os env_port = int(os.environ.get("PORT", 8080)) bind = f"0.0.0.0:{env_port}" -workers = max(2, multiprocessing.cpu_count() * 2 + 1) +workers = int(os.environ.get("WORKERS", 8)) preload_app = True max_requests = 100 max_requests_jitter = 50