[bitnami/tomcat] Add JMX metrics support (#7623)

* Update servicemonitor.yaml

Add template render for .Values.metrics.serviceMonitor.additionalLabels

* [bitnami/postgresql]

add template render for .Values.primary.extraVolumes

* [bitnami/postgresql]

Add template render for .Values.readReplicas.extraVolumes

* [bitnami/postgresql]

Update documentation about new value evaluated as a template (primary.extraVolumes, readReplicas.extraVolumes and metrics.serviceMonitor.additionalLabels).

* [bitnami/postgres]

Bump chart version

* [bitnami/zookeeper] Update ExtraVolumes as template render, add sidecar to POD and ZOO_LOG4J_PROP environment variables

* [bitnami/postgresql] Remove information (value evaluated as a template) from README.md

* [bitnami/zookeeper] Remove information to Readme, empty space at end of the line 294 bitnami/zookeeper/templates/statefulset.yaml and move comment on values

* [bitnami/zookeeper] Bump zookeeper chart version

* [bitnbami/zookeeper] Fix missnaming and nexw line on values and Fix README

* [bitnbami/postgresql] Fix README

* [bitnbami/postgresql] Fix README

* [bitnbami/postgresql] Bump postgresql version

* Update Chart.yaml

Include new line at the end of the file

* [bitnami/tomcat] Add JMX support on tomcat chart

* [bitnami/tomcat] Fix tomcat image to r10

* [bitnami/tomcat] Fix image ref

* [bitnami/tomcat] Fix Chart.yaml

* [bitnami/tomcat] Fix  metadata non existing key

* [bitnami/tomcat] Fix  metadata missing

* [bitnami/tomcat] Fix trailing-spaces

* [bitnami/tomcat] Fix trailing-spaces

* [bitnami/tomcat] Fix requested changes

* [bitnami/tomcat] Fix requested changes

* [bitnami/tomcat] Bump version

* Update bitnami/tomcat/templates/podmonitor.yaml

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* Update bitnami/tomcat/templates/podmonitor.yaml

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* Update bitnami/tomcat/templates/podmonitor.yaml

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* [bitnami/tomcat]

remove unnecessary --- at begining

* Update bitnami/tomcat/Chart.yaml

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* [bitnami/tomcat] update requested change

* [bitnami/tomcat] Add validationValues function

* [bitnami/tomcat] Update bitnami/tomcat/templates/_pod.tpl

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* [bitnami/tomcat] Bump version

* Update bitnami/tomcat/Chart.yaml

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* [bitnami/tomcat]

Remove empty line

* Update bitnami/tomcat/templates/_helpers.tpl

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* Update bitnami/tomcat/templates/_helpers.tpl

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

* [bitnami/tomcat] stadardize port Name and number

* [bitnami/tomcat] update values and readme

* [bitnami/tomcat] update values

* Update bitnami/tomcat/templates/_pod.tpl

Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>

Co-authored-by: baudelet <bbaudelet.soprasteria@lfdj.com>
Co-authored-by: alvneiayu <alvaron@vmware.com>
Co-authored-by: Miguel Ángel Cabrera Miñagorri <devgorri@gmail.com>
Co-authored-by: Miguel Ángel Cabrera Miñagorri <mcabrera@vmware.com>
This commit is contained in:
bbaudelet
2021-10-20 13:28:19 +02:00
committed by GitHub
parent b227c8bd1d
commit 1de6cc930e
8 changed files with 299 additions and 3 deletions

View File

@@ -26,4 +26,4 @@ name: tomcat
sources:
- https://github.com/bitnami/bitnami-docker-tomcat
- http://tomcat.apache.org
version: 9.4.5
version: 9.5.0

View File

@@ -83,6 +83,7 @@ The command removes all the Kubernetes components associated with the chart and
| `tomcatUsername` | Tomcat admin user | `user` |
| `tomcatPassword` | Tomcat admin password | `""` |
| `tomcatAllowRemoteManagement` | Enable remote access to management interface | `0` |
| `catalinaOpts` | Java runtime option used by tomcat JVM | `""` |
| `command` | Override default container command (useful when using custom images) | `[]` |
| `args` | Override default container args (useful when using custom images) | `[]` |
| `extraEnvVars` | Extra environment variables to be set on Tomcat container | `[]` |
@@ -185,6 +186,30 @@ The command removes all the Kubernetes components associated with the chart and
| `volumePermissions.resources.requests` | Init container volume-permissions resource requests | `{}` |
### Metrics parameters
| Name | Description | Value |
| ------------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metrics.jmx.enabled` | Whether or not to expose JMX metrics to Prometheus | `false` |
| `metrics.jmx.catalinaOpts` | custom option used to enabled JMX on tomcat jvm evaluated as template | `-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=5555 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=true` |
| `metrics.jmx.image.registry` | JMX exporter image registry | `docker.io` |
| `metrics.jmx.image.repository` | JMX exporter image repository | `bitnami/jmx-exporter` |
| `metrics.jmx.image.tag` | JMX exporter image tag (immutable tags are recommended) | `0.16.1-debian-10-r73` |
| `metrics.jmx.image.pullPolicy` | JMX exporter image pull policy | `IfNotPresent` |
| `metrics.jmx.image.pullSecrets` | Specify docker-registry secret names as an array | `[]` |
| `metrics.jmx.config` | Configuration file for JMX exporter | `""` |
| `metrics.jmx.resources.limits` | JMX Exporter container resource limits | `{}` |
| `metrics.jmx.resources.requests` | JMX Exporter container resource requests | `{}` |
| `metrics.jmx.ports.metrics` | JMX Exporter container metrics ports | `5556` |
| `metrics.jmx.existingConfigmap` | Name of existing ConfigMap with JMX exporter configuration | `""` |
| `metrics.podMonitor.podTargetLabels` | Used to keep given pod's labels in target | `[]` |
| `metrics.podMonitor.enabled` | Create PodMonitor Resource for scraping metrics using PrometheusOperator | `false` |
| `metrics.podMonitor.interval` | Specify the interval at which metrics should be scraped | `30s` |
| `metrics.podMonitor.scrapeTimeout` | Specify the timeout after which the scrape is ended | `30s` |
| `metrics.podMonitor.additionalLabels` | Additional labels that can be used so PodMonitors will be discovered by Prometheus | `{}` |
| `metrics.podMonitor.relabelings` | Prometheus relabeling rules | `[]` |
The above parameters map to the env variables defined in [bitnami/tomcat](http://github.com/bitnami/bitnami-docker-tomcat). For more information please refer to the [bitnami/tomcat](http://github.com/bitnami/bitnami-docker-tomcat) image documentation.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

View File

@@ -51,3 +51,4 @@
{{- $requiredTomcatPasswordError := include "common.validations.values.single.empty" $requiredTomcatPassword -}}
{{- $passwordValidationErrors = append $passwordValidationErrors $requiredTomcatPasswordError -}}
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $) -}}
{{- include "tomcat.validateValues" . -}}

View File

@@ -7,6 +7,15 @@ Return the proper Tomcat image name
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "tomcat.fullname" -}}
{{- include "common.names.fullname" . -}}
{{- end -}}
{{/*
Return the proper image name (for the init container volume-permissions image)
*/}}
@@ -18,7 +27,7 @@ Return the proper image name (for the init container volume-permissions image)
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "tomcat.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image .Values.metrics.jmx.image) "global" .Values.global) -}}
{{- end -}}
{{/*
@@ -35,3 +44,54 @@ Expand the name of the chart.
{{- define "tomcat.pvc" -}}
{{- coalesce .Values.persistence.existingClaim (include "common.names.fullname" .) -}}
{{- end -}}
{{/*
Return the proper CATALINA_OPTS value
*/}}
{{- define "tomcat.catalinaOpts" -}}
{{- printf "%s %s" .Values.catalinaOpts .Values.metrics.jmx.catalinaOpts | trim -}}
{{- end -}}
{{/*
Return the proper JMX exporter image name
*/}}
{{- define "tomcat.metrics.jmx.image" -}}
{{- include "common.images.image" (dict "imageRoot" .Values.metrics.jmx.image "global" .Values.global) -}}
{{- end -}}
{{/*
Return the tomcat jmx configuration configmap
*/}}
{{- define "tomcat.metrics.jmx.configmapName" -}}
{{- if .Values.metrics.jmx.existingConfigmap -}}
{{- printf "%s" (tpl .Values.metrics.jmx.existingConfigmap $) -}}
{{- else -}}
{{- printf "%s-jmx-configuration" (include "tomcat.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Compile all warnings into a single message, and call fail.
*/}}
{{- define "tomcat.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "tomcat.validateValues.jmxConfig" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}
{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
{{- end -}}
{{- end -}}
{{/*
Check if jmx metrics is enabled, then either metrics.jmx.config or metrics.jmx.existingConfigmap must be set.
*/}}
{{- define "tomcat.validateValues.jmxConfig" -}}
{{- if and .Values.metrics.jmx.enabled (not .Values.metrics.jmx.config) (not .Values.metrics.jmx.existingConfigmap) -}}
tomcat: metrics.jmx.enabled
In order to enable JMX metrics, you also need to provide
the prometheus/jmx_exporter configuration or
provide an existing ConfigMap.
{{- end -}}
{{- end -}}

View File

@@ -37,7 +37,7 @@ initContainers:
- |
chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} /bitnami/tomcat
securityContext:
runAsUser: 0
runAsUser: 0
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 4 }}
{{- end }}
@@ -73,6 +73,10 @@ containers:
key: tomcat-password
- name: TOMCAT_ALLOW_REMOTE_MANAGEMENT
value: {{ .Values.tomcatAllowRemoteManagement | quote }}
{{- if or .Values.catalinaOpts .Values.metrics.jmx.enabled }}
- name: CATALINA_OPTS
value: {{ include "tomcat.catalinaOpts" . | quote }}
{{- end }}
{{- if .Values.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 2 }}
{{- end }}
@@ -115,6 +119,32 @@ containers:
{{- if .Values.sidecars }}
{{ include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) }}
{{- end }}
{{- if .Values.metrics.jmx.enabled }}
- name: jmx-exporter
image: {{ template "tomcat.metrics.jmx.image" . }}
imagePullPolicy: {{ .Values.metrics.jmx.image.pullPolicy | quote }}
command:
- java
- -XX:+UnlockExperimentalVMOptions
- -XX:+UseCGroupMemoryLimitForHeap
- -XX:MaxRAMFraction=1
- -XshowSettings:vm
- -jar
- jmx_prometheus_httpserver.jar
- {{ .Values.metrics.jmx.ports.metrics | quote }}
- /etc/jmx-tomcat/jmx-tomcat-prometheus.yml
ports:
{{- range $key, $val := .Values.metrics.jmx.ports }}
- name: {{ $key }}
containerPort: {{ $val }}
{{- end }}
{{- if .Values.metrics.jmx.resources }}
resources: {{- toYaml .Values.metrics.jmx.resources | nindent 4 }}
{{- end }}
volumeMounts:
- name: jmx-config
mountPath: /etc/jmx-tomcat
{{- end }}
volumes:
{{- if and .Values.persistence.enabled (eq .Values.deployment.type "deployment") }}
- name: data
@@ -126,6 +156,11 @@ volumes:
- name: data
emptyDir: {}
{{- end }}
{{- if .Values.metrics.jmx.enabled }}
- name: jmx-config
configMap:
name: {{ include "tomcat.metrics.jmx.configmapName" . }}
{{- end }}
{{- if .Values.extraVolumes }}
{{ include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) }}
{{- end }}

View File

@@ -0,0 +1,17 @@
{{- if and .Values.metrics.jmx.enabled .Values.metrics.jmx.config (not .Values.metrics.jmx.existingConfigmap) }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "tomcat.fullname" . }}-jmx-configuration
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
jmx-tomcat-prometheus.yml: |-
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.jmx.config "context" $ ) | nindent 4 }}
{{- end -}}

View File

@@ -0,0 +1,38 @@
{{- if and .Values.metrics.jmx.enabled .Values.metrics.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podMonitor.additionalLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
podTargetLabels: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podMonitor.podTargetLabels "context" $ ) | nindent 4 }}
podMetricsEndpoints:
{{- range $key, $val := .Values.metrics.jmx.ports }}
- port: {{ $key | quote }}
path: /metrics
{{- if $.Values.metrics.podMonitor.interval }}
interval: {{ $.Values.metrics.podMonitor.interval }}
{{- end }}
{{- if $.Values.metrics.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ $.Values.metrics.podMonitor.scrapeTimeout }}
{{- end }}
{{- if $.Values.metrics.podMonitor.relabelings }}
relabelings:
{{- include "common.tplvalues.render" (dict "value" $.Values.metrics.podMonitor.relabelings "context" $) | nindent 8 }}
{{- end }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "common.labels.matchLabels" . | nindent 6 }}
{{- end }}

View File

@@ -87,6 +87,9 @@ tomcatPassword: ""
## ref: https://github.com/bitnami/charts/tree/master/bitnami/tomcat#configuration
##
tomcatAllowRemoteManagement: 0
## @param catalinaOpts Java runtime option used by tomcat JVM
##
catalinaOpts: ""
## @param command Override default container command (useful when using custom images)
##
command: []
@@ -487,3 +490,120 @@ volumePermissions:
## cpu: 100m
## memory: 128Mi
requests: {}
## @section Metrics parameters
## Prometheus Exporters / Metrics
##
metrics:
## Prometheus JMX Exporter: exposes the majority of tomcat jvm metrics
##
jmx:
## @param metrics.jmx.enabled Whether or not to expose JMX metrics to Prometheus
##
enabled: false
## @param metrics.jmx.catalinaOpts custom option used to enabled JMX on tomcat jvm evaluated as template
##
catalinaOpts: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=5555 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=true
## Bitnami JMX exporter image
## ref: https://hub.docker.com/r/bitnami/jmx-exporter/tags/
## @param metrics.jmx.image.registry JMX exporter image registry
## @param metrics.jmx.image.repository JMX exporter image repository
## @param metrics.jmx.image.tag JMX exporter image tag (immutable tags are recommended)
## @param metrics.jmx.image.pullPolicy JMX exporter image pull policy
## @param metrics.jmx.image.pullSecrets Specify docker-registry secret names as an array
##
image:
registry: docker.io
repository: bitnami/jmx-exporter
tag: 0.16.1-debian-10-r73
## Specify a imagePullPolicy
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets (secrets must be manually created in the namespace)
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
## Example:
## pullSecrets:
## - myRegistryKeySecretName
##
pullSecrets: []
## @param metrics.jmx.config [string] Configuration file for JMX exporter
## Specify content for jmx-tomcat-prometheus.yml. Evaluated as a template
##
config: |
jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:5555/jmxrmi
startDelaySecs: 120
ssl: false
lowercaseOutputName: true
lowercaseOutputLabelNames: true
attrNameSnakeCase: true
## Prometheus JMX Exporter' resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
## We usually recommend not to specify default resources and to leave this as a conscious
## choice for the user. This also increases chances charts run on environments with little
## resources, such as Minikube. If you do want to specify resources, uncomment the following
## lines, adjust them as necessary, and remove the curly braces after 'resources:'.
## @param metrics.jmx.resources.limits JMX Exporter container resource limits
## @param metrics.jmx.resources.requests JMX Exporter container resource requests
##
resources:
## Example:
## limits:
## cpu: 100m
## memory: 128Mi
limits: {}
## Examples:
## requests:
## cpu: 100m
## memory: 128Mi
requests: {}
## @param metrics.jmx.ports.metrics JMX Exporter container metrics ports
##
ports:
metrics: 5556
## @param metrics.jmx.existingConfigmap Name of existing ConfigMap with JMX exporter configuration
## NOTE: This will override metrics.jmx.config
##
existingConfigmap: ""
## Prometheus pod Monitor
## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#podmonitorspec
##
podMonitor:
## @param metrics.podMonitor.podTargetLabels Used to keep given pod's labels in target
## e.g:
## - app.kubernetes.io/name
##
podTargetLabels: []
## @param metrics.podMonitor.enabled Create PodMonitor Resource for scraping metrics using PrometheusOperator
##
enabled: false
## @param metrics.podMonitor.namespace Namespace in which Prometheus is running
##
namespace: monitoring
## @param metrics.podMonitor.interval Specify the interval at which metrics should be scraped
##
interval: 30s
## @param metrics.podMonitor.scrapeTimeout Specify the timeout after which the scrape is ended
##
scrapeTimeout: 30s
## @param metrics.podMonitor.additionalLabels [object] Additional labels that can be used so PodMonitors will be discovered by Prometheus
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
##
additionalLabels: {}
## @param metrics.podMonitor.scheme Scheme to use for scraping
##
scheme: http
## @param metrics.podMonitor.tlsConfig [object] TLS configuration used for scrape endpoints used by Prometheus
## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#tlsconfig
## e.g:
## tlsConfig:
## ca:
## secret:
## name: existingSecretName
##
tlsConfig: {}
## @param metrics.podMonitor.relabelings [array] Prometheus relabeling rules
##
relabelings: []