From da6fe0b58122160201e4362de0cbd11979ffe69c Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Thu, 19 Oct 2023 14:44:16 +0300 Subject: [PATCH] apps: cluster1: kubernetes-dashboard: Scale to zero. --- .../httpscaledobject.yaml | 16 ++++++++ .../kubernetes-dashboard/kustomization.yaml | 2 + .../kubernetes-dashboard/scaledobject.yaml | 38 +++++++++++++++++++ .../cluster1/kubernetes-dashboard/values.yaml | 2 + 4 files changed, 58 insertions(+) create mode 100644 apps/cluster1/kubernetes-dashboard/httpscaledobject.yaml create mode 100644 apps/cluster1/kubernetes-dashboard/scaledobject.yaml diff --git a/apps/cluster1/kubernetes-dashboard/httpscaledobject.yaml b/apps/cluster1/kubernetes-dashboard/httpscaledobject.yaml new file mode 100644 index 000000000..83b16127e --- /dev/null +++ b/apps/cluster1/kubernetes-dashboard/httpscaledobject.yaml @@ -0,0 +1,16 @@ +kind: HTTPScaledObject +apiVersion: http.keda.sh/v1alpha1 +metadata: + name: kubernetes-dashboard-web +spec: + host: kubernetes-dashboard.home.wugi.info + # Optional. Default: 300 seconds. + # Should be smaller than kubernetes-dashboard-web-scaledobject. + scaledownPeriod: 150 + scaleTargetRef: + deployment: kubernetes-dashboard-web + service: kubernetes-dashboard-web + port: 8000 + replicas: + min: 0 + max: 1 diff --git a/apps/cluster1/kubernetes-dashboard/kustomization.yaml b/apps/cluster1/kubernetes-dashboard/kustomization.yaml index 607a7442b..5933e0295 100644 --- a/apps/cluster1/kubernetes-dashboard/kustomization.yaml +++ b/apps/cluster1/kubernetes-dashboard/kustomization.yaml @@ -3,6 +3,8 @@ kind: Kustomization namespace: kubernetes-dashboard resources: - ../../base/kubernetes-dashboard +- scaledobject.yaml +- httpscaledobject.yaml patchesStrategicMerge: - release.yaml configMapGenerator: diff --git a/apps/cluster1/kubernetes-dashboard/scaledobject.yaml b/apps/cluster1/kubernetes-dashboard/scaledobject.yaml new file mode 100644 index 000000000..494766810 --- /dev/null +++ b/apps/cluster1/kubernetes-dashboard/scaledobject.yaml @@ -0,0 +1,38 @@ +--- +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: kubernetes-dashboard-web-scaledobject +spec: + maxReplicaCount: 1 + minReplicaCount: 0 + pollingInterval: 3 # Optional. Default: 30 seconds + cooldownPeriod: 300 # Optional. Default: 300 seconds + scaleTargetRef: + name: kubernetes-dashboard-web + triggers: + - type: prometheus + metadata: + serverAddress: http://kube-prometheus-stack-prometheus.monitoring:9090 + metricName: nginx_ingress_controller_request_duration_seconds_count + threshold: "0.5" + query: max(irate(nginx_ingress_controller_request_duration_seconds_count{host="kubernetes-dashboard.home.wugi.info"}[5m])) +--- +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: kubernetes-dashboard-api-scaledobject +spec: + maxReplicaCount: 1 + minReplicaCount: 0 + pollingInterval: 3 # Optional. Default: 30 seconds + cooldownPeriod: 300 # Optional. Default: 300 seconds + scaleTargetRef: + name: kubernetes-dashboard-api + triggers: + - type: prometheus + metadata: + serverAddress: http://kube-prometheus-stack-prometheus.monitoring:9090 + metricName: nginx_ingress_controller_request_duration_seconds_count + threshold: "0.5" + query: max(irate(nginx_ingress_controller_request_duration_seconds_count{host="kubernetes-dashboard.home.wugi.info"}[5m])) diff --git a/apps/cluster1/kubernetes-dashboard/values.yaml b/apps/cluster1/kubernetes-dashboard/values.yaml index 2641d0e78..db2544018 100644 --- a/apps/cluster1/kubernetes-dashboard/values.yaml +++ b/apps/cluster1/kubernetes-dashboard/values.yaml @@ -1,6 +1,8 @@ # General configuration shared across resources app: ingress: + labels: + keda.cluster.local/scale-to-zero: "true" hosts: - kubernetes-dashboard.home.wugi.info settings: