-
Notifications
You must be signed in to change notification settings - Fork 416
Deploying using HELM
Stéphane Brunner edited this page Jun 26, 2024
·
5 revisions
To publish the print, you can use this generic HELM chart HELM custom Pod.
With the following values, you will have a print with:
- Use a database to make the cluster mode working.
- Expose the JMX metrics to Prometheus.
- Configure a PodDisruptionBudget.
- Configure an Ingress.
To expose the JMX metrics to Prometheus, we:
- Get the
jmx_prometheus_javaagent.jar
from thebitnami/jmx-exporter
image. - Create a
jmx-exporter.yaml
configuration in a ConfigMap. - Run java with a
-javaagent:...
argument. - Configure a
prometheus
port. - Create a PodMonitor object to indicate to the Prometheus operator where he should get the metrics.
metadata:
enabled: true
securityContext:
runAsNonRoot: true
runAsUser: 33 # www-data
ingress:
enabled: true
hostGroups:
test:
tls:
enabled: true
hosts:
- my-technical-url.example.com
main:
tls:
enabled: true
hosts:
- print.example.com
configMaps:
content:
jmxExporterYaml:
type: yaml
value:
startDelaySeconds: 30
username:
password:
ssl: false
lowercaseOutputLabelNames: true
lowercaseOutputName: true
rules:
- pattern: metrics_org_mapfish_print_map_image_wms_wmslayer_read_(.*)_([a-z]+)
name: metrics_org_mapfish_print_map_image_wms_wmslayer_read_$2
labels:
host: '$1'
help: Read time or WMS requests
type: GAUGE
- pattern: metrics_org_mapfish_print_http_httprequestfetcher_read_(.*)_([a-z]+)
name: metrics_org_mapfish_print_http_httprequestfetcher_read_$2
labels:
host: '$1'
help: Read time or HTTP requests
type: GAUGE
services:
print:
enabled: true
replicaCount: 2
pdb:
enabled: true
ingress:
enabled: true
path: /
service:
type: ClusterIP
servicePort: 80
ports:
- name: http
port: 8080
protocol: TCP
targetPort: http
podMonitor:
enabled: true
endpoint:
port: prometheus
interval: 10s
honorLabels: true
volumes:
jmx-exporter-jar:
emptyDir: {}
jmx-exporter-config:
configMap:
name: self
items:
- key: jmxExporterYaml
path: jmx-exporter.yaml
initContainers:
jmx-exporter:
image:
repository: bitnami/jmx-exporter
tag: 0.18.0
command:
- /bin/bash
- -c
args:
- cp /opt/bitnami/jmx-exporter/jmx_prometheus_javaagent.jar /jmx-exporter-jar/
resources:
requests:
ephemeral-storage: 16Mi
memory: 8Mi
cpu: 0.1
limits:
ephemeral-storage: 32Mi
memory: 16Mi
cpu: 0.2
volumeMounts:
/jmx-exporter-jar/:
name: jmx-exporter-jar
containers:
print:
image:
repository: camptocamp/mapfish_print
tag: '3.30'
env:
LOG_LEVEL:
value: INFO
TOMCAT_LOG_TYPE:
value: json
PGHOST:
type: secret
name: database
key: hostname
PGPORT:
type: secret
name: database
key: port
PGDATABASE:
type: secret
name: database
key: database
PGUSER:
type: secret
name: database
key: username
PGPASSWORD:
type: secret
name: database
key: password
PGOPTIONS:
value: -c statement_timeout=30000
PGSCHEMA:
value: print
PRINT_YAML_MAX_ALIASES:
value: '200'
PRINT_POLL_INTERVAL:
value: '1'
PRINT_MAXCONTENT_LENGTH:
value: '100000000' # 100 MB
PRINT_MAXNUMBEROFRUNNINGPRINTJOBS:
value: '2'
EXTRA_JARS:
value: /usr/local/tomcat/webapps/ROOT/print-apps/mfp-extras/jars
EXTRA_JAVA_OPTS:
value: ' '
EXTRA_CATALINA_OPTS:
value: ' '
# [ms]
HTTP_CONNECTIONREQUESTTIMEOUT:
value: '30000'
HTTP_CONNECTTIMEOUT:
value: '30000'
HTTP_SOCKETTIMEOUT:
value: '30000'
CATALINA_CACHEDURATION:
value: '60'
# <Non heap percentage> = 800Mo / <limit.memory> * 100 = 9.8
# => good value: 90 - <Non heap percentage>
JAVA_MAXRAMPERCENTAGE:
value: '80'
JAVA_INETADDR_TTL:
value: '30'
JAVA_MINRAMPERCENTAGE:
value: '50'
JAVA_MAMRAMPERCENTAGE:
value: '50'
JAVA_INITIALRAMPERCENTAGE:
value: '50'
JAVA_GCTIMELIMIT:
value: '70'
JAVA_GCHEAPFREELIMIT:
value: '10'
# useful:
# kubectl -n gmf-mutualize-int exec deployments/mutualize-mutualize-print -c print -- bash -c 'java ${JAVA_OPTS} -XshowSettings:vm -version'
# kubectl -n gmf-mutualize-int exec deployments/mutualize-mutualize-print -c print -- bash -c 'java ${JAVA_OPTS} -XX:+PrintFlagsFinal -version'
JAVA_OPTS:
value: >-
-XX:MinRAMPercentage=$(JAVA_MINRAMPERCENTAGE)
-XX:MaxRAMPercentage=$(JAVA_MAXRAMPERCENTAGE)
-XX:InitialRAMPercentage=$(JAVA_INITIALRAMPERCENTAGE)
-XX:GCTimeLimit=$(JAVA_GCTIMELIMIT)
-XX:GCHeapFreeLimit=$(JAVA_GCHEAPFREELIMIT)
-XX:+ExitOnOutOfMemoryError
$(EXTRA_JAVA_OPTS)
order: 1
CATALINA_OPTS:
value: >-
-Dmapfish.maxContentLength=$(PRINT_MAXCONTENT_LENGTH)
-DmaxNumberOfRunningPrintJobs=$(PRINT_MAXNUMBEROFRUNNINGPRINTJOBS)
-Dsentry.dsn=$(SENTRY_DSN)
-Dsentry.release=$(SENTRY_RELEASE)
-Dsentry.environment=$(SENTRY_ENVIRONMENT)
-Dsentry.tags=$(SENTRY_TAGS)
-Ddb.host=$(PGHOST)
-Ddb.port=$(PGPORT)
-Ddb.username=$(PGUSER)
-Ddb.password=$(PGPASSWORD)
-Ddb.name=$(PGDATABASE)
-Ddb.schema=$(PGSCHEMA)
-DcacheDuration=$(CATALINA_CACHEDURATION)
-Dsun.net.inetaddr.ttl=$(JAVA_INETADDR_TTL)
-Dhttp.connectionRequestTimeout=$(HTTP_CONNECTIONREQUESTTIMEOUT)
-Dhttp.connectTimeout=$(HTTP_CONNECTTIMEOUT)
-Dhttp.socketTimeout=$(HTTP_SOCKETTIMEOUT)
-javaagent:/usr/local/tomcat/jmx-lib/jmx_prometheus_javaagent.jar=9110:/usr/local/tomcat/jmx-exporter.yaml
$(EXTRA_CATALINA_OPTS)
order: 1
SENTRY_DSN:
value: https://[email protected]/...
SENTRY_TAGS:
value: service:print
SENTRY_RELEASE:
type: configMap
name: self-metadata
key: SERVICE_PRINT_CONTAINER_PRINT_IMAGE_TAG
SENTRY_ENVIRONMENT:
value: prod
ports:
prometheus:
containerPort: 9111
protocol: TCP
http:
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /metrics/healthcheck
port: http
initialDelaySeconds: 15
failureThreshold: 50
periodSeconds: 120
readinessProbe:
httpGet:
path: /metrics/healthcheck
port: http
initialDelaySeconds: 15
periodSeconds: 30
startupProbe:
exec:
# Be sure that the EPSG 2056 exists, see: https://jira.camptocamp.com/browse/GSGMF-1606
command:
- curl
- http://localhost:8080/print/examples:simple/buildreport.pdf
- --data-raw
- spec=%7B%0D%0A++++%22layout%22%3A+%22A4+portrait%22%2C%0D%0A++++%22attributes%22%3A+%7B%22map%22%3A+%7B%0D%0A++++++++%22center%22%3A+%5B%0D%0A++++++++++++1200000%2C%0D%0A++++++++++++2600000%0D%0A++++++++%5D%2C%0D%0A++++++++%22rotation%22%3A+0%2C%0D%0A++++++++%22longitudeFirst%22%3A+true%2C%0D%0A++++++++%22layers%22%3A+%5B%5D%2C%0D%0A++++++++%22scale%22%3A+100000000%2C%0D%0A++++++++%22projection%22%3A+%22EPSG%3A2056%22%2C%0D%0A++++++++%22dpi%22%3A+72%0D%0A++++%7D%7D%0D%0A%7D
initialDelaySeconds: 15
failureThreshold: 50
periodSeconds: 120
volumeMounts:
/usr/local/tomcat/jmx-exporter.yaml:
name: jmx-exporter-config
subPath: jmx-exporter.yaml
/usr/local/tomcat/jmx-lib:
name: jmx-exporter-jar
resources:
requests:
memory: 1Gi
limits:
memory: 2Gi
cpu: '2'
ephemeral-storage: 256Mi