diff --git a/charts/trino/templates/configmap-coordinator.yaml b/charts/trino/templates/configmap-coordinator.yaml index eaaf255b..a3080cd3 100644 --- a/charts/trino/templates/configmap-coordinator.yaml +++ b/charts/trino/templates/configmap-coordinator.yaml @@ -43,6 +43,9 @@ data: {{- range $configValue := .Values.coordinator.additionalJVMConfig }} {{ $configValue }} {{- end }} + {{- if .Values.jmx.enabled }} + -Dcom.sun.management.jmxremote.rmi.port={{ .Values.jmx.serverPort }} + {{- end }} config.properties: | coordinator=true @@ -69,6 +72,10 @@ data: http-server.https.port={{ .Values.server.config.https.port }} http-server.https.keystore.path={{ .Values.server.config.https.keystore.path }} {{- end }} + {{- if .Values.jmx.enabled }} + jmx.rmiregistry.port={{ .Values.jmx.registryPort }} + jmx.rmiserver.port={{ .Values.jmx.serverPort }} + {{- end }} {{- if .Values.server.coordinatorExtraConfig }} {{- .Values.server.coordinatorExtraConfig | nindent 4 }} {{- end }} diff --git a/charts/trino/templates/configmap-jmx-exporter.yaml b/charts/trino/templates/configmap-jmx-exporter.yaml new file mode 100644 index 00000000..a66ef142 --- /dev/null +++ b/charts/trino/templates/configmap-jmx-exporter.yaml @@ -0,0 +1,13 @@ +{{- if .Values.jmx.exporter.enabled -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "trino.fullname" . }}-jmx-exporter-config + namespace: {{ .Release.Namespace }} + labels: + {{- include "trino.labels" . | nindent 4 }} + app.kubernetes.io/component: jmx +data: + jmx-exporter-config.yaml: |- + {{- .Values.jmx.exporter.configProperties | nindent 4 }} +{{- end }} diff --git a/charts/trino/templates/configmap-jmx.yaml b/charts/trino/templates/configmap-jmx.yaml new file mode 100644 index 00000000..40365902 --- /dev/null +++ b/charts/trino/templates/configmap-jmx.yaml @@ -0,0 +1,28 @@ +{{- if .Values.jmx.enabled -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "trino.fullname" }}-jmx-config + namespace: {{ .Release.Namespace }} + labels: + {{- include "trino.labels" . | nindent 4 }} + app.kubernetes.io/component: jmx +data: + jmx-config: | + {{- range $configValue := .Values.jmx.configProperties }} + {{- $configValue }} + {{- end }} + +# jmx-config.yaml: | +# startDelaySeconds: 0 +# hostPort: 127.0.0.1:9080 +# rules: +# - pattern: 'java.lang(\w+): (.*)' +# name: jmx_jvm_memory_HeapMemoryUsed_$1 +# help: "JVM heap memory $1" +# value: $2 +# type: GAUGE +# - pattern: 'trino.memory*' +# - pattern: 'trino.execution*' +# - pattern: 'iceberg*' +{{- end }} diff --git a/charts/trino/templates/deployment-coordinator.yaml b/charts/trino/templates/deployment-coordinator.yaml index 2ed54b69..3decfcd7 100644 --- a/charts/trino/templates/deployment-coordinator.yaml +++ b/charts/trino/templates/deployment-coordinator.yaml @@ -73,6 +73,11 @@ spec: path: group.db {{- end }} {{- end }} + {{- if .Values.jmx.exporter.enabled }} + - name: jmx-exporter-config-volume + configMap: + name: {{ template "trino.fullname" . }}-jmx-exporter-config + {{- end }} {{- range .Values.configMounts }} - name: {{ .name }} configMap: @@ -155,6 +160,19 @@ spec: - name: http containerPort: {{ .Values.service.port }} protocol: TCP + {{- if .Values.jmx.enabled }} + - name: jmx-registry + containerPort: {{ .Values.jmx.registryPort }} + protocol: TCP + - name: jmx-server + containerPort: {{ .Values.jmx.serverPort }} + protocol: TCP + {{- end }} + {{- if .Values.podMonitor.enabled }} + - name: jmx-exporter + containerPort: {{ .Values.jmx.exporter.port }} + protocol: TCP + {{- end }} {{- range $key, $value := .Values.coordinator.additionalExposedPorts }} - name: {{ $value.name }} containerPort: {{ $value.port }} @@ -181,6 +199,17 @@ spec: {{- toYaml .Values.coordinator.lifecycle | nindent 12 }} resources: {{- toYaml .Values.coordinator.resources | nindent 12 }} + {{- if .Values.jmx.exporter.enabled }} + - name: jmx-exporter + image: {{ .Values.jmx.exporter.image }} + imagePullPolicy: {{ .Values.jmx.exporter.pullPolicy }} + args: + - "{{ .Values.jmx.exporter.port }}" + - /etc/jmx-exporter/jmx-exporter-config.yaml + volumeMounts: + - mountPath: /etc/jmx-exporter/ + name: jmx-exporter-config-volume + {{- end }} {{- if .Values.sidecarContainers.coordinator }} {{- toYaml .Values.sidecarContainers.coordinator | nindent 8 }} {{- end }} diff --git a/charts/trino/templates/service.yaml b/charts/trino/templates/service.yaml index 687d6959..a3e7d6b2 100644 --- a/charts/trino/templates/service.yaml +++ b/charts/trino/templates/service.yaml @@ -14,6 +14,12 @@ spec: targetPort: http protocol: TCP name: http + {{- if .Values.jmx.exporter.enabled }} + - port: {{ .Values.jmx.exporter.port }} + targetPort: jmx-exporter + protocol: TCP + name: jmx-exporter + {{- end }} {{- range $key, $value := .Values.coordinator.additionalExposedPorts }} - port: {{ $value.servicePort }} name: {{ $value.name }} diff --git a/charts/trino/templates/servicemonitor.yaml b/charts/trino/templates/servicemonitor.yaml new file mode 100644 index 00000000..55c5e820 --- /dev/null +++ b/charts/trino/templates/servicemonitor.yaml @@ -0,0 +1,21 @@ + +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "trino.fullname" . }} + labels: + {{- include "trino.labels" . | nindent 4 }} + {{- if .Values.serviceMonitor.selector }} + {{- toYaml .Values.serviceMonitor.selector | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "trino.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: coordinator + endpoints: + - port: jmx-exporter + path: {{ .Values.serviceMonitor.path }} + interval: {{ .Values.serviceMonitor.interval }} +{{- end }} \ No newline at end of file diff --git a/charts/trino/values.yaml b/charts/trino/values.yaml index 2a2c5a50..960099c4 100644 --- a/charts/trino/values.yaml +++ b/charts/trino/values.yaml @@ -727,6 +727,54 @@ kafka: # } # ``` +jmx: + # -- Set to true to enable the RMI server to expose Trino's [JMX metrics](https://trino.io/docs/current/admin/jmx.html). + enabled: false + 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: false + image: bitnami/jmx-exporter:latest + pullPolicy: Always + port: 5556 + configProperties: [] + # jmx.exporter.configProperties -- JMX Config Properties is mounted to /etc/jmx-exporter/jmx-exporter-config.yaml + # @raw + # Example: + # ```yaml + # configProperties: |- + # startDelaySeconds: 0 + # ssl: false + # lowercaseOutputName: false + # lowercaseOutputLabelNames: false + # includeObjectNames: ["java.lang:type=Threading"] + # autoExcludeObjectNameAttributes: true + # excludeObjectNameAttributes: + # "java.lang:type=OperatingSystem": + # - "ObjectName" + # "java.lang:type=Runtime": + # - "ClassPath" + # - "SystemProperties" + # rules: + # - pattern: 'java\.lang<(.*)>ThreadCount: (.*)' + # name: java_lang_Threading_ThreadCount + # value: '$2' + # help: 'ThreadCount (java.lang<>ThreadCount)' + # type: UNTYPED + +podMonitor: + # - podMonitor is a resource from prometheus-operator: + # https://github.com/prometheus-operator/prometheus-operator + enabled: false + # labels for podMonitor, so that Prometheus can select it + selector: + prometheus: kube-prometheus + # the podMonitor web endpoint path + path: /admin/metrics + # the podMonitor web endpoint interval + interval: "30s" + # -- Labels that get applied to every resource's metadata commonLabels: {}