mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 19:49:46 +00:00
*: Remove PrometheusRuleSelector
This commit is contained in:
parent
fb32e57837
commit
f07d73bd1e
11 changed files with 10 additions and 126 deletions
Documentation
contrib/kube-prometheus
jsonnet/kube-prometheus/prometheus-operator
manifests
example/prometheus-operator-crd
pkg
client/monitoring/v1
prometheus
test
|
@ -249,9 +249,8 @@ Specification of the desired behavior of the Prometheus cluster. More info: http
|
|||
| externalUrl | The external URL the Prometheus instances will be available under. This is necessary to generate correct URLs. This is necessary if Prometheus is not served from root of a DNS name. | string | false |
|
||||
| routePrefix | The route prefix Prometheus registers HTTP handlers for. This is useful, if using ExternalURL and a proxy is rewriting HTTP routes of a request, and the actual ExternalURL is still true, but the server serves requests under a different route prefix. For example for use with `kubectl proxy`. | string | false |
|
||||
| storage | Storage spec to specify how storage shall be used. | *[StorageSpec](#storagespec) | false |
|
||||
| prometheusRuleSelector | A selector to select which PrometheusRules to mount for loading alerting rules from. | *[metav1.LabelSelector](https://v1-6.docs.kubernetes.io/docs/api-reference/v1.6/#labelselector-v1-meta) | false |
|
||||
| ruleSelector | DEPRECATED with Prometheus Operator 'v0.20.0'. Any value in this field will just be copied to 'PrometheusRuleSelector' field | *[metav1.LabelSelector](https://v1-6.docs.kubernetes.io/docs/api-reference/v1.6/#labelselector-v1-meta) | false |
|
||||
| ruleNamespaceSelector | Namespaces to be selected for PrometheusRules discovery. If empty, only check own namespace. | *[metav1.LabelSelector](https://v1-6.docs.kubernetes.io/docs/api-reference/v1.6/#labelselector-v1-meta) | false |
|
||||
| ruleSelector | A selector to select which PrometheusRules to mount for loading alerting rules from. | *[metav1.LabelSelector](https://v1-6.docs.kubernetes.io/docs/api-reference/v1.6/#labelselector-v1-meta) | false |
|
||||
| ruleNamespaceSelector | Namespaces to be selected for PrometheusRules discovery. If unspecified, only the same namespace as the Prometheus object is in is used. | *[metav1.LabelSelector](https://v1-6.docs.kubernetes.io/docs/api-reference/v1.6/#labelselector-v1-meta) | false |
|
||||
| alerting | Define details regarding alerting. | *[AlertingSpec](#alertingspec) | false |
|
||||
| resources | Define resources requests and limits for single Pods. | [v1.ResourceRequirements](https://v1-6.docs.kubernetes.io/docs/api-reference/v1.6/#resourcerequirements-v1-core) | false |
|
||||
| nodeSelector | Define which Nodes the Pods are scheduled on. | map[string]string | false |
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1662,48 +1662,6 @@ spec:
|
|||
|
||||
Populated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids
|
||||
type: string
|
||||
prometheusRuleSelector:
|
||||
description: A label selector is a label query over a set of resources.
|
||||
The result of matchLabels and matchExpressions are ANDed. An empty
|
||||
label selector matches all objects. A null label selector matches
|
||||
no objects.
|
||||
properties:
|
||||
matchExpressions:
|
||||
description: matchExpressions is a list of label selector requirements.
|
||||
The requirements are ANDed.
|
||||
items:
|
||||
description: A label selector requirement is a selector that contains
|
||||
values, a key, and an operator that relates the key and values.
|
||||
properties:
|
||||
key:
|
||||
description: key is the label key that the selector applies
|
||||
to.
|
||||
type: string
|
||||
operator:
|
||||
description: operator represents a key's relationship to a
|
||||
set of values. Valid operators are In, NotIn, Exists and
|
||||
DoesNotExist.
|
||||
type: string
|
||||
values:
|
||||
description: values is an array of string values. If the operator
|
||||
is In or NotIn, the values array must be non-empty. If the
|
||||
operator is Exists or DoesNotExist, the values array must
|
||||
be empty. This array is replaced during a strategic merge
|
||||
patch.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- key
|
||||
- operator
|
||||
type: array
|
||||
matchLabels:
|
||||
description: matchLabels is a map of {key,value} pairs. A single
|
||||
{key,value} in the matchLabels map is equivalent to an element
|
||||
of matchExpressions, whose key field is "key", the operator is
|
||||
"In", and the values array contains only "value". The requirements
|
||||
are ANDed.
|
||||
type: object
|
||||
remoteRead:
|
||||
description: If specified, the remote_read spec. This is an experimental
|
||||
feature, it may change in any upcoming release in a breaking way.
|
||||
|
|
|
@ -1663,48 +1663,6 @@ spec:
|
|||
|
||||
Populated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids
|
||||
type: string
|
||||
prometheusRuleSelector:
|
||||
description: A label selector is a label query over a set of resources.
|
||||
The result of matchLabels and matchExpressions are ANDed. An empty
|
||||
label selector matches all objects. A null label selector matches
|
||||
no objects.
|
||||
properties:
|
||||
matchExpressions:
|
||||
description: matchExpressions is a list of label selector requirements.
|
||||
The requirements are ANDed.
|
||||
items:
|
||||
description: A label selector requirement is a selector that contains
|
||||
values, a key, and an operator that relates the key and values.
|
||||
properties:
|
||||
key:
|
||||
description: key is the label key that the selector applies
|
||||
to.
|
||||
type: string
|
||||
operator:
|
||||
description: operator represents a key's relationship to a
|
||||
set of values. Valid operators are In, NotIn, Exists and
|
||||
DoesNotExist.
|
||||
type: string
|
||||
values:
|
||||
description: values is an array of string values. If the operator
|
||||
is In or NotIn, the values array must be non-empty. If the
|
||||
operator is Exists or DoesNotExist, the values array must
|
||||
be empty. This array is replaced during a strategic merge
|
||||
patch.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- key
|
||||
- operator
|
||||
type: array
|
||||
matchLabels:
|
||||
description: matchLabels is a map of {key,value} pairs. A single
|
||||
{key,value} in the matchLabels map is equivalent to an element
|
||||
of matchExpressions, whose key field is "key", the operator is
|
||||
"In", and the values array contains only "value". The requirements
|
||||
are ANDed.
|
||||
type: object
|
||||
remoteRead:
|
||||
description: If specified, the remote_read spec. This is an experimental
|
||||
feature, it may change in any upcoming release in a breaking way.
|
||||
|
|
|
@ -901,21 +901,15 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
Ref: ref("github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.StorageSpec"),
|
||||
},
|
||||
},
|
||||
"prometheusRuleSelector": {
|
||||
"ruleSelector": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "A selector to select which PrometheusRules to mount for loading alerting rules from.",
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"),
|
||||
},
|
||||
},
|
||||
"ruleSelector": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "DEPRECATED with Prometheus Operator 'v0.20.0'. Any value in this field will just be copied to 'PrometheusRuleSelector' field",
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"),
|
||||
},
|
||||
},
|
||||
"ruleNamespaceSelector": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Namespaces to be selected for PrometheusRules discovery. If empty, only check own namespace.",
|
||||
Description: "Namespaces to be selected for PrometheusRules discovery. If unspecified, only the same namespace as the Prometheus object is in is used.",
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -100,12 +100,9 @@ type PrometheusSpec struct {
|
|||
Storage *StorageSpec `json:"storage,omitempty"`
|
||||
// A selector to select which PrometheusRules to mount for loading alerting
|
||||
// rules from.
|
||||
PrometheusRuleSelector *metav1.LabelSelector `json:"prometheusRuleSelector,omitempty"`
|
||||
// DEPRECATED with Prometheus Operator 'v0.20.0'. Any value in this field
|
||||
// will just be copied to 'PrometheusRuleSelector' field
|
||||
RuleSelector *metav1.LabelSelector `json:"ruleSelector,omitempty"`
|
||||
// Namespaces to be selected for PrometheusRules discovery. If empty, only
|
||||
// check own namespace.
|
||||
// Namespaces to be selected for PrometheusRules discovery. If unspecified, only
|
||||
// the same namespace as the Prometheus object is in is used.
|
||||
RuleNamespaceSelector *metav1.LabelSelector `json:"ruleNamespaceSelector,omitempty"`
|
||||
// Define details regarding alerting.
|
||||
Alerting *AlertingSpec `json:"alerting,omitempty"`
|
||||
|
|
|
@ -567,15 +567,6 @@ func (in *PrometheusSpec) DeepCopyInto(out *PrometheusSpec) {
|
|||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
if in.PrometheusRuleSelector != nil {
|
||||
in, out := &in.PrometheusRuleSelector, &out.PrometheusRuleSelector
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(meta_v1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
if in.RuleSelector != nil {
|
||||
in, out := &in.RuleSelector, &out.RuleSelector
|
||||
if *in == nil {
|
||||
|
|
|
@ -187,7 +187,7 @@ func generateTestConfig(version string) ([]byte, error) {
|
|||
"group": "group1",
|
||||
},
|
||||
},
|
||||
PrometheusRuleSelector: &metav1.LabelSelector{
|
||||
RuleSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"role": "rulefile",
|
||||
},
|
||||
|
|
|
@ -125,14 +125,7 @@ func (c *Operator) selectRuleNamespaces(p *monitoringv1.Prometheus) ([]string, e
|
|||
func (c *Operator) selectRules(p *monitoringv1.Prometheus, namespaces []string) (map[string]string, error) {
|
||||
rules := map[string]string{}
|
||||
|
||||
// With Prometheus Operator v0.20.0 the 'RuleSelector' field in the Prometheus
|
||||
// CRD Spec is deprecated. Any value in 'RuleSelector' is just copied to the new
|
||||
// field 'PrometheusRuleSelector'.
|
||||
if p.Spec.PrometheusRuleSelector == nil && p.Spec.RuleSelector != nil {
|
||||
p.Spec.PrometheusRuleSelector = p.Spec.RuleSelector
|
||||
}
|
||||
|
||||
ruleSelector, err := metav1.LabelSelectorAsSelector(p.Spec.PrometheusRuleSelector)
|
||||
ruleSelector, err := metav1.LabelSelectorAsSelector(p.Spec.RuleSelector)
|
||||
if err != nil {
|
||||
return rules, errors.Wrap(err, "convert rule label selector to selector")
|
||||
}
|
||||
|
|
|
@ -490,9 +490,6 @@ func TestPrometheusDeprecatedRuleSelectorField(t *testing.T) {
|
|||
|
||||
p := framework.MakeBasicPrometheus(ns, name, name, 1)
|
||||
p.Spec.EvaluationInterval = "1s"
|
||||
// Reset new 'RuleFileSelector' field
|
||||
p.Spec.PrometheusRuleSelector = nil
|
||||
// Specify old 'RuleFile' field
|
||||
p.Spec.RuleSelector = &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"role": "rulefile",
|
||||
|
@ -547,9 +544,6 @@ groups:
|
|||
framework.KubeClient.CoreV1().ConfigMaps(ns).Create(&cm)
|
||||
|
||||
p := framework.MakeBasicPrometheus(ns, name, name, 1)
|
||||
// Reset new 'RuleFileSelector' field
|
||||
p.Spec.PrometheusRuleSelector = nil
|
||||
// Specify old 'RuleFile' field
|
||||
p.Spec.RuleSelector = &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"role": "rulefile",
|
||||
|
|
|
@ -48,7 +48,7 @@ func (f *Framework) MakeBasicPrometheus(ns, name, group string, replicas int32)
|
|||
},
|
||||
},
|
||||
ServiceAccountName: "prometheus",
|
||||
PrometheusRuleSelector: &metav1.LabelSelector{
|
||||
RuleSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"role": "rulefile",
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue