diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-12-20 13:55:04 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-12-20 13:55:04 +0100 |
commit | 75a28c1819a4d14c7a3ffade5e164b441e44b36c (patch) | |
tree | 90fb5d867b13add57548f40efbb4333f182c12c4 | |
parent | 137c520f02c15bae932e06611268e6f5135ed42c (diff) |
Add networking and balancing
-rwxr-xr-x | run.sh | 2 | ||||
-rw-r--r-- | yaml/networking/balance.yaml | 37 | ||||
-rw-r--r-- | yaml/networking/ingress.yaml | 18 | ||||
-rw-r--r-- | yaml/services/cas.yaml | 2 |
4 files changed, 58 insertions, 1 deletions
@@ -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 |