mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
feat: support pod spec field "enableServiceLinks" (#7383)
This commit is contained in:
parent
9da5dce39d
commit
75b4e09ed0
33 changed files with 389 additions and 0 deletions
Documentation/api-reference
bundle.yamlexample
prometheus-operator-crd-full
monitoring.coreos.com_alertmanagers.yamlmonitoring.coreos.com_prometheusagents.yamlmonitoring.coreos.com_prometheuses.yamlmonitoring.coreos.com_thanosrulers.yaml
prometheus-operator-crd
jsonnet/prometheus-operator
pkg
alertmanager
apis/monitoring/v1
client/applyconfiguration/monitoring
v1
v1alpha1
prometheus
agent
server
thanos
|
@ -515,6 +515,18 @@ PodDNSConfig
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>serviceName</code><br/>
|
||||
<em>
|
||||
string
|
||||
|
@ -2440,6 +2452,18 @@ instead of the Pod IP’s address.</p>
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>containers</code><br/>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#container-v1-core">
|
||||
|
@ -4257,6 +4281,18 @@ PodDNSConfig
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>priorityClassName</code><br/>
|
||||
<em>
|
||||
string
|
||||
|
@ -5979,6 +6015,18 @@ PodDNSConfig
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>serviceName</code><br/>
|
||||
<em>
|
||||
string
|
||||
|
@ -7669,6 +7717,18 @@ instead of the Pod IP’s address.</p>
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>containers</code><br/>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#container-v1-core">
|
||||
|
@ -12566,6 +12626,18 @@ instead of the Pod IP’s address.</p>
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>containers</code><br/>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#container-v1-core">
|
||||
|
@ -16830,6 +16902,18 @@ PodDNSConfig
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>priorityClassName</code><br/>
|
||||
<em>
|
||||
string
|
||||
|
@ -19492,6 +19576,18 @@ instead of the Pod IP’s address.</p>
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>containers</code><br/>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#container-v1-core">
|
||||
|
@ -27692,6 +27788,18 @@ instead of the Pod IP’s address.</p>
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>enableServiceLinks</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>Indicates whether information about services should be injected into pod’s environment variables</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>containers</code><br/>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#container-v1-core">
|
||||
|
|
16
bundle.yaml
generated
16
bundle.yaml
generated
|
@ -13641,6 +13641,10 @@ spec:
|
|||
items:
|
||||
type: string
|
||||
type: array
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
externalUrl:
|
||||
description: |-
|
||||
The external URL the Alertmanager instances will be available under. This is
|
||||
|
@ -24104,6 +24108,10 @@ spec:
|
|||
|
||||
It requires Prometheus >= v2.33.0.
|
||||
type: boolean
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedBodySizeLimit:
|
||||
description: |-
|
||||
When defined, enforcedBodySizeLimit specifies a global limit on the size
|
||||
|
@ -35694,6 +35702,10 @@ spec:
|
|||
|
||||
It requires Prometheus >= v2.33.0.
|
||||
type: boolean
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedBodySizeLimit:
|
||||
description: |-
|
||||
When defined, enforcedBodySizeLimit specifies a global limit on the size
|
||||
|
@ -61600,6 +61612,10 @@ spec:
|
|||
- Default
|
||||
- None
|
||||
type: string
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedNamespaceLabel:
|
||||
description: |-
|
||||
EnforcedNamespaceLabel enforces adding a namespace label of origin for each alert
|
||||
|
|
|
@ -3602,6 +3602,10 @@ spec:
|
|||
items:
|
||||
type: string
|
||||
type: array
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
externalUrl:
|
||||
description: |-
|
||||
The external URL the Alertmanager instances will be available under. This is
|
||||
|
|
|
@ -2935,6 +2935,10 @@ spec:
|
|||
|
||||
It requires Prometheus >= v2.33.0.
|
||||
type: boolean
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedBodySizeLimit:
|
||||
description: |-
|
||||
When defined, enforcedBodySizeLimit specifies a global limit on the size
|
||||
|
|
|
@ -3691,6 +3691,10 @@ spec:
|
|||
|
||||
It requires Prometheus >= v2.33.0.
|
||||
type: boolean
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedBodySizeLimit:
|
||||
description: |-
|
||||
When defined, enforcedBodySizeLimit specifies a global limit on the size
|
||||
|
|
|
@ -2607,6 +2607,10 @@ spec:
|
|||
- Default
|
||||
- None
|
||||
type: string
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedNamespaceLabel:
|
||||
description: |-
|
||||
EnforcedNamespaceLabel enforces adding a namespace label of origin for each alert
|
||||
|
|
|
@ -3603,6 +3603,10 @@ spec:
|
|||
items:
|
||||
type: string
|
||||
type: array
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
externalUrl:
|
||||
description: |-
|
||||
The external URL the Alertmanager instances will be available under. This is
|
||||
|
|
|
@ -2936,6 +2936,10 @@ spec:
|
|||
|
||||
It requires Prometheus >= v2.33.0.
|
||||
type: boolean
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedBodySizeLimit:
|
||||
description: |-
|
||||
When defined, enforcedBodySizeLimit specifies a global limit on the size
|
||||
|
|
|
@ -3692,6 +3692,10 @@ spec:
|
|||
|
||||
It requires Prometheus >= v2.33.0.
|
||||
type: boolean
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedBodySizeLimit:
|
||||
description: |-
|
||||
When defined, enforcedBodySizeLimit specifies a global limit on the size
|
||||
|
|
|
@ -2608,6 +2608,10 @@ spec:
|
|||
- Default
|
||||
- None
|
||||
type: string
|
||||
enableServiceLinks:
|
||||
description: Indicates whether information about services should be
|
||||
injected into pod's environment variables
|
||||
type: boolean
|
||||
enforcedNamespaceLabel:
|
||||
description: |-
|
||||
EnforcedNamespaceLabel enforces adding a namespace label of origin for each alert
|
||||
|
|
|
@ -3203,6 +3203,10 @@
|
|||
},
|
||||
"type": "array"
|
||||
},
|
||||
"enableServiceLinks": {
|
||||
"description": "Indicates whether information about services should be injected into pod's environment variables",
|
||||
"type": "boolean"
|
||||
},
|
||||
"externalUrl": {
|
||||
"description": "The external URL the Alertmanager instances will be available under. This is\nnecessary to generate correct URLs. This is necessary if Alertmanager is not\nserved from root of a DNS name.",
|
||||
"type": "string"
|
||||
|
|
|
@ -2536,6 +2536,10 @@
|
|||
"description": "Enable Prometheus to be used as a receiver for the Prometheus remote\nwrite protocol.\n\nWARNING: This is not considered an efficient way of ingesting samples.\nUse it with caution for specific low-volume use cases.\nIt is not suitable for replacing the ingestion via scraping and turning\nPrometheus into a push-based metrics collection system.\nFor more information see https://prometheus.io/docs/prometheus/latest/querying/api/#remote-write-receiver\n\nIt requires Prometheus >= v2.33.0.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"enableServiceLinks": {
|
||||
"description": "Indicates whether information about services should be injected into pod's environment variables",
|
||||
"type": "boolean"
|
||||
},
|
||||
"enforcedBodySizeLimit": {
|
||||
"description": "When defined, enforcedBodySizeLimit specifies a global limit on the size\nof uncompressed response body that will be accepted by Prometheus.\nTargets responding with a body larger than this many bytes will cause\nthe scrape to fail.\n\nIt requires Prometheus >= v2.28.0.\n\nWhen both `enforcedBodySizeLimit` and `bodySizeLimit` are defined and greater than zero, the following rules apply:\n* Scrape objects without a defined bodySizeLimit value will inherit the global bodySizeLimit value (Prometheus >= 2.45.0) or the enforcedBodySizeLimit value (Prometheus < v2.45.0).\n If Prometheus version is >= 2.45.0 and the `enforcedBodySizeLimit` is greater than the `bodySizeLimit`, the `bodySizeLimit` will be set to `enforcedBodySizeLimit`.\n* Scrape objects with a bodySizeLimit value less than or equal to enforcedBodySizeLimit keep their specific value.\n* Scrape objects with a bodySizeLimit value greater than enforcedBodySizeLimit are set to enforcedBodySizeLimit.",
|
||||
"pattern": "(^0|([0-9]*[.])?[0-9]+((K|M|G|T|E|P)i?)?B)$",
|
||||
|
|
|
@ -3178,6 +3178,10 @@
|
|||
"description": "Enable Prometheus to be used as a receiver for the Prometheus remote\nwrite protocol.\n\nWARNING: This is not considered an efficient way of ingesting samples.\nUse it with caution for specific low-volume use cases.\nIt is not suitable for replacing the ingestion via scraping and turning\nPrometheus into a push-based metrics collection system.\nFor more information see https://prometheus.io/docs/prometheus/latest/querying/api/#remote-write-receiver\n\nIt requires Prometheus >= v2.33.0.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"enableServiceLinks": {
|
||||
"description": "Indicates whether information about services should be injected into pod's environment variables",
|
||||
"type": "boolean"
|
||||
},
|
||||
"enforcedBodySizeLimit": {
|
||||
"description": "When defined, enforcedBodySizeLimit specifies a global limit on the size\nof uncompressed response body that will be accepted by Prometheus.\nTargets responding with a body larger than this many bytes will cause\nthe scrape to fail.\n\nIt requires Prometheus >= v2.28.0.\n\nWhen both `enforcedBodySizeLimit` and `bodySizeLimit` are defined and greater than zero, the following rules apply:\n* Scrape objects without a defined bodySizeLimit value will inherit the global bodySizeLimit value (Prometheus >= 2.45.0) or the enforcedBodySizeLimit value (Prometheus < v2.45.0).\n If Prometheus version is >= 2.45.0 and the `enforcedBodySizeLimit` is greater than the `bodySizeLimit`, the `bodySizeLimit` will be set to `enforcedBodySizeLimit`.\n* Scrape objects with a bodySizeLimit value less than or equal to enforcedBodySizeLimit keep their specific value.\n* Scrape objects with a bodySizeLimit value greater than enforcedBodySizeLimit are set to enforcedBodySizeLimit.",
|
||||
"pattern": "(^0|([0-9]*[.])?[0-9]+((K|M|G|T|E|P)i?)?B)$",
|
||||
|
|
|
@ -2256,6 +2256,10 @@
|
|||
],
|
||||
"type": "string"
|
||||
},
|
||||
"enableServiceLinks": {
|
||||
"description": "Indicates whether information about services should be injected into pod's environment variables",
|
||||
"type": "boolean"
|
||||
},
|
||||
"enforcedNamespaceLabel": {
|
||||
"description": "EnforcedNamespaceLabel enforces adding a namespace label of origin for each alert\nand metric that is user created. The label value will always be the namespace of the object that is\nbeing created.",
|
||||
"type": "string"
|
||||
|
|
|
@ -748,6 +748,7 @@ func makeStatefulSetSpec(logger *slog.Logger, a *monitoringv1.Alertmanager, conf
|
|||
Affinity: a.Spec.Affinity,
|
||||
TopologySpreadConstraints: a.Spec.TopologySpreadConstraints,
|
||||
HostAliases: operator.MakeHostAliases(a.Spec.HostAliases),
|
||||
EnableServiceLinks: a.Spec.EnableServiceLinks,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1336,3 +1336,29 @@ func TestPersistentVolumeClaimRetentionPolicy(t *testing.T) {
|
|||
t.Fatalf("expected persistentVolumeClaimDeletePolicy.WhenScaled to be %s but got %s", appsv1.DeletePersistentVolumeClaimRetentionPolicyType, sset.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatefulSetEnableServiceLinks(t *testing.T) {
|
||||
tests := []struct {
|
||||
enableServiceLinks *bool
|
||||
expectedEnableService *bool
|
||||
}{
|
||||
{enableServiceLinks: ptr.To(false), expectedEnableService: ptr.To(false)},
|
||||
{enableServiceLinks: ptr.To(true), expectedEnableService: ptr.To(true)},
|
||||
{enableServiceLinks: nil, expectedEnableService: nil},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
sset, err := makeStatefulSet(nil, &monitoringv1.Alertmanager{
|
||||
ObjectMeta: metav1.ObjectMeta{},
|
||||
Spec: monitoringv1.AlertmanagerSpec{EnableServiceLinks: test.expectedEnableService},
|
||||
}, defaultTestConfig, "", &operator.ShardedSecret{})
|
||||
require.NoError(t, err)
|
||||
|
||||
if test.expectedEnableService != nil {
|
||||
require.NotNil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks not nil")
|
||||
require.Equal(t, *test.expectedEnableService, *sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to match")
|
||||
} else {
|
||||
require.Nil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks is nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,6 +193,9 @@ type AlertmanagerSpec struct {
|
|||
//
|
||||
// +optional
|
||||
DNSConfig *PodDNSConfig `json:"dnsConfig,omitempty"`
|
||||
// Indicates whether information about services should be injected into pod's environment variables
|
||||
// +optional
|
||||
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"`
|
||||
// The name of the service name used by the underlying StatefulSet(s) as the governing service.
|
||||
// If defined, the Service must be created before the Alertmanager resource in the same namespace and it must define a selector that matches the pod labels.
|
||||
// If empty, the operator will create and manage a headless service named `alertmanager-operated` for Alermanager resources.
|
||||
|
|
|
@ -464,6 +464,10 @@ type CommonPrometheusFields struct {
|
|||
// instead of the Pod IP's address.
|
||||
ListenLocal bool `json:"listenLocal,omitempty"`
|
||||
|
||||
// Indicates whether information about services should be injected into pod's environment variables
|
||||
// +optional
|
||||
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"`
|
||||
|
||||
// Containers allows injecting additional containers or modifying operator
|
||||
// generated containers. This can be used to allow adding an authentication
|
||||
// proxy to the Pods or to change the behavior of an operator generated
|
||||
|
|
|
@ -137,6 +137,10 @@ type ThanosRulerSpec struct {
|
|||
// +optional
|
||||
DNSConfig *PodDNSConfig `json:"dnsConfig,omitempty"`
|
||||
|
||||
// Indicates whether information about services should be injected into pod's environment variables
|
||||
// +optional
|
||||
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"`
|
||||
|
||||
// Priority class assigned to the Pods
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
|
||||
|
|
15
pkg/apis/monitoring/v1/zz_generated.deepcopy.go
generated
15
pkg/apis/monitoring/v1/zz_generated.deepcopy.go
generated
|
@ -377,6 +377,11 @@ func (in *AlertmanagerSpec) DeepCopyInto(out *AlertmanagerSpec) {
|
|||
*out = new(PodDNSConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.EnableServiceLinks != nil {
|
||||
in, out := &in.EnableServiceLinks, &out.EnableServiceLinks
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.ServiceName != nil {
|
||||
in, out := &in.ServiceName, &out.ServiceName
|
||||
*out = new(string)
|
||||
|
@ -881,6 +886,11 @@ func (in *CommonPrometheusFields) DeepCopyInto(out *CommonPrometheusFields) {
|
|||
*out = new(PodDNSConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.EnableServiceLinks != nil {
|
||||
in, out := &in.EnableServiceLinks, &out.EnableServiceLinks
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.Containers != nil {
|
||||
in, out := &in.Containers, &out.Containers
|
||||
*out = make([]corev1.Container, len(*in))
|
||||
|
@ -3420,6 +3430,11 @@ func (in *ThanosRulerSpec) DeepCopyInto(out *ThanosRulerSpec) {
|
|||
*out = new(PodDNSConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.EnableServiceLinks != nil {
|
||||
in, out := &in.EnableServiceLinks, &out.EnableServiceLinks
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.ServiceName != nil {
|
||||
in, out := &in.ServiceName, &out.ServiceName
|
||||
*out = new(string)
|
||||
|
|
|
@ -56,6 +56,7 @@ type AlertmanagerSpecApplyConfiguration struct {
|
|||
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
|
||||
DNSPolicy *monitoringv1.DNSPolicy `json:"dnsPolicy,omitempty"`
|
||||
DNSConfig *PodDNSConfigApplyConfiguration `json:"dnsConfig,omitempty"`
|
||||
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"`
|
||||
ServiceName *string `json:"serviceName,omitempty"`
|
||||
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
|
||||
ListenLocal *bool `json:"listenLocal,omitempty"`
|
||||
|
@ -347,6 +348,14 @@ func (b *AlertmanagerSpecApplyConfiguration) WithDNSConfig(value *PodDNSConfigAp
|
|||
return b
|
||||
}
|
||||
|
||||
// WithEnableServiceLinks sets the EnableServiceLinks 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 EnableServiceLinks field is set to the value of the last call.
|
||||
func (b *AlertmanagerSpecApplyConfiguration) WithEnableServiceLinks(value bool) *AlertmanagerSpecApplyConfiguration {
|
||||
b.EnableServiceLinks = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithServiceName sets the ServiceName 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 ServiceName field is set to the value of the last call.
|
||||
|
|
|
@ -76,6 +76,7 @@ type CommonPrometheusFieldsApplyConfiguration struct {
|
|||
DNSPolicy *monitoringv1.DNSPolicy `json:"dnsPolicy,omitempty"`
|
||||
DNSConfig *PodDNSConfigApplyConfiguration `json:"dnsConfig,omitempty"`
|
||||
ListenLocal *bool `json:"listenLocal,omitempty"`
|
||||
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"`
|
||||
Containers []corev1.Container `json:"containers,omitempty"`
|
||||
InitContainers []corev1.Container `json:"initContainers,omitempty"`
|
||||
AdditionalScrapeConfigs *corev1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"`
|
||||
|
@ -566,6 +567,14 @@ func (b *CommonPrometheusFieldsApplyConfiguration) WithListenLocal(value bool) *
|
|||
return b
|
||||
}
|
||||
|
||||
// WithEnableServiceLinks sets the EnableServiceLinks 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 EnableServiceLinks field is set to the value of the last call.
|
||||
func (b *CommonPrometheusFieldsApplyConfiguration) WithEnableServiceLinks(value bool) *CommonPrometheusFieldsApplyConfiguration {
|
||||
b.EnableServiceLinks = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithContainers adds the given value to the Containers field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the Containers field.
|
||||
|
|
|
@ -498,6 +498,14 @@ func (b *PrometheusSpecApplyConfiguration) WithListenLocal(value bool) *Promethe
|
|||
return b
|
||||
}
|
||||
|
||||
// WithEnableServiceLinks sets the EnableServiceLinks 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 EnableServiceLinks field is set to the value of the last call.
|
||||
func (b *PrometheusSpecApplyConfiguration) WithEnableServiceLinks(value bool) *PrometheusSpecApplyConfiguration {
|
||||
b.CommonPrometheusFieldsApplyConfiguration.EnableServiceLinks = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithContainers adds the given value to the Containers field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the Containers field.
|
||||
|
|
|
@ -40,6 +40,7 @@ type ThanosRulerSpecApplyConfiguration struct {
|
|||
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
|
||||
DNSPolicy *monitoringv1.DNSPolicy `json:"dnsPolicy,omitempty"`
|
||||
DNSConfig *PodDNSConfigApplyConfiguration `json:"dnsConfig,omitempty"`
|
||||
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"`
|
||||
PriorityClassName *string `json:"priorityClassName,omitempty"`
|
||||
ServiceName *string `json:"serviceName,omitempty"`
|
||||
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
|
||||
|
@ -219,6 +220,14 @@ func (b *ThanosRulerSpecApplyConfiguration) WithDNSConfig(value *PodDNSConfigApp
|
|||
return b
|
||||
}
|
||||
|
||||
// WithEnableServiceLinks sets the EnableServiceLinks 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 EnableServiceLinks field is set to the value of the last call.
|
||||
func (b *ThanosRulerSpecApplyConfiguration) WithEnableServiceLinks(value bool) *ThanosRulerSpecApplyConfiguration {
|
||||
b.EnableServiceLinks = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithPriorityClassName sets the PriorityClassName 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 PriorityClassName field is set to the value of the last call.
|
||||
|
|
|
@ -486,6 +486,14 @@ func (b *PrometheusAgentSpecApplyConfiguration) WithListenLocal(value bool) *Pro
|
|||
return b
|
||||
}
|
||||
|
||||
// WithEnableServiceLinks sets the EnableServiceLinks 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 EnableServiceLinks field is set to the value of the last call.
|
||||
func (b *PrometheusAgentSpecApplyConfiguration) WithEnableServiceLinks(value bool) *PrometheusAgentSpecApplyConfiguration {
|
||||
b.CommonPrometheusFieldsApplyConfiguration.EnableServiceLinks = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithContainers adds the given value to the Containers field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the Containers field.
|
||||
|
|
|
@ -224,6 +224,7 @@ func makeDaemonSetSpec(
|
|||
TopologySpreadConstraints: prompkg.MakeK8sTopologySpreadConstraint(finalSelectorLabels, cpf.TopologySpreadConstraints),
|
||||
HostAliases: operator.MakeHostAliases(cpf.HostAliases),
|
||||
HostNetwork: cpf.HostNetwork,
|
||||
EnableServiceLinks: cpf.EnableServiceLinks,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
monitoringv1alpha1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1"
|
||||
|
@ -180,3 +181,32 @@ func TestDaemonSetLabelingAndAnnotations(t *testing.T) {
|
|||
require.Equal(t, expectedDaemonSetAnnotations, dset.Annotations)
|
||||
require.Equal(t, expectedPodLabels, dset.Spec.Template.ObjectMeta.Labels)
|
||||
}
|
||||
|
||||
func TestDaemonSetenableServiceLinks(t *testing.T) {
|
||||
tests := []struct {
|
||||
enableServiceLinks *bool
|
||||
expectedEnableServiceLinks *bool
|
||||
}{
|
||||
{enableServiceLinks: ptr.To(false), expectedEnableServiceLinks: ptr.To(false)},
|
||||
{enableServiceLinks: ptr.To(true), expectedEnableServiceLinks: ptr.To(true)},
|
||||
{enableServiceLinks: nil, expectedEnableServiceLinks: nil},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
sset, err := makeDaemonSetFromPrometheus(monitoringv1alpha1.PrometheusAgent{
|
||||
Spec: monitoringv1alpha1.PrometheusAgentSpec{
|
||||
CommonPrometheusFields: monitoringv1.CommonPrometheusFields{
|
||||
EnableServiceLinks: test.enableServiceLinks,
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
if test.expectedEnableServiceLinks != nil {
|
||||
require.NotNil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be non-nil")
|
||||
require.Equal(t, *test.expectedEnableServiceLinks, *sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to match")
|
||||
} else {
|
||||
require.Nil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,6 +287,7 @@ func makeStatefulSetSpec(
|
|||
TopologySpreadConstraints: prompkg.MakeK8sTopologySpreadConstraint(finalSelectorLabels, cpf.TopologySpreadConstraints),
|
||||
HostAliases: operator.MakeHostAliases(cpf.HostAliases),
|
||||
HostNetwork: cpf.HostNetwork,
|
||||
EnableServiceLinks: cpf.EnableServiceLinks,
|
||||
}
|
||||
|
||||
if cpf.HostNetwork {
|
||||
|
|
|
@ -332,3 +332,32 @@ func TestScrapeFailureLogFileVolumeMountNotPresent(t *testing.T) {
|
|||
|
||||
require.False(t, found, "Scrape failure log file mounted, when it shouldn't be.")
|
||||
}
|
||||
|
||||
func TestStatefulSetenableServiceLinks(t *testing.T) {
|
||||
tests := []struct {
|
||||
enableServiceLinks *bool
|
||||
expectedEnableServiceLinks *bool
|
||||
}{
|
||||
{enableServiceLinks: ptr.To(false), expectedEnableServiceLinks: ptr.To(false)},
|
||||
{enableServiceLinks: ptr.To(true), expectedEnableServiceLinks: ptr.To(true)},
|
||||
{enableServiceLinks: nil, expectedEnableServiceLinks: nil},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
sset, err := makeStatefulSetFromPrometheus(monitoringv1alpha1.PrometheusAgent{
|
||||
Spec: monitoringv1alpha1.PrometheusAgentSpec{
|
||||
CommonPrometheusFields: monitoringv1.CommonPrometheusFields{
|
||||
EnableServiceLinks: test.enableServiceLinks,
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
if test.expectedEnableServiceLinks != nil {
|
||||
require.NotNil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be non-nil")
|
||||
require.Equal(t, *test.expectedEnableServiceLinks, *sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to match")
|
||||
} else {
|
||||
require.Nil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -368,6 +368,7 @@ func makeStatefulSetSpec(
|
|||
TopologySpreadConstraints: prompkg.MakeK8sTopologySpreadConstraint(finalSelectorLabels, cpf.TopologySpreadConstraints),
|
||||
HostAliases: operator.MakeHostAliases(cpf.HostAliases),
|
||||
HostNetwork: cpf.HostNetwork,
|
||||
EnableServiceLinks: cpf.EnableServiceLinks,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3180,3 +3180,32 @@ func TestDNSPolicyAndDNSConfig(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatefulSetenableServiceLinks(t *testing.T) {
|
||||
tests := []struct {
|
||||
enableServiceLinks *bool
|
||||
expectedEnableServiceLinks *bool
|
||||
}{
|
||||
{enableServiceLinks: ptr.To(false), expectedEnableServiceLinks: ptr.To(false)},
|
||||
{enableServiceLinks: ptr.To(true), expectedEnableServiceLinks: ptr.To(true)},
|
||||
{enableServiceLinks: nil, expectedEnableServiceLinks: nil},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
sset, err := makeStatefulSetFromPrometheus(monitoringv1.Prometheus{
|
||||
Spec: monitoringv1.PrometheusSpec{
|
||||
CommonPrometheusFields: monitoringv1.CommonPrometheusFields{
|
||||
EnableServiceLinks: test.enableServiceLinks,
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
if test.expectedEnableServiceLinks != nil {
|
||||
require.NotNil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be non-nil")
|
||||
require.Equal(t, *test.expectedEnableServiceLinks, *sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to match")
|
||||
} else {
|
||||
require.Nil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -478,6 +478,7 @@ func makeStatefulSetSpec(tr *monitoringv1.ThanosRuler, config Config, ruleConfig
|
|||
Affinity: tr.Spec.Affinity,
|
||||
TopologySpreadConstraints: tr.Spec.TopologySpreadConstraints,
|
||||
HostAliases: operator.MakeHostAliases(tr.Spec.HostAliases),
|
||||
EnableServiceLinks: tr.Spec.EnableServiceLinks,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1015,3 +1015,32 @@ func TestStatefulSetDNSPolicyAndDNSConfig(t *testing.T) {
|
|||
},
|
||||
}, sset.Spec.Template.Spec.DNSConfig, "expected DNS configuration to match")
|
||||
}
|
||||
|
||||
func TestStatefulSetenableServiceLinks(t *testing.T) {
|
||||
tests := []struct {
|
||||
enableServiceLinks *bool
|
||||
expectedEnableServiceLinks *bool
|
||||
}{
|
||||
{enableServiceLinks: ptr.To(false), expectedEnableServiceLinks: ptr.To(false)},
|
||||
{enableServiceLinks: ptr.To(true), expectedEnableServiceLinks: ptr.To(true)},
|
||||
{enableServiceLinks: nil, expectedEnableServiceLinks: nil},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
sset, err := makeStatefulSet(&monitoringv1.ThanosRuler{
|
||||
ObjectMeta: metav1.ObjectMeta{},
|
||||
Spec: monitoringv1.ThanosRulerSpec{
|
||||
QueryEndpoints: emptyQueryEndpoints,
|
||||
EnableServiceLinks: test.enableServiceLinks,
|
||||
},
|
||||
}, defaultTestConfig, nil, "", &operator.ShardedSecret{})
|
||||
require.NoError(t, err)
|
||||
|
||||
if test.expectedEnableServiceLinks != nil {
|
||||
require.NotNil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be non-nil")
|
||||
require.Equal(t, *test.expectedEnableServiceLinks, *sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to match")
|
||||
} else {
|
||||
require.Nil(t, sset.Spec.Template.Spec.EnableServiceLinks, "expected enableServiceLinks to be nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue