diff --git a/Documentation/operator.md b/Documentation/operator.md index f09a3001e..10413607d 100644 --- a/Documentation/operator.md +++ b/Documentation/operator.md @@ -83,6 +83,8 @@ Usage of ./operator: Label selector to filter Prometheus and PrometheusAgent Custom Resources to watch. -secret-field-selector value Field selector to filter Secrets to watch + -secret-label-selector value + Label selector to filter Secrets to watch -short-version Print just the version number. -thanos-default-base-image string diff --git a/cmd/operator/main.go b/cmd/operator/main.go index 8f722315f..2e61386b5 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -172,7 +172,8 @@ func parseFlags(fs *flag.FlagSet) { fs.Var(&cfg.PromSelector, "prometheus-instance-selector", "Label selector to filter Prometheus and PrometheusAgent Custom Resources to watch.") fs.Var(&cfg.AlertmanagerSelector, "alertmanager-instance-selector", "Label selector to filter Alertmanager Custom Resources to watch.") fs.Var(&cfg.ThanosRulerSelector, "thanos-ruler-instance-selector", "Label selector to filter ThanosRuler Custom Resources to watch.") - fs.Var(&cfg.SecretListWatchSelector, "secret-field-selector", "Field selector to filter Secrets to watch") + fs.Var(&cfg.SecretListWatchFieldSelector, "secret-field-selector", "Field selector to filter Secrets to watch") + fs.Var(&cfg.SecretListWatchLabelSelector, "secret-label-selector", "Label selector to filter Secrets to watch") fs.Float64Var(&memlimitRatio, "auto-gomemlimit-ratio", defaultMemlimitRatio, "The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory. The value should be greater than 0.0 and less than 1.0. Default: 0.0 (disabled).") diff --git a/pkg/alertmanager/operator.go b/pkg/alertmanager/operator.go index dec5ea8b6..46666ba4d 100644 --- a/pkg/alertmanager/operator.go +++ b/pkg/alertmanager/operator.go @@ -217,7 +217,8 @@ func (c *Operator) bootstrap(ctx context.Context, config operator.Config) error c.mdClient, resyncPeriod, func(options *metav1.ListOptions) { - options.FieldSelector = config.SecretListWatchSelector.String() + options.FieldSelector = config.SecretListWatchFieldSelector.String() + options.LabelSelector = config.SecretListWatchLabelSelector.String() }, ), v1.SchemeGroupVersion.WithResource("secrets"), diff --git a/pkg/operator/config.go b/pkg/operator/config.go index 3ac32e799..3fc3abd7b 100644 --- a/pkg/operator/config.go +++ b/pkg/operator/config.go @@ -57,10 +57,11 @@ type Config struct { LocalHost string // Label and field selectors for resource watchers. - PromSelector LabelSelector - AlertmanagerSelector LabelSelector - ThanosRulerSelector LabelSelector - SecretListWatchSelector FieldSelector + PromSelector LabelSelector + AlertmanagerSelector LabelSelector + ThanosRulerSelector LabelSelector + SecretListWatchFieldSelector FieldSelector + SecretListWatchLabelSelector LabelSelector // Controller id for pod ownership. ControllerID string diff --git a/pkg/prometheus/agent/operator.go b/pkg/prometheus/agent/operator.go index 38e7ec4c3..f3297ef4e 100644 --- a/pkg/prometheus/agent/operator.go +++ b/pkg/prometheus/agent/operator.go @@ -258,7 +258,8 @@ func New(ctx context.Context, restConfig *rest.Config, c operator.Config, logger o.mdClient, resyncPeriod, func(options *metav1.ListOptions) { - options.FieldSelector = c.SecretListWatchSelector.String() + options.FieldSelector = c.SecretListWatchFieldSelector.String() + options.LabelSelector = c.SecretListWatchLabelSelector.String() }, ), v1.SchemeGroupVersion.WithResource(string(v1.ResourceSecrets)), diff --git a/pkg/prometheus/server/operator.go b/pkg/prometheus/server/operator.go index c3b345231..0e1affb5a 100644 --- a/pkg/prometheus/server/operator.go +++ b/pkg/prometheus/server/operator.go @@ -295,7 +295,8 @@ func New(ctx context.Context, restConfig *rest.Config, c operator.Config, logger o.mdClient, resyncPeriod, func(options *metav1.ListOptions) { - options.FieldSelector = c.SecretListWatchSelector.String() + options.FieldSelector = c.SecretListWatchFieldSelector.String() + options.LabelSelector = c.SecretListWatchLabelSelector.String() }, ), v1.SchemeGroupVersion.WithResource(string(v1.ResourceSecrets)),