Skip to content

Commit

Permalink
feat(metrics-operator)!: release Analysis feature (#2457)
Browse files Browse the repository at this point in the history
BREAKING-CHANGE: The Analysis feature is officially released! Learn more about [here](https://lifecycle.keptn.sh/docs/implementing/slo/).
  • Loading branch information
thisthat committed Nov 8, 2023
1 parent 6085e7e commit fb1f4ac
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 36 deletions.
2 changes: 0 additions & 2 deletions .github/actions/deploy-klt-on-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ certManager:
tag: $TAG
metricsOperator:
imagePullPolicy: Never
env:
enableKeptnAnalysis: "true"
image:
tag: $TAG

Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/.helm-tests/default/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8483,8 +8483,6 @@ spec:
fieldPath: metadata.name
- name: EXPOSE_KEPTN_METRICS
value: "true"
- name: ENABLE_ANALYSIS
value: "false"
- name: METRICS_CONTROLLER_LOG_LEVEL
value: "0"
- name: ANALYSIS_CONTROLLER_LOG_LEVEL
Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/.helm-tests/metrics-only/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1547,8 +1547,6 @@ spec:
fieldPath: metadata.name
- name: EXPOSE_KEPTN_METRICS
value: "true"
- name: ENABLE_ANALYSIS
value: "false"
- name: METRICS_CONTROLLER_LOG_LEVEL
value: "0"
- name: ANALYSIS_CONTROLLER_LOG_LEVEL
Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/.helm-tests/metrics-with-certs/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1803,8 +1803,6 @@ spec:
fieldPath: metadata.name
- name: EXPOSE_KEPTN_METRICS
value: "true"
- name: ENABLE_ANALYSIS
value: "false"
- name: METRICS_CONTROLLER_LOG_LEVEL
value: "0"
- name: ANALYSIS_CONTROLLER_LOG_LEVEL
Expand Down
1 change: 0 additions & 1 deletion metrics-operator/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ Prometheus, Dynatrace, DataDog and K8s metric server...
| `containerSecurityContext.runAsUser` | | `65532` |
| `containerSecurityContext.seccompProfile.type` | | `RuntimeDefault` |
| `env.exposeKeptnMetrics` | enable metrics exporter | `true` |
| `env.enableKeptnAnalysis` | enables/disables the analysis feature | `false` |
| `env.metricsControllerLogLevel` | sets the log level of Metrics Controller | `0` |
| `env.analysisControllerLogLevel` | sets the log level of Analysis Controller | `0` |
| `image.registry` | specify the container registry for the metrics-operator image | `ghcr.io` |
Expand Down
2 changes: 0 additions & 2 deletions metrics-operator/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ spec:
fieldPath: metadata.name
- name: EXPOSE_KEPTN_METRICS
value: {{ .Values.env.exposeKeptnMetrics | quote }}
- name: ENABLE_ANALYSIS
value: {{ .Values.env.enableKeptnAnalysis | quote }}
- name: METRICS_CONTROLLER_LOG_LEVEL
value: {{ .Values.env.metricsControllerLogLevel | quote
}}
Expand Down
2 changes: 0 additions & 2 deletions metrics-operator/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ containerSecurityContext:
env:
## @param env.exposeKeptnMetrics enable metrics exporter
exposeKeptnMetrics: "true"
## @param env.enableKeptnAnalysis enables/disables the analysis feature
enableKeptnAnalysis: "false"
## @param env.metricsControllerLogLevel sets the log level of Metrics Controller
metricsControllerLogLevel: "0"
## @param env.analysisControllerLogLevel sets the log level of Analysis Controller
Expand Down
44 changes: 21 additions & 23 deletions metrics-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ type envConfig struct {
KeptnMetricControllerLogLevel int `envconfig:"METRICS_CONTROLLER_LOG_LEVEL" default:"0"`
AnalysisControllerLogLevel int `envconfig:"ANALYSIS_CONTROLLER_LOG_LEVEL" default:"0"`
ExposeKeptnMetrics bool `envconfig:"EXPOSE_KEPTN_METRICS" default:"true"`
EnableKeptnAnalysis bool `envconfig:"ENABLE_ANALYSIS" default:"false"`
}

//nolint:gocyclo,funlen
Expand Down Expand Up @@ -201,31 +200,30 @@ func main() {
os.Exit(1)
}

if env.EnableKeptnAnalysis {
analysisLogger := ctrl.Log.WithName("KeptnAnalysis Controller")
targetEval := analysis.NewTargetEvaluator(&analysis.OperatorEvaluator{})
objEval := analysis.NewObjectiveEvaluator(&targetEval)
analysisEval := analysis.NewAnalysisEvaluator(&objEval)

ac := &analysiscontroller.AnalysisReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: analysisLogger.V(env.AnalysisControllerLogLevel),
MaxWorkers: 2,
NewWorkersPoolFactory: analysiscontroller.NewWorkersPool,
IAnalysisEvaluator: &analysisEval,
}
if err = ac.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "KeptnMetric")
os.Exit(1)
}
analysisLogger := ctrl.Log.WithName("KeptnAnalysis Controller")
targetEval := analysis.NewTargetEvaluator(&analysis.OperatorEvaluator{})
objEval := analysis.NewObjectiveEvaluator(&targetEval)
analysisEval := analysis.NewAnalysisEvaluator(&objEval)

ac := &analysiscontroller.AnalysisReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: analysisLogger.V(env.AnalysisControllerLogLevel),
MaxWorkers: 2,
NewWorkersPoolFactory: analysiscontroller.NewWorkersPool,
IAnalysisEvaluator: &analysisEval,
}
if err = ac.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "KeptnMetric")
os.Exit(1)
}

res := make(chan analysistypes.AnalysisCompletion)
res := make(chan analysistypes.AnalysisCompletion)

ac.SetAnalysisResultsChannel(res)
ac.SetAnalysisResultsChannel(res)

_ = analysismetrics.GetResultsReporter(ctx, res)

_ = analysismetrics.GetResultsReporter(ctx, res)
}
// +kubebuilder:scaffold:builder

setupValidationWebhooks(mgr)
Expand Down

0 comments on commit fb1f4ac

Please sign in to comment.