From 86eb41eaf128a5411e99bfa99e096b302b67b707 Mon Sep 17 00:00:00 2001 From: Or Novogroder <108669655+OrNovo@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:19:31 +0300 Subject: [PATCH] patch - make prometheus-rule controller optional (#88) --- CONTRIBUTING.md | 4 ++++ main.go | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6669e5e5..fc7ba3d3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,6 +45,10 @@ Or with `regin` and `api-key` flags ```sh $ go run main.go -region EUROPE2 -api-key xxx-xxx-xxx ``` +For not running the prometheusRule controller set the `prometheus-rule-controller` flag to `false` +```sh +$ go run main.go -prometheus-rule-controller=false +``` Or build and push your image to a registry ```sh make docker-build docker-push IMG=/coralogix-operator:tag diff --git a/main.go b/main.go index a6ae473e..c68fe92b 100644 --- a/main.go +++ b/main.go @@ -84,6 +84,9 @@ func main() { apiKey := os.Getenv("CORALOGIX_API_KEY") flag.StringVar(&apiKey, "api-key", apiKey, "The proper api-key based on your Coralogix cluster's region") + var prometheusRuleController bool + flag.BoolVar(&prometheusRuleController, "prometheus-rule-controller", true, "Determine if the prometheus rule controller should be started. Default is true.") + opts := zap.Options{} opts.BindFlags(flag.CommandLine) flag.Parse() @@ -144,13 +147,15 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "Alert") os.Exit(1) } - if err = (&controllers.PrometheusRuleReconciler{ - CoralogixClientSet: clientset.NewClientSet(targetUrl, apiKey), - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "RecordingRuleGroup") - os.Exit(1) + if prometheusRuleController { + if err = (&controllers.PrometheusRuleReconciler{ + CoralogixClientSet: clientset.NewClientSet(targetUrl, apiKey), + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "RecordingRuleGroup") + os.Exit(1) + } } if err = (&alphacontrollers.RecordingRuleGroupSetReconciler{ CoralogixClientSet: clientset.NewClientSet(targetUrl, apiKey),