1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-15 16:56:24 +00:00

Add mode field in PrometheusAgent CRD (#6640)

* Add mode field in PrometheusAgent CRD
This commit is contained in:
Ha Anh Vu 2024-06-04 17:17:29 +07:00 committed by GitHub
parent 77e92ecd4e
commit fa37a770ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 97 additions and 5 deletions

28
Documentation/api.md generated
View file

@ -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">

View file

@ -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

11
bundle.yaml generated
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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"`
}

View file

@ -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)
}

View file

@ -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.

View file

@ -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

View file

@ -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"))
}