Skip to content

Commit

Permalink
Add support for specifying MySQL TLS mode to mysqld-exporter (#738)
Browse files Browse the repository at this point in the history
* Add support for MySQL TLS mode to mysqld-exporter

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

* Make TLS mode argument last in the list

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>
  • Loading branch information
radiohead committed Feb 2, 2022
1 parent d403990 commit 6277906
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mysqld-exporter/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ local container = k.core.v1.container;
host,
port=3306,
image='prom/mysqld-exporter:v0.13.0',
tlsMode='preferred',
):: {
local this = self,

envMap:: {
MYSQL_USER: user,
MYSQL_HOST: host,
MYSQL_PORT: std.toString(port),
MYSQL_TLS_MODE: tlsMode,
},

local containerPort = k.core.v1.containerPort,
Expand All @@ -38,7 +40,7 @@ local container = k.core.v1.container;
this.container
// Force DATA_SOURCE_NAME to be declared after the variables it references
+ container.withEnvMap({
DATA_SOURCE_NAME: '$(MYSQL_USER):$(MYSQL_PASSWORD)@tcp($(MYSQL_HOST):$(MYSQL_PORT))/',
DATA_SOURCE_NAME: '$(MYSQL_USER):$(MYSQL_PASSWORD)@tcp($(MYSQL_HOST):$(MYSQL_PORT))/?tls=$(MYSQL_TLS_MODE)',
}),
]
),
Expand Down Expand Up @@ -71,6 +73,13 @@ local container = k.core.v1.container;
container+:: container.withImage(image),
},

withTLSMode(mode):: {
local envVar = k.core.v1.envVar,
container+:: container.withEnvMixin([
envVar.new('MYSQL_TLS_MODE', mode),
]),
},

args:: {
lockWaitTimeout(timeout):: {
container+::
Expand Down

0 comments on commit 6277906

Please sign in to comment.