Skip to content

Commit

Permalink
[CHORE] upgrading helm chart (#110)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Takashi <[email protected]>
  • Loading branch information
nicolastakashi committed Jul 9, 2024
1 parent d63821f commit c0e9388
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions charts/coralogix-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ maintainers:
name: coralogix-operator
sources:
- https://github.com/coralogix/coralogix-operator
version: 0.2.0
appVersion: 0.1.20
version: 0.2.1
appVersion: 0.2.0
kubeVersion: ">=1.16.0-0"
home: https://github.com/coralogix/coralogix-operator
keywords:
Expand Down
9 changes: 4 additions & 5 deletions charts/coralogix-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ spec:
{{- toYaml .Values.kubeRbacProxy.resources | nindent 12 }}
- name: {{ .Chart.Name }}
args:
- /manager
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- --prometheus-rule-controller={{.Values.coralogixOperator.prometheusRules.enabled}}
- -health-probe-bind-address=:8081
- -metrics-bind-address=127.0.0.1:8080
- -leader-elect
- -prometheus-rule-controller={{.Values.coralogixOperator.prometheusRules.enabled}}
env:
- name: CORALOGIX_REGION
value: {{ .Values.coralogixOperator.region | quote }}
Expand Down
23 changes: 23 additions & 0 deletions controllers/prometheusrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
"k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

const (
Expand Down Expand Up @@ -339,7 +341,28 @@ func prometheusInnerRuleToCoralogixInnerRule(rule prometheus.Rule) coralogixv1al

// SetupWithManager sets up the controller with the Manager.
func (r *PrometheusRuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
shouldTrackPrometheusRules := func(labels map[string]string) bool {
if value, ok := labels["app.coralogix.com/track-recording-rules"]; ok && value == "true" {
return true
}
if value, ok := labels["app.coralogix.com/track-alerting-rules"]; ok && value == "true" {
return true
}
return false
}

return ctrl.NewControllerManagedBy(mgr).
For(&prometheus.PrometheusRule{}).
WithEventFilter(predicate.Funcs{
CreateFunc: func(e event.CreateEvent) bool {
return shouldTrackPrometheusRules(e.Object.GetLabels())
},
UpdateFunc: func(e event.UpdateEvent) bool {
return shouldTrackPrometheusRules(e.ObjectNew.GetLabels()) || shouldTrackPrometheusRules(e.ObjectOld.GetLabels())
},
DeleteFunc: func(e event.DeleteEvent) bool {
return shouldTrackPrometheusRules(e.Object.GetLabels())
},
}).
Complete(r)
}

0 comments on commit c0e9388

Please sign in to comment.