Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator: Allow optional installation of webhooks #6363

Merged
merged 4 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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