helm安裝
#install helm repo add kedacore https://kedacore.github.io/charts #最新版 helm install keda kedacore/keda #本地安裝 helm install ./keda -f ./keda/values.yaml
設定ScaledObject
apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: app-demo spec: scaleTargetRef: deploymentName: app-demo pollingInterval: 15 # 可選。預設為 15 秒 cooldownPeriod: 300 # 可選。預設為 300 秒 (5 分鐘) maxReplicaCount: 10 triggers: - type: prometheus metadata: serverAddress: http://prometheus.monitoring:9090 metricName: http_requests_total threshold: "100"
檢查資源
kubectl get ScaledObject kubectl get deployment | grep keda-operator
promtheus設定
- job_name: 'app-demo' kubernetes_sd_configs: - role: pod relabel_configs: - source_labels: [ __meta_kubernetes_pod_name ] target_label: instance - source_labels: [ __meta_kubernetes_pod_container_port_number ] action: "keep" regex: "8081" - source_labels: [ __meta_kubernetes_namespace ] action: "keep" regex: "dev"
查詢metrics指標
壓測服務查看是否會Scale