Skip to content

Commit

Permalink
operator: Allow optional installation of webhooks (#6363)
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis committed Jun 10, 2022
1 parent 6205b96 commit 09712df
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Main

- [6363](https://github.com/grafana/loki/pull/6363) **periklis**: Allow optional installation of webhooks (Kind)
- [6362](https://github.com/grafana/loki/pull/6362) **periklis**: Allow reduced tenant OIDC authentication requirements
- [6288](https://github.com/grafana/loki/pull/6288) **aminesnow**: Expose only an HTTPS gateway when in openshift mode
- [6195](https://github.com/grafana/loki/pull/6195) **periklis**: Add ruler config support
Expand Down
1 change: 1 addition & 0 deletions operator/config/overlays/development/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ labels:
app.kubernetes.io/version: "0.0.1"

patchesStrategicMerge:
- manager_run_flags_patch.yaml
- manager_related_image_patch.yaml
- manager_image_pull_policy_patch.yaml
12 changes: 12 additions & 0 deletions operator/config/overlays/development/manager_run_flags_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
spec:
template:
spec:
containers:
- name: manager
args:
- "--with-alerting-rule-webhooks=false"
- "--with-recording-rule-webhooks=false"
42 changes: 26 additions & 16 deletions operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ func init() {

func main() {
var (
metricsAddr string
enableLeaderElection bool
probeAddr string
enableCertSigning bool
enableServiceMonitors bool
enableTLSServiceMonitors bool
enableGateway bool
enableGatewayRoute bool
enablePrometheusAlerts bool
enableGrafanaLabsAnalytics bool
metricsAddr string
enableLeaderElection bool
probeAddr string
enableCertSigning bool
enableServiceMonitors bool
enableTLSServiceMonitors bool
enableGateway bool
enableGatewayRoute bool
enablePrometheusAlerts bool
enableGrafanaLabsAnalytics bool
enableAlertingRuleWebhooks bool
enableRecordingRuleWebhooks bool
)

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
Expand All @@ -70,6 +72,10 @@ func main() {
flag.BoolVar(&enablePrometheusAlerts, "with-prometheus-alerts", false, "Enables prometheus alerts.")
flag.BoolVar(&enableGrafanaLabsAnalytics, "with-grafana-labs-analytics", true,
"Enables Grafana Labs analytics.\nMore info: https://grafana.com/docs/loki/latest/configuration/#analytics")
flag.BoolVar(&enableAlertingRuleWebhooks, "with-alerting-rule-webhooks", true,
"Enables AlertingRule validation webhooks.")
flag.BoolVar(&enableRecordingRuleWebhooks, "with-recording-rule-webhooks", true,
"Enables RecordingRule validation webhooks.")
flag.Parse()

logger := log.NewLogger("loki-operator")
Expand Down Expand Up @@ -132,9 +138,11 @@ func main() {
logger.Error(err, "unable to create controller", "controller", "AlertingRule")
os.Exit(1)
}
if err = (&lokiv1beta1.AlertingRule{}).SetupWebhookWithManager(mgr); err != nil {
logger.Error(err, "unable to create webhook", "webhook", "AlertingRule")
os.Exit(1)
if enableAlertingRuleWebhooks {
if err = (&lokiv1beta1.AlertingRule{}).SetupWebhookWithManager(mgr); err != nil {
logger.Error(err, "unable to create webhook", "webhook", "AlertingRule")
os.Exit(1)
}
}
if err = (&controllers.RecordingRuleReconciler{
Client: mgr.GetClient(),
Expand All @@ -144,9 +152,11 @@ func main() {
logger.Error(err, "unable to create controller", "controller", "RecordingRule")
os.Exit(1)
}
if err = (&lokiv1beta1.RecordingRule{}).SetupWebhookWithManager(mgr); err != nil {
logger.Error(err, "unable to create webhook", "webhook", "RecordingRule")
os.Exit(1)
if enableRecordingRuleWebhooks {
if err = (&lokiv1beta1.RecordingRule{}).SetupWebhookWithManager(mgr); err != nil {
logger.Error(err, "unable to create webhook", "webhook", "RecordingRule")
os.Exit(1)
}
}
if err = (&controllers.RulerConfigReconciler{
Client: mgr.GetClient(),
Expand Down

0 comments on commit 09712df

Please sign in to comment.