Skip to content

Commit c1a590e

Browse files
committed
Enable the mysqld_exporter without any required user changes
Signed-off-by: Matt Lord <[email protected]>
1 parent 91c619f commit c1a590e

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

pkg/operator/vttablet/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232

3333
mysqldExporterContainerName = "mysqld-exporter"
3434
mysqldExporterCommand = "/bin/mysqld_exporter"
35+
mysqldExporterMySQLCnf = "client.cnf"
3536
mysqldExporterUser = "vt_dba"
3637
mysqldExporterPort = 9104
3738
mysqldExporterPortName = "metrics"

pkg/operator/vttablet/mysqlctld.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ln -sf /dev/stderr /mnt/vt/config/stderr.symlink
4040
echo "log-error = /vt/config/stderr.symlink" > /mnt/vt/config/mycnf/log-error.cnf
4141
echo "binlog_format=row" > /mnt/vt/config/mycnf/rbr.cnf
4242
echo "socket = ` + mysqlSocketPath + `" > /mnt/vt/config/mycnf/socket.cnf
43+
echo -n "[client]\nuser=vt_dba\nsocket=` + mysqlSocketPath + `\n" > /mnt/vt/config/mycnf/client.cnf
4344
`
4445

4546
mysqlSocketInitScript = `set -ex

pkg/operator/vttablet/pod.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package vttablet
1818

1919
import (
20+
"path/filepath"
2021
"strconv"
2122
"strings"
2223

@@ -256,6 +257,10 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
256257
if spec.MysqldExporter != nil && (len(spec.MysqldExporter.Resources.Limits) > 0 || len(spec.MysqldExporter.Resources.Requests) > 0) {
257258
update.ResourceRequirements(&mysqldExporterContainer.Resources, &spec.MysqldExporter.Resources)
258259
}
260+
261+
if _, ok := spec.MysqldExporter.ExtraFlags["config.my-cnf"]; !ok {
262+
spec.MysqldExporter.ExtraFlags["config.my-cnf"] = filepath.Join(vtMycnfPath, mysqldExporterMySQLCnf)
263+
}
259264
}
260265

261266
// Set the resource requirements on each of the default vttablet init

0 commit comments

Comments
 (0)