Skip to content

Commit

Permalink
Add option to enable JMX exporter on workers
Browse files Browse the repository at this point in the history
  • Loading branch information
sdaberdaku committed Oct 2, 2024
1 parent 36a4833 commit fd8ba50
Show file tree
Hide file tree
Showing 14 changed files with 275 additions and 48 deletions.
44 changes: 44 additions & 0 deletions charts/trino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,30 @@ Fast distributed SQL query engine for big data analytics that helps you explore
cpu: 100m
memory: 128Mi
```
* `jmx.coordinator` - object, default: `{}`

Override JMX configurations for the Trino coordinator.
Example
```yaml
coordinator:
enabled: true
exporter:
enable: true
configProperties: |-
hostPort: localhost:{{- .Values.jmx.registryPort }}
startDelaySeconds: 0
ssl: false
```
* `jmx.worker` - object, default: `{}`

Override JMX configurations for the Trino workers.
Example
```yaml
worker:
enabled: true
exporter:
enable: true
```
* `serviceMonitor.enabled` - bool, default: `false`

Set to true to create resources for the [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator).
Expand All @@ -706,6 +730,26 @@ Fast distributed SQL query engine for big data analytics that helps you explore
* `serviceMonitor.interval` - string, default: `"30s"`

The serviceMonitor web endpoint interval
* `serviceMonitor.coordinator` - object, default: `{}`

Override ServiceMonitor configurations for the Trino coordinator.
Example
```yaml
coordinator:
enabled: true
labels:
prometheus: my-prometheus
```
* `serviceMonitor.worker` - object, default: `{}`

Override ServiceMonitor configurations for the Trino workers.
Example
```yaml
worker:
enabled: true
labels:
prometheus: my-prometheus
```
* `commonLabels` - object, default: `{}`

Labels that get applied to every resource's metadata
Expand Down
11 changes: 6 additions & 5 deletions charts/trino/templates/configmap-coordinator.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $coordinatorJmx := merge .Values.jmx.coordinator (omit .Values.jmx "coordinator" "worker") -}}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -43,8 +44,8 @@ data:
{{- range $configValue := .Values.coordinator.additionalJVMConfig }}
{{ $configValue }}
{{- end }}
{{- if .Values.jmx.enabled }}
-Dcom.sun.management.jmxremote.rmi.port={{ .Values.jmx.serverPort }}
{{- if $coordinatorJmx.enabled }}
-Dcom.sun.management.jmxremote.rmi.port={{- $coordinatorJmx.serverPort }}
{{- end }}

config.properties: |
Expand Down Expand Up @@ -72,9 +73,9 @@ 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 }}
{{- if $coordinatorJmx.enabled }}
jmx.rmiregistry.port={{- $coordinatorJmx.registryPort }}
jmx.rmiserver.port={{- $coordinatorJmx.serverPort }}
{{- end }}
{{- if .Values.server.coordinatorExtraConfig }}
{{- .Values.server.coordinatorExtraConfig | nindent 4 }}
Expand Down
22 changes: 19 additions & 3 deletions charts/trino/templates/configmap-jmx-exporter.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
{{- if .Values.jmx.exporter.enabled }}
{{- $coordinatorJmx := merge .Values.jmx.coordinator (omit .Values.jmx "coordinator" "worker") -}}
{{- if $coordinatorJmx.exporter.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "trino.fullname" . }}-jmx-exporter-config
name: {{ template "trino.fullname" . }}-jmx-exporter-config-coordinator
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: jmx
data:
jmx-exporter-config.yaml: |-
{{- tpl .Values.jmx.exporter.configProperties . | nindent 4 }}
{{- tpl $coordinatorJmx.exporter.configProperties . | nindent 4 }}
{{- end }}
{{- $workerJmx := merge .Values.jmx.worker (omit .Values.jmx "coordinator" "worker") -}}
{{- if $workerJmx.exporter.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "trino.fullname" . }}-jmx-exporter-config-worker
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: jmx
data:
jmx-exporter-config.yaml: |-
{{- tpl $workerJmx.exporter.configProperties . | nindent 4 }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/trino/templates/configmap-worker.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $workerJmx := merge .Values.jmx.worker (omit .Values.jmx "coordinator" "worker") -}}
{{- if gt (int .Values.server.workers) 0 }}
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -44,6 +45,9 @@ data:
{{- range $configValue := .Values.worker.additionalJVMConfig }}
{{ $configValue }}
{{- end }}
{{- if $workerJmx.enabled }}
-Dcom.sun.management.jmxremote.rmi.port={{- $workerJmx.serverPort }}
{{- end }}

config.properties: |
coordinator=false
Expand All @@ -57,6 +61,10 @@ data:
{{- range $configValue := .Values.additionalConfigProperties }}
{{ $configValue }}
{{- end }}
{{- if $workerJmx.enabled }}
jmx.rmiregistry.port={{- $workerJmx.registryPort }}
jmx.rmiserver.port={{- $workerJmx.serverPort }}
{{- end }}
{{- if .Values.server.workerExtraConfig }}
{{- .Values.server.workerExtraConfig | nindent 4 }}
{{- end }}
Expand Down
33 changes: 13 additions & 20 deletions charts/trino/templates/deployment-coordinator.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $coordinatorJmx := merge .Values.jmx.coordinator (omit .Values.jmx "coordinator" "worker") -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -79,10 +80,10 @@ spec:
path: group.db
{{- end }}
{{- end }}
{{- if .Values.jmx.exporter.enabled }}
{{- if $coordinatorJmx.exporter.enabled }}
- name: jmx-exporter-config-volume
configMap:
name: {{ template "trino.fullname" . }}-jmx-exporter-config
name: {{ template "trino.fullname" . }}-jmx-exporter-config-coordinator
{{- end }}
{{- range .Values.configMounts }}
- name: {{ .name }}
Expand Down Expand Up @@ -168,16 +169,14 @@ spec:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- with .Values.jmx }}
{{- if .enabled }}
{{- if $coordinatorJmx.enabled }}
- name: jmx-registry
containerPort: {{ .registryPort }}
containerPort: {{ $coordinatorJmx.registryPort }}
protocol: TCP
- name: jmx-server
containerPort: {{ .serverPort }}
containerPort: {{ $coordinatorJmx.serverPort }}
protocol: TCP
{{- end }}
{{- end }}
{{- range $key, $value := .Values.coordinator.additionalExposedPorts }}
- name: {{ $value.name }}
containerPort: {{ $value.port }}
Expand All @@ -204,31 +203,25 @@ spec:
{{- toYaml .Values.coordinator.lifecycle | nindent 12 }}
resources:
{{- toYaml .Values.coordinator.resources | nindent 12 }}
{{- with .Values.jmx.exporter }}
{{- if .enabled }}
{{- if $coordinatorJmx.exporter.enabled }}
- name: jmx-exporter
image: {{ .image }}
imagePullPolicy: {{ .pullPolicy }}
{{- with .securityContext }}
image: {{ $coordinatorJmx.exporter.image }}
imagePullPolicy: {{ $coordinatorJmx.exporter.pullPolicy }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- toYaml $coordinatorJmx.exporter.securityContext | nindent 12 }}
args:
- "{{ .port }}"
- "{{ $coordinatorJmx.exporter.port }}"
- /etc/jmx-exporter/jmx-exporter-config.yaml
volumeMounts:
- mountPath: /etc/jmx-exporter/
name: jmx-exporter-config-volume
{{- with .resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- toYaml $coordinatorJmx.exporter.resources | nindent 12 }}
ports:
- name: jmx-exporter
containerPort: {{ .port }}
containerPort: {{ $coordinatorJmx.exporter.port }}
protocol: TCP
{{- end }}
{{- end }}
{{- if .Values.sidecarContainers.coordinator }}
{{- toYaml .Values.sidecarContainers.coordinator | nindent 8 }}
{{- end }}
Expand Down
33 changes: 33 additions & 0 deletions charts/trino/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $workerJmx := merge .Values.jmx.worker (omit .Values.jmx "coordinator" "worker") -}}
{{- if gt (int .Values.server.workers) 0 }}
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -55,6 +56,11 @@ spec:
- name: schemas-volume
configMap:
name: {{ template "trino.fullname" . }}-schemas-volume-worker
{{- if $workerJmx.exporter.enabled }}
- name: jmx-exporter-config-volume
configMap:
name: {{ template "trino.fullname" . }}-jmx-exporter-config-worker
{{- end }}
{{- range .Values.configMounts }}
- name: {{ .name }}
configMap:
Expand Down Expand Up @@ -127,6 +133,14 @@ spec:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if $workerJmx.enabled }}
- name: jmx-registry
containerPort: {{ $workerJmx.registryPort }}
protocol: TCP
- name: jmx-server
containerPort: {{ $workerJmx.serverPort }}
protocol: TCP
{{- end }}
{{- range $key, $value := .Values.worker.additionalExposedPorts }}
- name: {{ $value.name }}
containerPort: {{ $value.port }}
Expand All @@ -153,6 +167,25 @@ spec:
{{- toYaml .Values.worker.lifecycle | nindent 12 }}
resources:
{{- toYaml .Values.worker.resources | nindent 12 }}
{{- if $workerJmx.exporter.enabled }}
- name: jmx-exporter
image: {{ $workerJmx.exporter.image }}
imagePullPolicy: {{ $workerJmx.exporter.pullPolicy }}
securityContext:
{{- toYaml $workerJmx.exporter.securityContext | nindent 12 }}
args:
- "{{ $workerJmx.exporter.port }}"
- /etc/jmx-exporter/jmx-exporter-config.yaml
volumeMounts:
- mountPath: /etc/jmx-exporter/
name: jmx-exporter-config-volume
resources:
{{- toYaml $workerJmx.exporter.resources | nindent 12 }}
ports:
- name: jmx-exporter
containerPort: {{ $workerJmx.exporter.port }}
protocol: TCP
{{- end }}
{{- if .Values.sidecarContainers.worker }}
{{- toYaml .Values.sidecarContainers.worker | nindent 8 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{{- $coordinatorJmx := merge .Values.jmx.coordinator (omit .Values.jmx "coordinator" "worker") -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "trino.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: coordinator
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
spec:
Expand All @@ -17,8 +19,8 @@ spec:
{{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- if .Values.jmx.exporter.enabled }}
- port: {{ .Values.jmx.exporter.port }}
{{- if $coordinatorJmx.exporter.enabled }}
- port: {{ $coordinatorJmx.exporter.port }}
targetPort: jmx-exporter
protocol: TCP
name: jmx-exporter
Expand Down
27 changes: 27 additions & 0 deletions charts/trino/templates/service-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- $workerJmx := merge .Values.jmx.worker (omit .Values.jmx "coordinator" "worker") -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "trino.fullname" . }}-worker
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: worker
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
spec:
clusterIP: None
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
{{- if $workerJmx.exporter.enabled }}
- port: {{$workerJmx.exporter.port }}
targetPort: jmx-exporter
protocol: TCP
name: jmx-exporter
{{- end }}
selector:
{{- include "trino.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: worker
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{{- if .Values.serviceMonitor.enabled -}}
{{- $coordinatorServiceMonitor := merge .Values.serviceMonitor.coordinator (omit .Values.serviceMonitor "coordinator" "worker") -}}
{{- if $coordinatorServiceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "trino.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.labels }}
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
{{- if $coordinatorServiceMonitor.labels }}
{{- toYaml $coordinatorServiceMonitor.labels | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "trino.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: coordinator
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- port: jmx-exporter
interval: {{ .Values.serviceMonitor.interval }}
interval: {{ $coordinatorServiceMonitor.interval }}
{{- end }}
24 changes: 24 additions & 0 deletions charts/trino/templates/servicemonitor-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- $workerServiceMonitor := merge .Values.serviceMonitor.worker (omit .Values.serviceMonitor "coordinator" "worker") -}}
{{- if $workerServiceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "trino.fullname" . }}-worker
namespace: {{ .Release.Namespace }}
labels:
{{- include "trino.labels" . | nindent 4 }}
{{- if $workerServiceMonitor.labels }}
{{- toYaml $workerServiceMonitor.labels | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "trino.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: worker
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- port: jmx-exporter
interval: {{ $workerServiceMonitor.interval }}
{{- end }}
Loading

0 comments on commit fd8ba50

Please sign in to comment.