Skip to content

Commit

Permalink
feat(lifecycle-operator): add Helm value for DORA metrics port (keptn…
Browse files Browse the repository at this point in the history
…#2571)

Co-authored-by: Griffin <[email protected]>
Co-authored-by: David Ahmadov <[email protected]>
Co-authored-by: Moritz Wiesinger <[email protected]>
Signed-off-by: David Ahmadov <[email protected]>
  • Loading branch information
4 people committed Dec 6, 2023
1 parent d668faa commit 1d498f6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/scripts/.helm-tests/default/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9070,6 +9070,8 @@ spec:
value: "0"
- name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL
value: "0"
- name: KEPTN_DORA_METRICS_PORT
value: "2222"
- name: OPTIONS_CONTROLLER_LOG_LEVEL
value: "0"
- name: SCHEDULING_GATES_ENABLED
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/.helm-tests/lifecycle-only/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6557,6 +6557,8 @@ spec:
value: "0"
- name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL
value: "0"
- name: KEPTN_DORA_METRICS_PORT
value: "2222"
- name: OPTIONS_CONTROLLER_LOG_LEVEL
value: "0"
- name: SCHEDULING_GATES_ENABLED
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/.helm-tests/lifecycle-with-certs/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6813,6 +6813,8 @@ spec:
value: "0"
- name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL
value: "0"
- name: KEPTN_DORA_METRICS_PORT
value: "2222"
- name: OPTIONS_CONTROLLER_LOG_LEVEL
value: "0"
- name: SCHEDULING_GATES_ENABLED
Expand Down
1 change: 1 addition & 0 deletions lifecycle-operator/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ and application health checks
| `lifecycleOperator.env.keptnWorkloadControllerLogLevel` | sets the log level of Keptn Workload Controller | `0` |
| `lifecycleOperator.env.keptnWorkloadVersionControllerLogLevel` | sets the log level of Keptn WorkloadVersion Controller | `0` |
| `lifecycleOperator.env.keptnWorkloadInstanceControllerLogLevel` | Deprecated: Use keptnWorkloadVersionControllerLogLevel instead. Sets the log level of Keptn WorkloadVersion Controller | `0` |
| `lifecycleOperator.env.keptnDoraMetricsPort` | sets the port for accessing lifecycle metrics in prometheus format | `2222` |
| `lifecycleOperator.env.optionsControllerLogLevel` | sets the log level of Keptn Options Controller | `0` |
| `lifecycleOperator.env.pythonRunnerImage` | specify image for python task runtime | `ghcr.io/keptn/python-runtime:v1.0.1` |
| `lifecycleOperator.image.registry` | specify the container registry for the lifecycle-operator image | `ghcr.io` |
Expand Down
2 changes: 2 additions & 0 deletions lifecycle-operator/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ spec:
- name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL
value: {{ .Values.lifecycleOperator.env.keptnWorkloadInstanceControllerLogLevel
| quote }}
- name: KEPTN_DORA_METRICS_PORT
value: {{ .Values.lifecycleOperator.env.keptnDoraMetricsPort | quote }}
- name: OPTIONS_CONTROLLER_LOG_LEVEL
value: {{ .Values.lifecycleOperator.env.optionsControllerLogLevel | quote
}}
Expand Down
2 changes: 2 additions & 0 deletions lifecycle-operator/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ lifecycleOperator:
keptnWorkloadVersionControllerLogLevel: "0"
## @param lifecycleOperator.env.keptnWorkloadInstanceControllerLogLevel Deprecated: Use keptnWorkloadVersionControllerLogLevel instead. Sets the log level of Keptn WorkloadVersion Controller
keptnWorkloadInstanceControllerLogLevel: "0"
## @param lifecycleOperator.env.keptnDoraMetricsPort sets the port for accessing lifecycle metrics in prometheus format
keptnDoraMetricsPort: "2222"
## @param lifecycleOperator.env.optionsControllerLogLevel sets the log level of Keptn Options Controller
optionsControllerLogLevel: "0"
## @param lifecycleOperator.env.pythonRunnerImage specify image for python task runtime
Expand Down
11 changes: 5 additions & 6 deletions lifecycle-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type envConfig struct {
KeptnWorkloadControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_CONTROLLER_LOG_LEVEL" default:"0"`
KeptnWorkloadVersionControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_VERSION_CONTROLLER_LOG_LEVEL" default:"0"`
KeptnWorkloadInstanceControllerLogLevel int `envconfig:"KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL" default:"0"`
KeptnDoraMetricsPort int `envconfig:"KEPTN_DORA_METRICS_PORT" default:"2222"`
KeptnOptionsControllerLogLevel int `envconfig:"OPTIONS_CONTROLLER_LOG_LEVEL" default:"0"`

SchedulingGatesEnabled bool `envconfig:"SCHEDULING_GATES_ENABLED" default:"false"`
Expand All @@ -122,7 +123,6 @@ func main() {
// The exporter embeds a default OpenTelemetry Reader and
// implements prometheus.Collector, allowing it to be used as
// both a Reader and Collector.

exporter, err := otelprom.New()
if err != nil {
setupLog.Error(err, "unable to start OTel")
Expand All @@ -140,7 +140,7 @@ func main() {
keptnMeters := telemetry.SetUpKeptnTaskMeters(meter)

// Start the prometheus HTTP server and pass the exporter Collector to it
go serveMetrics()
go serveMetrics(env.KeptnDoraMetricsPort)

// As recommended by the kubebuilder docs, webhook registration should be disabled if running locally. See https://book.kubebuilder.io/cronjob-tutorial/running.html#running-webhooks-locally for reference
flag.BoolVar(&disableWebhook, "disable-webhook", false, "Disable the registration of webhooks.")
Expand Down Expand Up @@ -437,11 +437,10 @@ func main() {

}

func serveMetrics() {
log.Printf("serving metrics at localhost:2222/metrics")

func serveMetrics(metricsPort int) {
log.Printf("serving metrics at localhost:%d/metrics", metricsPort)
http.Handle("/metrics", promhttp.Handler())
err := http.ListenAndServe(":2222", nil)
err := http.ListenAndServe(":"+fmt.Sprint(metricsPort), nil)
if err != nil {
fmt.Printf("error serving http: %v", err)
return
Expand Down

0 comments on commit 1d498f6

Please sign in to comment.