From e456a5fdb8593e913741cd0fe1e3172e7488d151 Mon Sep 17 00:00:00 2001 From: Bo Guan Date: Tue, 3 Dec 2024 22:12:10 -0600 Subject: [PATCH 1/4] add keda jmx --- distributed-databases/trino/addons.tf | 18 +++++- .../trino/examples/hive-setup.sh | 2 +- .../kube-prometheus-amp-enable.yaml | 1 + .../trino/helm-values/trino.yaml | 57 ++++++++++++++++++- distributed-databases/trino/trino-keda.yaml | 42 ++++++++++++++ distributed-databases/trino/trino.tf | 18 +++++- distributed-databases/trino/variables.tf | 2 +- distributed-databases/trino/versions.tf | 2 +- 8 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 distributed-databases/trino/trino-keda.yaml diff --git a/distributed-databases/trino/addons.tf b/distributed-databases/trino/addons.tf index 9bacb9749..3b8e25e0d 100644 --- a/distributed-databases/trino/addons.tf +++ b/distributed-databases/trino/addons.tf @@ -123,7 +123,12 @@ module "eks_blueprints_addons" { # Adding AWS Load Balancer Controller #--------------------------------------- enable_aws_load_balancer_controller = true - + aws_load_balancer_controller = { + set = [{ + name = "enableServiceMutatorWebhook" + value = "false" + }] + } #--------------------------------------- # AWS for FluentBit - DaemonSet @@ -176,6 +181,17 @@ module "eks_blueprints_addons" { ], } + helm_releases = { + keda = { + chart = "keda" + chart_version = "2.16.0" + repository = "https://kedacore.github.io/charts" + description = "Keda helm Chart deployment" + namespace = "keda" + create_namespace = true + } + } + tags = local.tags } diff --git a/distributed-databases/trino/examples/hive-setup.sh b/distributed-databases/trino/examples/hive-setup.sh index 47e72d9d6..4fa98f215 100755 --- a/distributed-databases/trino/examples/hive-setup.sh +++ b/distributed-databases/trino/examples/hive-setup.sh @@ -10,7 +10,7 @@ echo "The name of your bucket is: ${BUCKET}" echo "Now copying the 2022 NY Taxi data into the S3 bucket..." ## Copy the 2022 NY Taxi data into the S3 bucket -aws s3 cp "s3://nyc-tlc/trip data/" s3://$BUCKET/hive/ --exclude "*" --include "yellow_tripdata_2022*" --recursive +aws s3 cp "s3://aws-data-analytics-workshops/shared_datasets/tripdata/" s3://$BUCKET/hive/ --recursive sleep 2 echo "Now we create the Glue Database..." diff --git a/distributed-databases/trino/helm-values/kube-prometheus-amp-enable.yaml b/distributed-databases/trino/helm-values/kube-prometheus-amp-enable.yaml index fbdc3e07b..2e9e77763 100644 --- a/distributed-databases/trino/helm-values/kube-prometheus-amp-enable.yaml +++ b/distributed-databases/trino/helm-values/kube-prometheus-amp-enable.yaml @@ -28,6 +28,7 @@ prometheus: resources: requests: storage: 50Gi + serviceMonitorSelectorNilUsesHelmValues: false alertmanager: enabled: false diff --git a/distributed-databases/trino/helm-values/trino.yaml b/distributed-databases/trino/helm-values/trino.yaml index 823a8fe89..74d679579 100644 --- a/distributed-databases/trino/helm-values/trino.yaml +++ b/distributed-databases/trino/helm-values/trino.yaml @@ -1,11 +1,15 @@ image: - tag: "427" + repository: trinodb/trino + tag: 447 + pullPolicy: IfNotPresent server: workers: 3 exchangeManager: + name: filesystem baseDir: "s3://${exchange_bucket_id}" autoscaling: - enabled: true + enabled: false + minReplicas: 1 maxReplicas: 20 targetCPUUtilizationPercentage: 70 config: @@ -73,7 +77,7 @@ ingress: annotations: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/target-type: ip - alb.ingress.kubernetes.io/scheme: internet-facing + alb.ingress.kubernetes.io/scheme: internal hosts: - paths: - path: / @@ -83,3 +87,50 @@ ingress: name: trino port: number: 8080 +jmx: + enabled: true + registryPort: 9080 + serverPort: 9081 + exporter: + # jmx.exporter.enabled -- Set to true to export JMX Metrics via HTTP for [Prometheus](https://github.com/prometheus/jmx_exporter) consumption + enabled: true + image: bitnami/jmx-exporter:latest + pullPolicy: Always + port: 5556 + configProperties: |- + hostPort: localhost:{{- .Values.jmx.registryPort }} + startDelaySeconds: 0 + ssl: false + lowercaseOutputName: false + lowercaseOutputLabelNames: false + whitelistObjectNames: ["trino.execution:name=QueryManager","trino.execution:name=SqlTaskManager","trino.execution.executor:name=TaskExecutor","trino.memory:name=ClusterMemoryManager","java.lang:type=Runtime","trino.memory:type=ClusterMemoryPool,name=general","java.lang:type=Memory","trino.memory:type=MemoryPool,name=general"] + autoExcludeObjectNameAttributes: true + excludeObjectNameAttributes: + "java.lang:type=OperatingSystem": + - "ObjectName" + "java.lang:type=Runtime": + - "ClassPath" + - "SystemProperties" + rules: + - pattern: ".*" + resources: + limits: + cpu: 200m + memory: 512Mi + requests: + cpu: 200m + memory: 512Mi + +serviceMonitor: + enabled: true + labels: + prometheus: kube-prometheus + interval: "30s" + coordinator: + enabled: true + labels: + prometheus: kube-prometheus + worker: + enabled: true + labels: + prometheus: kube-prometheus diff --git a/distributed-databases/trino/trino-keda.yaml b/distributed-databases/trino/trino-keda.yaml new file mode 100644 index 000000000..60e05fa04 --- /dev/null +++ b/distributed-databases/trino/trino-keda.yaml @@ -0,0 +1,42 @@ +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: keda-scaler-trino-worker + namespace: ${trino_namespace} +spec: + scaleTargetRef: + name: trino-worker + minReplicaCount: 3 + maxReplicaCount: 15 + pollingInterval: 30 # Seconds + cooldownPeriod: 600 # Seconds + fallback: + failureThreshold: 3 + replicas: 6 + advanced: + horizontalPodAutoscalerConfig: + behavior: + scaleDown: + stabilizationWindowSeconds: 600 + policies: + - type: Pods + value: 1 + periodSeconds: 300 + scaleUp: + stabilizationWindowSeconds: 0 + policies: + - type: Pods + value: 1 + periodSeconds: 120 + triggers: + - type: cpu + metricType: Utilization + metadata: + value: '80' # Target CPU utilization percentage + - type: prometheus + metricType: Value + metadata: + serverAddress: http://kube-prometheus-stack-prometheus.kube-prometheus-stack.svc.cluster.local:9090 + threshold: '1' + metricName: queued_queries + query: sum by (job) (avg_over_time(trino_execution_QueryManager_QueuedQueries{job="trino"}[1m])) \ No newline at end of file diff --git a/distributed-databases/trino/trino.tf b/distributed-databases/trino/trino.tf index b654cf9c6..64c11362f 100644 --- a/distributed-databases/trino/trino.tf +++ b/distributed-databases/trino/trino.tf @@ -103,7 +103,7 @@ module "trino_addon" { version = "~> 1.1.1" #ensure to update this to the latest/desired version chart = "trino" - chart_version = "0.13.0" + chart_version = "0.34.0" repository = "https://trinodb.github.io/charts" description = "Trino Helm Chart deployment" namespace = local.trino_namespace @@ -140,3 +140,19 @@ module "trino_addon" { } } } + + +#--------------------------------------------------------------- +# KEDA ScaleObject - Trino Prometheus +#--------------------------------------------------------------- +resource "kubectl_manifest" "trino_keda" { + + yaml_body = templatefile("${path.module}/trino-keda.yaml", { + trino_namespace = local.trino_namespace + }) + + depends_on = [ + module.eks_blueprints_addons, + module.trino_addon + ] +} diff --git a/distributed-databases/trino/variables.tf b/distributed-databases/trino/variables.tf index d71add981..9cc05494f 100644 --- a/distributed-databases/trino/variables.tf +++ b/distributed-databases/trino/variables.tf @@ -25,5 +25,5 @@ variable "vpc_cidr" { variable "enable_amazon_prometheus" { description = "Enable AWS Managed Prometheus service" type = bool - default = false + default = true } diff --git a/distributed-databases/trino/versions.tf b/distributed-databases/trino/versions.tf index 97d5d2c31..fddc73c60 100644 --- a/distributed-databases/trino/versions.tf +++ b/distributed-databases/trino/versions.tf @@ -20,7 +20,7 @@ terraform { } random = { source = "hashicorp/random" - version = "3.4.3" + version = ">=3.6.0" } } From f1dde84fc3fd5f2230f0eaedca217de6a75a78f0 Mon Sep 17 00:00:00 2001 From: Bo Guan Date: Wed, 4 Dec 2024 10:44:29 -0600 Subject: [PATCH 2/4] merge --- distributed-databases/trino/trino.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/distributed-databases/trino/trino.tf b/distributed-databases/trino/trino.tf index 804d1cf2e..a37c06f63 100644 --- a/distributed-databases/trino/trino.tf +++ b/distributed-databases/trino/trino.tf @@ -149,6 +149,10 @@ resource "aws_iam_policy" "trino_exchange_bucket_policy" { # Trino Helm Add-on #--------------------------------------- module "trino_addon" { + depends_on = [ + module.eks_blueprints_addons, + ] + source = "aws-ia/eks-blueprints-addon/aws" version = "~> 1.1.1" #ensure to update this to the latest/desired version From 94ae9f35fe98863f87f7a8cb585b0f2affeba01a Mon Sep 17 00:00:00 2001 From: Bo Guan Date: Wed, 4 Dec 2024 10:56:47 -0600 Subject: [PATCH 3/4] pre-commit --- distributed-databases/trino/addons.tf | 12 ++++++------ distributed-databases/trino/helm-values/trino.yaml | 7 +++---- distributed-databases/trino/trino-keda.yaml | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/distributed-databases/trino/addons.tf b/distributed-databases/trino/addons.tf index fa7626286..1b8995f3b 100644 --- a/distributed-databases/trino/addons.tf +++ b/distributed-databases/trino/addons.tf @@ -155,12 +155,12 @@ module "eks_blueprints_addons" { helm_releases = { keda = { - chart = "keda" - chart_version = "2.16.0" - repository = "https://kedacore.github.io/charts" - description = "Keda helm Chart deployment" - namespace = "keda" - create_namespace = true + chart = "keda" + chart_version = "2.16.0" + repository = "https://kedacore.github.io/charts" + description = "Keda helm Chart deployment" + namespace = "keda" + create_namespace = true } } diff --git a/distributed-databases/trino/helm-values/trino.yaml b/distributed-databases/trino/helm-values/trino.yaml index 91e863b0a..2ba045fab 100644 --- a/distributed-databases/trino/helm-values/trino.yaml +++ b/distributed-databases/trino/helm-values/trino.yaml @@ -175,8 +175,8 @@ jmx: - "ClassPath" - "SystemProperties" rules: - - pattern: ".*" - resources: + - pattern: ".*" + resources: limits: cpu: 200m memory: 512Mi @@ -189,7 +189,7 @@ serviceMonitor: labels: prometheus: kube-prometheus interval: "30s" - coordinator: + coordinator: enabled: true labels: prometheus: kube-prometheus @@ -197,4 +197,3 @@ serviceMonitor: enabled: true labels: prometheus: kube-prometheus - diff --git a/distributed-databases/trino/trino-keda.yaml b/distributed-databases/trino/trino-keda.yaml index 60e05fa04..498e918bc 100644 --- a/distributed-databases/trino/trino-keda.yaml +++ b/distributed-databases/trino/trino-keda.yaml @@ -39,4 +39,4 @@ spec: serverAddress: http://kube-prometheus-stack-prometheus.kube-prometheus-stack.svc.cluster.local:9090 threshold: '1' metricName: queued_queries - query: sum by (job) (avg_over_time(trino_execution_QueryManager_QueuedQueries{job="trino"}[1m])) \ No newline at end of file + query: sum by (job) (avg_over_time(trino_execution_QueryManager_QueuedQueries{job="trino"}[1m])) From cc3608340b1662e2762bc7fd7e34b3a58f2d545a Mon Sep 17 00:00:00 2001 From: Ratnopam Charabarti Date: Thu, 19 Dec 2024 12:14:04 -0800 Subject: [PATCH 4/4] Update hive-setup.sh Add comments --- distributed-databases/trino/examples/hive-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distributed-databases/trino/examples/hive-setup.sh b/distributed-databases/trino/examples/hive-setup.sh index 4fa98f215..5a65ee022 100755 --- a/distributed-databases/trino/examples/hive-setup.sh +++ b/distributed-databases/trino/examples/hive-setup.sh @@ -7,9 +7,9 @@ export GLUE_DB_NAME=taxi_hive_database export CRAWLER_NAME=taxi-data-crawler echo "The name of your bucket is: ${BUCKET}" -echo "Now copying the 2022 NY Taxi data into the S3 bucket..." +echo "Now copying sample data into the S3 bucket..." -## Copy the 2022 NY Taxi data into the S3 bucket +## Copy sample data into the S3 bucket. Later on, we'd replace sample data with a more robust dataset. aws s3 cp "s3://aws-data-analytics-workshops/shared_datasets/tripdata/" s3://$BUCKET/hive/ --recursive sleep 2