Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

fix(k8s-manager): telegraf otl input port #213

Merged
merged 1 commit into from
Dec 1, 2023
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
10 changes: 6 additions & 4 deletions engine/k8s-manager/internal/infrastructure/config/viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const (
TelegrafImageKey = "telegraf.image"
TelegrafTagKey = "telegraf.tag"
TelegrafPullPolicyKey = "telegraf.pullPolicy"
TelegrafMetricsPortKey = "telegraf.port"
TelegrafMetricsOutputPortKey = "telegraf.output.port"
TelegrafMetricsInputPortKey = "telegraf.input.port"
MeasurementsInsecureKey = "measurements.insecure"
MeasurementsTimeoutKey = "measurements.timeout"
MeasurementsMetricsIntervalKey = "measurements.metricsInterval"
Expand Down Expand Up @@ -131,7 +132,7 @@ func Init(configFilePath string) error {
viper.RegisterAlias(TelegrafImageKey, "TELEGRAF_IMAGE_REPOSITORY")
viper.RegisterAlias(TelegrafTagKey, "TELEGRAF_IMAGE_TAG")
viper.RegisterAlias(TelegrafPullPolicyKey, "TELEGRAF_IMAGE_PULLPOLICY")
viper.RegisterAlias(TelegrafMetricsPortKey, "TELEGRAF_METRICS_PORT")
viper.RegisterAlias(TelegrafMetricsOutputPortKey, "TELEGRAF_METRICS_PORT")
viper.RegisterAlias(MeasurementsInsecureKey, "MEASUREMENTS_INSECURE")
viper.RegisterAlias(MeasurementsTimeoutKey, "MEASUREMENTS_TIMEOUT")
viper.RegisterAlias(MeasurementsMetricsIntervalKey, "MEASUREMENTS_METRICS_INTERVAL")
Expand Down Expand Up @@ -175,8 +176,9 @@ func setDefaultValues() {
viper.SetDefault(TelegrafImageKey, "telegraf")
viper.SetDefault(TelegrafTagKey, "1.28.5")
viper.SetDefault(TelegrafPullPolicyKey, "IfNotPresent")
viper.SetDefault(TelegrafMetricsPortKey, 9191)
viper.SetDefault(MeasurementsInsecureKey, false)
viper.SetDefault(TelegrafMetricsOutputPortKey, 9191)
viper.SetDefault(TelegrafMetricsInputPortKey, 4317)
viper.SetDefault(MeasurementsInsecureKey, true)
viper.SetDefault(MeasurementsTimeoutKey, 5)
viper.SetDefault(MeasurementsMetricsIntervalKey, 10)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (kc KubeConfiguration) getProcessConfig(
Realm: viper.GetString(config.AuthRealmKey),
},
Measurements: MeasurementsConfig{
Endpoint: fmt.Sprintf("localhost:%d", viper.GetInt(config.TelegrafMetricsPortKey)),
Endpoint: fmt.Sprintf("localhost:%d", viper.GetInt(config.TelegrafMetricsInputPortKey)),
Insecure: viper.GetBool(config.MeasurementsInsecureKey),
Timeout: viper.GetInt(config.MeasurementsTimeoutKey),
MetricsInterval: viper.GetInt(config.MeasurementsMetricsIntervalKey),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (kn KubeNetwork) CreateNetwork(ctx context.Context, params service.CreateNe
},
{
Name: _metricsPortName,
TargetPort: intstr.FromInt(viper.GetInt(config.TelegrafMetricsPortKey)),
Port: viper.GetInt32(config.TelegrafMetricsPortKey),
TargetPort: intstr.FromInt(viper.GetInt(config.TelegrafMetricsOutputPortKey)),
Port: viper.GetInt32(config.TelegrafMetricsOutputPortKey),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (kp *KubeProcess) getTelegrafContainer() corev1.Container {
},
Ports: []corev1.ContainerPort{
{
ContainerPort: viper.GetInt32(config.TelegrafMetricsPortKey),
ContainerPort: viper.GetInt32(config.TelegrafMetricsOutputPortKey),
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (kp *KubeProcess) getPrometheusAnnotations() map[string]string {
"kai.prometheus/scrape": "true",
"kai.prometheus/scheme": "http",
"kai.prometheus/path": "/metrics",
"kai.prometheus/port": strconv.Itoa(viper.GetInt(config.TelegrafMetricsPortKey)),
"kai.prometheus/port": strconv.Itoa(viper.GetInt(config.TelegrafMetricsOutputPortKey)),
}
}

Expand Down