summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2024-12-20 13:55:04 +0100
committerSanto Cariotti <santo@dcariotti.me>2024-12-20 13:55:04 +0100
commit75a28c1819a4d14c7a3ffade5e164b441e44b36c (patch)
tree90fb5d867b13add57548f40efbb4333f182c12c4
parent137c520f02c15bae932e06611268e6f5135ed42c (diff)
Add networking and balancing
-rwxr-xr-xrun.sh2
-rw-r--r--yaml/networking/balance.yaml37
-rw-r--r--yaml/networking/ingress.yaml18
-rw-r--r--yaml/services/cas.yaml2
4 files changed, 58 insertions, 1 deletions
diff --git a/run.sh b/run.sh
index 38bbdaa..96b33bc 100755
--- a/run.sh
+++ b/run.sh
@@ -27,6 +27,8 @@ YAML_FILES=(
"pvcs/pgdata.yaml"
"deployments/postgres.yaml"
"services/postgres.yaml"
+ "networking/ingress.yaml"
+ "networking/balance.yaml"
)
for file in "${YAML_FILES[@]}"; do
diff --git a/yaml/networking/balance.yaml b/yaml/networking/balance.yaml
new file mode 100644
index 0000000..dd0f17b
--- /dev/null
+++ b/yaml/networking/balance.yaml
@@ -0,0 +1,37 @@
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+ name: cas-hpa
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: cas-deployment
+ minReplicas: 1
+ maxReplicas: 10
+ metrics:
+ - type: Resource
+ resource:
+ name: cpu
+ target:
+ type: Utilization
+ averageUtilization: 70
+ - type: Resource
+ resource:
+ name: memory
+ target:
+ type: Utilization
+ averageUtilization: 80
+ behavior:
+ scaleUp:
+ stabilizationWindowSeconds: 60
+ policies:
+ - type: Percent
+ value: 100
+ periodSeconds: 15
+ scaleDown:
+ stabilizationWindowSeconds: 300
+ policies:
+ - type: Percent
+ value: 100
+ periodSeconds: 15
diff --git a/yaml/networking/ingress.yaml b/yaml/networking/ingress.yaml
new file mode 100644
index 0000000..4a0d31d
--- /dev/null
+++ b/yaml/networking/ingress.yaml
@@ -0,0 +1,18 @@
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: cas-ingress
+ annotations:
+ nginx.ingress.kubernetes.io/rewrite-target: /
+spec:
+ ingressClassName: nginx
+ rules:
+ - http:
+ paths:
+ - path: /
+ pathType: Prefix
+ backend:
+ service:
+ name: cas-service
+ port:
+ number: 80
diff --git a/yaml/services/cas.yaml b/yaml/services/cas.yaml
index ff1d8c5..bd30fe9 100644
--- a/yaml/services/cas.yaml
+++ b/yaml/services/cas.yaml
@@ -10,4 +10,4 @@ spec:
protocol: TCP
selector:
app: cas
- type: ClusterIP
+ type: LoadBalancer