diff --git a/Documentation/api.md b/Documentation/api.md index 31fa075a3..91fd2b9da 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -16133,6 +16133,20 @@ PrometheusAgentSpec <table> <tr> <td> +<code>mode</code><br/> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Mode defines how the Prometheus operator deploys the PrometheusAgent pod(s). +For now this field has no effect.</p> +<p>(Alpha) Using this field requires the <code>PrometheusAgentDaemonSet</code> feature gate to be enabled.</p> +</td> +</tr> +<tr> +<td> <code>podMetadata</code><br/> <em> <a href="#monitoring.coreos.com/v1.EmbeddedObjectMetadata"> @@ -22476,6 +22490,20 @@ int <tbody> <tr> <td> +<code>mode</code><br/> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Mode defines how the Prometheus operator deploys the PrometheusAgent pod(s). +For now this field has no effect.</p> +<p>(Alpha) Using this field requires the <code>PrometheusAgentDaemonSet</code> feature gate to be enabled.</p> +</td> +</tr> +<tr> +<td> <code>podMetadata</code><br/> <em> <a href="#monitoring.coreos.com/v1.EmbeddedObjectMetadata"> diff --git a/Documentation/operator.md b/Documentation/operator.md index 9912fc8fc..e56c76d3f 100644 --- a/Documentation/operator.md +++ b/Documentation/operator.md @@ -52,7 +52,7 @@ Usage of ./operator: -enable-config-reloader-probes Enable liveness and readiness for the config-reloader container. Default: false -feature-gates value - Feature gates are a set of key=value pairs that describe Prometheus-Operator features. Available features: ["PrometheusAgentDaemonset"]. + Feature gates are a set of key=value pairs that describe Prometheus-Operator features. Available features: ["PrometheusAgentDaemonSet"]. -key-file string - NOT RECOMMENDED FOR PRODUCTION - Path to private TLS certificate file. -kubelet-node-address-priority value diff --git a/bundle.yaml b/bundle.yaml index 31c2defb6..ff02a192f 100644 --- a/bundle.yaml +++ b/bundle.yaml @@ -21568,6 +21568,17 @@ spec: enabling the StatefulSetMinReadySeconds feature gate. format: int32 type: integer + mode: + description: |- + Mode defines how the Prometheus operator deploys the PrometheusAgent pod(s). + For now this field has no effect. + + + (Alpha) Using this field requires the `PrometheusAgentDaemonSet` feature gate to be enabled. + enum: + - StatefulSet + - DaemonSet + type: string nodeSelector: additionalProperties: type: string diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml index af799a115..7f981d38c 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml @@ -4644,6 +4644,17 @@ spec: enabling the StatefulSetMinReadySeconds feature gate. format: int32 type: integer + mode: + description: |- + Mode defines how the Prometheus operator deploys the PrometheusAgent pod(s). + For now this field has no effect. + + + (Alpha) Using this field requires the `PrometheusAgentDaemonSet` feature gate to be enabled. + enum: + - StatefulSet + - DaemonSet + type: string nodeSelector: additionalProperties: type: string diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml index b7b389326..f87b1bc9f 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml @@ -4645,6 +4645,17 @@ spec: enabling the StatefulSetMinReadySeconds feature gate. format: int32 type: integer + mode: + description: |- + Mode defines how the Prometheus operator deploys the PrometheusAgent pod(s). + For now this field has no effect. + + + (Alpha) Using this field requires the `PrometheusAgentDaemonSet` feature gate to be enabled. + enum: + - StatefulSet + - DaemonSet + type: string nodeSelector: additionalProperties: type: string diff --git a/jsonnet/prometheus-operator/prometheusagents-crd.json b/jsonnet/prometheus-operator/prometheusagents-crd.json index 8f46419f1..3829be051 100644 --- a/jsonnet/prometheus-operator/prometheusagents-crd.json +++ b/jsonnet/prometheus-operator/prometheusagents-crd.json @@ -3917,6 +3917,14 @@ "format": "int32", "type": "integer" }, + "mode": { + "description": "Mode defines how the Prometheus operator deploys the PrometheusAgent pod(s).\nFor now this field has no effect.\n\n\n(Alpha) Using this field requires the `PrometheusAgentDaemonSet` feature gate to be enabled.", + "enum": [ + "StatefulSet", + "DaemonSet" + ], + "type": "string" + }, "nodeSelector": { "additionalProperties": { "type": "string" diff --git a/pkg/apis/monitoring/v1alpha1/prometheusagent_types.go b/pkg/apis/monitoring/v1alpha1/prometheusagent_types.go index f3335b85f..139d016e5 100644 --- a/pkg/apis/monitoring/v1alpha1/prometheusagent_types.go +++ b/pkg/apis/monitoring/v1alpha1/prometheusagent_types.go @@ -91,5 +91,14 @@ func (l *PrometheusAgentList) DeepCopyObject() runtime.Object { // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status // +k8s:openapi-gen=true type PrometheusAgentSpec struct { + // Mode defines how the Prometheus operator deploys the PrometheusAgent pod(s). + // For now this field has no effect. + // + // (Alpha) Using this field requires the `PrometheusAgentDaemonSet` feature gate to be enabled. + // + // +kubebuilder:validation:Enum=StatefulSet;DaemonSet + // +optional + Mode *string `json:"mode,omitempty"` + monitoringv1.CommonPrometheusFields `json:",inline"` } diff --git a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go index 7f707ad6f..aea3e0b78 100644 --- a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go @@ -1548,6 +1548,11 @@ func (in *PrometheusAgentList) DeepCopy() *PrometheusAgentList { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PrometheusAgentSpec) DeepCopyInto(out *PrometheusAgentSpec) { *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(string) + **out = **in + } in.CommonPrometheusFields.DeepCopyInto(&out.CommonPrometheusFields) } diff --git a/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go b/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go index ae07efb80..23139f11c 100644 --- a/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go @@ -27,6 +27,7 @@ import ( // PrometheusAgentSpecApplyConfiguration represents an declarative configuration of the PrometheusAgentSpec type for use // with apply. type PrometheusAgentSpecApplyConfiguration struct { + Mode *string `json:"mode,omitempty"` v1.CommonPrometheusFieldsApplyConfiguration `json:",inline"` } @@ -36,6 +37,14 @@ func PrometheusAgentSpec() *PrometheusAgentSpecApplyConfiguration { return &PrometheusAgentSpecApplyConfiguration{} } +// WithMode sets the Mode field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Mode field is set to the value of the last call. +func (b *PrometheusAgentSpecApplyConfiguration) WithMode(value string) *PrometheusAgentSpecApplyConfiguration { + b.Mode = &value + return b +} + // WithPodMetadata sets the PodMetadata field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the PodMetadata field is set to the value of the last call. diff --git a/pkg/operator/feature_gates.go b/pkg/operator/feature_gates.go index 6840b387b..934a0c251 100644 --- a/pkg/operator/feature_gates.go +++ b/pkg/operator/feature_gates.go @@ -24,7 +24,7 @@ import ( // At the moment, the are no feature gates available. var defaultFeatureGates = map[string]bool{ - "PrometheusAgentDaemonset": false, + "PrometheusAgentDaemonSet": false, } // ValidateFeatureGates merges the feature gate default values with diff --git a/pkg/operator/feature_gates_test.go b/pkg/operator/feature_gates_test.go index d908e455c..f09d680f3 100644 --- a/pkg/operator/feature_gates_test.go +++ b/pkg/operator/feature_gates_test.go @@ -31,7 +31,7 @@ func TestDefaultFeatureGates(t *testing.T) { func TestMapToString(t *testing.T) { m := mapToString(defaultFeatureGates) - require.True(t, strings.Contains(m, "PrometheusAgentDaemonset=false")) + require.True(t, strings.Contains(m, "PrometheusAgentDaemonSet=false")) } func TestValidateFeatureGatesWithNotSupportFeature(t *testing.T) { @@ -39,7 +39,7 @@ func TestValidateFeatureGatesWithNotSupportFeature(t *testing.T) { require.Error(t, err) require.Equal(t, "", m) - m, err = ValidateFeatureGates(k8sflag.NewMapStringBool(&map[string]bool{"PrometheusAgentDaemonset": true})) + m, err = ValidateFeatureGates(k8sflag.NewMapStringBool(&map[string]bool{"PrometheusAgentDaemonSet": true})) require.NoError(t, err) - require.True(t, strings.Contains(m, "PrometheusAgentDaemonset=true")) + require.True(t, strings.Contains(m, "PrometheusAgentDaemonSet=true")) }