Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize metrics collector args #457

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config/crds/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ spec:
is removed from service.
format: int64
type: integer
metricsExporterExtraArgs:
description: MetricsExporterExtraArgs is a list of extra command line
arguments to pass to MySQL metrics exporter. See https://github.com/prometheus/mysqld_exporter
for the list of available flags.
items:
type: string
type: array
minAvailable:
description: The number of pods from that set that must still be available
after the eviction, even in the absence of the evicted pod Defaults
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ type MysqlClusterSpec struct {
// Set a custom offset for Server IDs. ServerID for each node will be the index of the statefulset, plus offset
// +optional
ServerIDOffset *int `json:"serverIDOffset,omitempty"`

// MetricsExporterExtraArgs is a list of extra command line arguments to pass to MySQL metrics exporter.
// See https://github.com/prometheus/mysqld_exporter for the list of available flags.
// +optional
MetricsExporterExtraArgs []string `json:"metricsExporterExtraArgs,omitempty"`
}

// MysqlConf defines type for extra cluster configs. It's a simple map between
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions pkg/controller/mysqlcluster/internal/syncer/statefullset.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,22 @@ func (s *sfsSyncer) ensureContainersSpec() []core.Container {
})

// METRICS container
exporterCommand := []string{
fmt.Sprintf("--web.listen-address=0.0.0.0:%d", ExporterPort),
fmt.Sprintf("--web.telemetry-path=%s", ExporterPath),
"--collect.heartbeat",
fmt.Sprintf("--collect.heartbeat.database=%s", constants.OperatorDbName),
}

if len(s.cluster.Spec.MetricsExporterExtraArgs) > 0 {
exporterCommand = append(exporterCommand, s.cluster.Spec.MetricsExporterExtraArgs...)
}

exporter := s.ensureContainer(containerExporterName,
s.opt.MetricsExporterImage,
[]string{
fmt.Sprintf("--web.listen-address=0.0.0.0:%d", ExporterPort),
fmt.Sprintf("--web.telemetry-path=%s", ExporterPath),
"--collect.heartbeat",
fmt.Sprintf("--collect.heartbeat.database=%s", constants.OperatorDbName),
},
exporterCommand,
)

exporter.Ports = ensurePorts(core.ContainerPort{
Name: ExporterPortName,
ContainerPort: ExporterPort,
Expand Down