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

feat: Add support for configuring STS persistentVolumeClaimRetentionPolicy (#6038)

Signed-off-by: adinhodovic <hodovicadin@gmail.com>
This commit is contained in:
Adin Hodovic 2023-11-14 13:41:40 +01:00 committed by GitHub
parent b51d46e668
commit c0f9cef3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 394 additions and 75 deletions

85
Documentation/api.md generated
View file

@ -1817,6 +1817,23 @@ container, that are generated as a result of StorageSpec objects.</p>
</tr>
<tr>
<td>
<code>persistentVolumeClaimRetentionPolicy</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#statefulsetpersistentvolumeclaimretentionpolicy-v1-apps">
Kubernetes apps/v1.StatefulSetPersistentVolumeClaimRetentionPolicy
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.
The default behavior is all PVCs are retained.
This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26.
It requires enabling the StatefulSetAutoDeletePVC feature gate.</p>
</td>
</tr>
<tr>
<td>
<code>web</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.PrometheusWebSpec">
@ -6062,6 +6079,23 @@ container, that are generated as a result of StorageSpec objects.</p>
</tr>
<tr>
<td>
<code>persistentVolumeClaimRetentionPolicy</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#statefulsetpersistentvolumeclaimretentionpolicy-v1-apps">
Kubernetes apps/v1.StatefulSetPersistentVolumeClaimRetentionPolicy
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.
The default behavior is all PVCs are retained.
This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26.
It requires enabling the StatefulSetAutoDeletePVC feature gate.</p>
</td>
</tr>
<tr>
<td>
<code>web</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.PrometheusWebSpec">
@ -9831,6 +9865,23 @@ container, that are generated as a result of StorageSpec objects.</p>
</tr>
<tr>
<td>
<code>persistentVolumeClaimRetentionPolicy</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#statefulsetpersistentvolumeclaimretentionpolicy-v1-apps">
Kubernetes apps/v1.StatefulSetPersistentVolumeClaimRetentionPolicy
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.
The default behavior is all PVCs are retained.
This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26.
It requires enabling the StatefulSetAutoDeletePVC feature gate.</p>
</td>
</tr>
<tr>
<td>
<code>web</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.PrometheusWebSpec">
@ -15154,6 +15205,23 @@ container, that are generated as a result of StorageSpec objects.</p>
</tr>
<tr>
<td>
<code>persistentVolumeClaimRetentionPolicy</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#statefulsetpersistentvolumeclaimretentionpolicy-v1-apps">
Kubernetes apps/v1.StatefulSetPersistentVolumeClaimRetentionPolicy
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.
The default behavior is all PVCs are retained.
This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26.
It requires enabling the StatefulSetAutoDeletePVC feature gate.</p>
</td>
</tr>
<tr>
<td>
<code>web</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.PrometheusWebSpec">
@ -19055,6 +19123,23 @@ container, that are generated as a result of StorageSpec objects.</p>
</tr>
<tr>
<td>
<code>persistentVolumeClaimRetentionPolicy</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#statefulsetpersistentvolumeclaimretentionpolicy-v1-apps">
Kubernetes apps/v1.StatefulSetPersistentVolumeClaimRetentionPolicy
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.
The default behavior is all PVCs are retained.
This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26.
It requires enabling the StatefulSetAutoDeletePVC feature gate.</p>
</td>
</tr>
<tr>
<td>
<code>web</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.PrometheusWebSpec">

44
bundle.yaml generated
View file

@ -18599,6 +18599,28 @@ spec:
description: When a Prometheus deployment is paused, no actions except
for deletion will be performed on the underlying objects.
type: boolean
persistentVolumeClaimRetentionPolicy:
description: The field controls if and how PVCs are deleted during
the lifecycle of a StatefulSet. The default behavior is all PVCs
are retained. This is an alpha field from kubernetes 1.23 until
1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC
feature gate.
properties:
whenDeleted:
description: WhenDeleted specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
deleted. The default policy of `Retain` causes PVCs to not be
affected by StatefulSet deletion. The `Delete` policy causes
those PVCs to be deleted.
type: string
whenScaled:
description: WhenScaled specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
scaled down. The default policy of `Retain` causes PVCs to not
be affected by a scaledown. The `Delete` policy causes the associated
PVCs for any excess pods above the replica count to be deleted.
type: string
type: object
podMetadata:
description: "PodMetadata configures labels and annotations which
are propagated to the Prometheus pods. \n The following items are
@ -27472,6 +27494,28 @@ spec:
description: When a Prometheus deployment is paused, no actions except
for deletion will be performed on the underlying objects.
type: boolean
persistentVolumeClaimRetentionPolicy:
description: The field controls if and how PVCs are deleted during
the lifecycle of a StatefulSet. The default behavior is all PVCs
are retained. This is an alpha field from kubernetes 1.23 until
1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC
feature gate.
properties:
whenDeleted:
description: WhenDeleted specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
deleted. The default policy of `Retain` causes PVCs to not be
affected by StatefulSet deletion. The `Delete` policy causes
those PVCs to be deleted.
type: string
whenScaled:
description: WhenScaled specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
scaled down. The default policy of `Retain` causes PVCs to not
be affected by a scaledown. The `Delete` policy causes the associated
PVCs for any excess pods above the replica count to be deleted.
type: string
type: object
podMetadata:
description: "PodMetadata configures labels and annotations which
are propagated to the Prometheus pods. \n The following items are

View file

@ -4084,6 +4084,28 @@ spec:
description: When a Prometheus deployment is paused, no actions except
for deletion will be performed on the underlying objects.
type: boolean
persistentVolumeClaimRetentionPolicy:
description: The field controls if and how PVCs are deleted during
the lifecycle of a StatefulSet. The default behavior is all PVCs
are retained. This is an alpha field from kubernetes 1.23 until
1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC
feature gate.
properties:
whenDeleted:
description: WhenDeleted specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
deleted. The default policy of `Retain` causes PVCs to not be
affected by StatefulSet deletion. The `Delete` policy causes
those PVCs to be deleted.
type: string
whenScaled:
description: WhenScaled specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
scaled down. The default policy of `Retain` causes PVCs to not
be affected by a scaledown. The `Delete` policy causes the associated
PVCs for any excess pods above the replica count to be deleted.
type: string
type: object
podMetadata:
description: "PodMetadata configures labels and annotations which
are propagated to the Prometheus pods. \n The following items are

View file

@ -4515,6 +4515,28 @@ spec:
description: When a Prometheus deployment is paused, no actions except
for deletion will be performed on the underlying objects.
type: boolean
persistentVolumeClaimRetentionPolicy:
description: The field controls if and how PVCs are deleted during
the lifecycle of a StatefulSet. The default behavior is all PVCs
are retained. This is an alpha field from kubernetes 1.23 until
1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC
feature gate.
properties:
whenDeleted:
description: WhenDeleted specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
deleted. The default policy of `Retain` causes PVCs to not be
affected by StatefulSet deletion. The `Delete` policy causes
those PVCs to be deleted.
type: string
whenScaled:
description: WhenScaled specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
scaled down. The default policy of `Retain` causes PVCs to not
be affected by a scaledown. The `Delete` policy causes the associated
PVCs for any excess pods above the replica count to be deleted.
type: string
type: object
podMetadata:
description: "PodMetadata configures labels and annotations which
are propagated to the Prometheus pods. \n The following items are

View file

@ -4085,6 +4085,28 @@ spec:
description: When a Prometheus deployment is paused, no actions except
for deletion will be performed on the underlying objects.
type: boolean
persistentVolumeClaimRetentionPolicy:
description: The field controls if and how PVCs are deleted during
the lifecycle of a StatefulSet. The default behavior is all PVCs
are retained. This is an alpha field from kubernetes 1.23 until
1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC
feature gate.
properties:
whenDeleted:
description: WhenDeleted specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
deleted. The default policy of `Retain` causes PVCs to not be
affected by StatefulSet deletion. The `Delete` policy causes
those PVCs to be deleted.
type: string
whenScaled:
description: WhenScaled specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
scaled down. The default policy of `Retain` causes PVCs to not
be affected by a scaledown. The `Delete` policy causes the associated
PVCs for any excess pods above the replica count to be deleted.
type: string
type: object
podMetadata:
description: "PodMetadata configures labels and annotations which
are propagated to the Prometheus pods. \n The following items are

View file

@ -4516,6 +4516,28 @@ spec:
description: When a Prometheus deployment is paused, no actions except
for deletion will be performed on the underlying objects.
type: boolean
persistentVolumeClaimRetentionPolicy:
description: The field controls if and how PVCs are deleted during
the lifecycle of a StatefulSet. The default behavior is all PVCs
are retained. This is an alpha field from kubernetes 1.23 until
1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC
feature gate.
properties:
whenDeleted:
description: WhenDeleted specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
deleted. The default policy of `Retain` causes PVCs to not be
affected by StatefulSet deletion. The `Delete` policy causes
those PVCs to be deleted.
type: string
whenScaled:
description: WhenScaled specifies what happens to PVCs created
from StatefulSet VolumeClaimTemplates when the StatefulSet is
scaled down. The default policy of `Retain` causes PVCs to not
be affected by a scaledown. The `Delete` policy causes the associated
PVCs for any excess pods above the replica count to be deleted.
type: string
type: object
podMetadata:
description: "PodMetadata configures labels and annotations which
are propagated to the Prometheus pods. \n The following items are

View file

@ -3657,6 +3657,20 @@
"description": "When a Prometheus deployment is paused, no actions except for deletion will be performed on the underlying objects.",
"type": "boolean"
},
"persistentVolumeClaimRetentionPolicy": {
"description": "The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet. The default behavior is all PVCs are retained. This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC feature gate.",
"properties": {
"whenDeleted": {
"description": "WhenDeleted specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is deleted. The default policy of `Retain` causes PVCs to not be affected by StatefulSet deletion. The `Delete` policy causes those PVCs to be deleted.",
"type": "string"
},
"whenScaled": {
"description": "WhenScaled specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is scaled down. The default policy of `Retain` causes PVCs to not be affected by a scaledown. The `Delete` policy causes the associated PVCs for any excess pods above the replica count to be deleted.",
"type": "string"
}
},
"type": "object"
},
"podMetadata": {
"description": "PodMetadata configures labels and annotations which are propagated to the Prometheus pods. \n The following items are reserved and cannot be overridden: * \"prometheus\" label, set to the name of the Prometheus object. * \"app.kubernetes.io/instance\" label, set to the name of the Prometheus object. * \"app.kubernetes.io/managed-by\" label, set to \"prometheus-operator\". * \"app.kubernetes.io/name\" label, set to \"prometheus\". * \"app.kubernetes.io/version\" label, set to the Prometheus version. * \"operator.prometheus.io/name\" label, set to the name of the Prometheus object. * \"operator.prometheus.io/shard\" label, set to the shard number of the Prometheus object. * \"kubectl.kubernetes.io/default-container\" annotation, set to \"prometheus\".",
"properties": {

View file

@ -4095,6 +4095,20 @@
"description": "When a Prometheus deployment is paused, no actions except for deletion will be performed on the underlying objects.",
"type": "boolean"
},
"persistentVolumeClaimRetentionPolicy": {
"description": "The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet. The default behavior is all PVCs are retained. This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26. It requires enabling the StatefulSetAutoDeletePVC feature gate.",
"properties": {
"whenDeleted": {
"description": "WhenDeleted specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is deleted. The default policy of `Retain` causes PVCs to not be affected by StatefulSet deletion. The `Delete` policy causes those PVCs to be deleted.",
"type": "string"
},
"whenScaled": {
"description": "WhenScaled specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is scaled down. The default policy of `Retain` causes PVCs to not be affected by a scaledown. The `Delete` policy causes the associated PVCs for any excess pods above the replica count to be deleted.",
"type": "string"
}
},
"type": "object"
},
"podMetadata": {
"description": "PodMetadata configures labels and annotations which are propagated to the Prometheus pods. \n The following items are reserved and cannot be overridden: * \"prometheus\" label, set to the name of the Prometheus object. * \"app.kubernetes.io/instance\" label, set to the name of the Prometheus object. * \"app.kubernetes.io/managed-by\" label, set to \"prometheus-operator\". * \"app.kubernetes.io/name\" label, set to \"prometheus\". * \"app.kubernetes.io/version\" label, set to the Prometheus version. * \"operator.prometheus.io/name\" label, set to the name of the Prometheus object. * \"operator.prometheus.io/shard\" label, set to the shard number of the Prometheus object. * \"kubectl.kubernetes.io/default-container\" annotation, set to \"prometheus\".",
"properties": {

View file

@ -17,6 +17,7 @@ package v1
import (
"strings"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -281,6 +282,14 @@ type CommonPrometheusFields struct {
// container, that are generated as a result of StorageSpec objects.
VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"`
// The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.
// The default behavior is all PVCs are retained.
// This is an alpha field from kubernetes 1.23 until 1.26 and a beta field from 1.26.
// It requires enabling the StatefulSetAutoDeletePVC feature gate.
//
// +optional
PersistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"`
// Defines the configuration of the Prometheus web server.
Web *PrometheusWebSpec `json:"web,omitempty"`

View file

@ -20,6 +20,7 @@
package v1
import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
@ -677,6 +678,11 @@ func (in *CommonPrometheusFields) DeepCopyInto(out *CommonPrometheusFields) {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.PersistentVolumeClaimRetentionPolicy != nil {
in, out := &in.PersistentVolumeClaimRetentionPolicy, &out.PersistentVolumeClaimRetentionPolicy
*out = new(appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy)
**out = **in
}
if in.Web != nil {
in, out := &in.Web, &out.Web
*out = new(PrometheusWebSpec)

View file

@ -18,6 +18,7 @@ package v1
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@ -25,81 +26,82 @@ import (
// CommonPrometheusFieldsApplyConfiguration represents an declarative configuration of the CommonPrometheusFields type for use
// with apply.
type CommonPrometheusFieldsApplyConfiguration struct {
PodMetadata *EmbeddedObjectMetadataApplyConfiguration `json:"podMetadata,omitempty"`
ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"`
PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"`
PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"`
ProbeSelector *metav1.LabelSelector `json:"probeSelector,omitempty"`
ProbeNamespaceSelector *metav1.LabelSelector `json:"probeNamespaceSelector,omitempty"`
ScrapeConfigSelector *metav1.LabelSelector `json:"scrapeConfigSelector,omitempty"`
ScrapeConfigNamespaceSelector *metav1.LabelSelector `json:"scrapeConfigNamespaceSelector,omitempty"`
Version *string `json:"version,omitempty"`
Paused *bool `json:"paused,omitempty"`
Image *string `json:"image,omitempty"`
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
Shards *int32 `json:"shards,omitempty"`
ReplicaExternalLabelName *string `json:"replicaExternalLabelName,omitempty"`
PrometheusExternalLabelName *string `json:"prometheusExternalLabelName,omitempty"`
LogLevel *string `json:"logLevel,omitempty"`
LogFormat *string `json:"logFormat,omitempty"`
ScrapeInterval *monitoringv1.Duration `json:"scrapeInterval,omitempty"`
ScrapeTimeout *monitoringv1.Duration `json:"scrapeTimeout,omitempty"`
ExternalLabels map[string]string `json:"externalLabels,omitempty"`
EnableRemoteWriteReceiver *bool `json:"enableRemoteWriteReceiver,omitempty"`
EnableFeatures []string `json:"enableFeatures,omitempty"`
ExternalURL *string `json:"externalUrl,omitempty"`
RoutePrefix *string `json:"routePrefix,omitempty"`
Storage *StorageSpecApplyConfiguration `json:"storage,omitempty"`
Volumes []corev1.Volume `json:"volumes,omitempty"`
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
Web *PrometheusWebSpecApplyConfiguration `json:"web,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
Secrets []string `json:"secrets,omitempty"`
ConfigMaps []string `json:"configMaps,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
RemoteWrite []RemoteWriteSpecApplyConfiguration `json:"remoteWrite,omitempty"`
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
ListenLocal *bool `json:"listenLocal,omitempty"`
Containers []corev1.Container `json:"containers,omitempty"`
InitContainers []corev1.Container `json:"initContainers,omitempty"`
AdditionalScrapeConfigs *corev1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"`
APIServerConfig *APIServerConfigApplyConfiguration `json:"apiserverConfig,omitempty"`
PriorityClassName *string `json:"priorityClassName,omitempty"`
PortName *string `json:"portName,omitempty"`
ArbitraryFSAccessThroughSMs *ArbitraryFSAccessThroughSMsConfigApplyConfiguration `json:"arbitraryFSAccessThroughSMs,omitempty"`
OverrideHonorLabels *bool `json:"overrideHonorLabels,omitempty"`
OverrideHonorTimestamps *bool `json:"overrideHonorTimestamps,omitempty"`
IgnoreNamespaceSelectors *bool `json:"ignoreNamespaceSelectors,omitempty"`
EnforcedNamespaceLabel *string `json:"enforcedNamespaceLabel,omitempty"`
EnforcedSampleLimit *uint64 `json:"enforcedSampleLimit,omitempty"`
EnforcedTargetLimit *uint64 `json:"enforcedTargetLimit,omitempty"`
EnforcedLabelLimit *uint64 `json:"enforcedLabelLimit,omitempty"`
EnforcedLabelNameLengthLimit *uint64 `json:"enforcedLabelNameLengthLimit,omitempty"`
EnforcedLabelValueLengthLimit *uint64 `json:"enforcedLabelValueLengthLimit,omitempty"`
EnforcedKeepDroppedTargets *uint64 `json:"enforcedKeepDroppedTargets,omitempty"`
EnforcedBodySizeLimit *monitoringv1.ByteSize `json:"enforcedBodySizeLimit,omitempty"`
MinReadySeconds *uint32 `json:"minReadySeconds,omitempty"`
HostAliases []HostAliasApplyConfiguration `json:"hostAliases,omitempty"`
AdditionalArgs []ArgumentApplyConfiguration `json:"additionalArgs,omitempty"`
WALCompression *bool `json:"walCompression,omitempty"`
ExcludedFromEnforcement []ObjectReferenceApplyConfiguration `json:"excludedFromEnforcement,omitempty"`
HostNetwork *bool `json:"hostNetwork,omitempty"`
PodTargetLabels []string `json:"podTargetLabels,omitempty"`
TracingConfig *PrometheusTracingConfigApplyConfiguration `json:"tracingConfig,omitempty"`
BodySizeLimit *monitoringv1.ByteSize `json:"bodySizeLimit,omitempty"`
SampleLimit *uint64 `json:"sampleLimit,omitempty"`
TargetLimit *uint64 `json:"targetLimit,omitempty"`
LabelLimit *uint64 `json:"labelLimit,omitempty"`
LabelNameLengthLimit *uint64 `json:"labelNameLengthLimit,omitempty"`
LabelValueLengthLimit *uint64 `json:"labelValueLengthLimit,omitempty"`
KeepDroppedTargets *uint64 `json:"keepDroppedTargets,omitempty"`
PodMetadata *EmbeddedObjectMetadataApplyConfiguration `json:"podMetadata,omitempty"`
ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"`
PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"`
PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"`
ProbeSelector *metav1.LabelSelector `json:"probeSelector,omitempty"`
ProbeNamespaceSelector *metav1.LabelSelector `json:"probeNamespaceSelector,omitempty"`
ScrapeConfigSelector *metav1.LabelSelector `json:"scrapeConfigSelector,omitempty"`
ScrapeConfigNamespaceSelector *metav1.LabelSelector `json:"scrapeConfigNamespaceSelector,omitempty"`
Version *string `json:"version,omitempty"`
Paused *bool `json:"paused,omitempty"`
Image *string `json:"image,omitempty"`
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
Shards *int32 `json:"shards,omitempty"`
ReplicaExternalLabelName *string `json:"replicaExternalLabelName,omitempty"`
PrometheusExternalLabelName *string `json:"prometheusExternalLabelName,omitempty"`
LogLevel *string `json:"logLevel,omitempty"`
LogFormat *string `json:"logFormat,omitempty"`
ScrapeInterval *monitoringv1.Duration `json:"scrapeInterval,omitempty"`
ScrapeTimeout *monitoringv1.Duration `json:"scrapeTimeout,omitempty"`
ExternalLabels map[string]string `json:"externalLabels,omitempty"`
EnableRemoteWriteReceiver *bool `json:"enableRemoteWriteReceiver,omitempty"`
EnableFeatures []string `json:"enableFeatures,omitempty"`
ExternalURL *string `json:"externalUrl,omitempty"`
RoutePrefix *string `json:"routePrefix,omitempty"`
Storage *StorageSpecApplyConfiguration `json:"storage,omitempty"`
Volumes []corev1.Volume `json:"volumes,omitempty"`
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
PersistentVolumeClaimRetentionPolicy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"`
Web *PrometheusWebSpecApplyConfiguration `json:"web,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
Secrets []string `json:"secrets,omitempty"`
ConfigMaps []string `json:"configMaps,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
RemoteWrite []RemoteWriteSpecApplyConfiguration `json:"remoteWrite,omitempty"`
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
ListenLocal *bool `json:"listenLocal,omitempty"`
Containers []corev1.Container `json:"containers,omitempty"`
InitContainers []corev1.Container `json:"initContainers,omitempty"`
AdditionalScrapeConfigs *corev1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"`
APIServerConfig *APIServerConfigApplyConfiguration `json:"apiserverConfig,omitempty"`
PriorityClassName *string `json:"priorityClassName,omitempty"`
PortName *string `json:"portName,omitempty"`
ArbitraryFSAccessThroughSMs *ArbitraryFSAccessThroughSMsConfigApplyConfiguration `json:"arbitraryFSAccessThroughSMs,omitempty"`
OverrideHonorLabels *bool `json:"overrideHonorLabels,omitempty"`
OverrideHonorTimestamps *bool `json:"overrideHonorTimestamps,omitempty"`
IgnoreNamespaceSelectors *bool `json:"ignoreNamespaceSelectors,omitempty"`
EnforcedNamespaceLabel *string `json:"enforcedNamespaceLabel,omitempty"`
EnforcedSampleLimit *uint64 `json:"enforcedSampleLimit,omitempty"`
EnforcedTargetLimit *uint64 `json:"enforcedTargetLimit,omitempty"`
EnforcedLabelLimit *uint64 `json:"enforcedLabelLimit,omitempty"`
EnforcedLabelNameLengthLimit *uint64 `json:"enforcedLabelNameLengthLimit,omitempty"`
EnforcedLabelValueLengthLimit *uint64 `json:"enforcedLabelValueLengthLimit,omitempty"`
EnforcedKeepDroppedTargets *uint64 `json:"enforcedKeepDroppedTargets,omitempty"`
EnforcedBodySizeLimit *monitoringv1.ByteSize `json:"enforcedBodySizeLimit,omitempty"`
MinReadySeconds *uint32 `json:"minReadySeconds,omitempty"`
HostAliases []HostAliasApplyConfiguration `json:"hostAliases,omitempty"`
AdditionalArgs []ArgumentApplyConfiguration `json:"additionalArgs,omitempty"`
WALCompression *bool `json:"walCompression,omitempty"`
ExcludedFromEnforcement []ObjectReferenceApplyConfiguration `json:"excludedFromEnforcement,omitempty"`
HostNetwork *bool `json:"hostNetwork,omitempty"`
PodTargetLabels []string `json:"podTargetLabels,omitempty"`
TracingConfig *PrometheusTracingConfigApplyConfiguration `json:"tracingConfig,omitempty"`
BodySizeLimit *monitoringv1.ByteSize `json:"bodySizeLimit,omitempty"`
SampleLimit *uint64 `json:"sampleLimit,omitempty"`
TargetLimit *uint64 `json:"targetLimit,omitempty"`
LabelLimit *uint64 `json:"labelLimit,omitempty"`
LabelNameLengthLimit *uint64 `json:"labelNameLengthLimit,omitempty"`
LabelValueLengthLimit *uint64 `json:"labelValueLengthLimit,omitempty"`
KeepDroppedTargets *uint64 `json:"keepDroppedTargets,omitempty"`
}
// CommonPrometheusFieldsApplyConfiguration constructs an declarative configuration of the CommonPrometheusFields type for use with
@ -362,6 +364,14 @@ func (b *CommonPrometheusFieldsApplyConfiguration) WithVolumeMounts(values ...co
return b
}
// WithPersistentVolumeClaimRetentionPolicy sets the PersistentVolumeClaimRetentionPolicy 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 PersistentVolumeClaimRetentionPolicy field is set to the value of the last call.
func (b *CommonPrometheusFieldsApplyConfiguration) WithPersistentVolumeClaimRetentionPolicy(value appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy) *CommonPrometheusFieldsApplyConfiguration {
b.PersistentVolumeClaimRetentionPolicy = &value
return b
}
// WithWeb sets the Web 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 Web field is set to the value of the last call.

View file

@ -18,6 +18,7 @@ package v1
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@ -310,6 +311,14 @@ func (b *PrometheusSpecApplyConfiguration) WithVolumeMounts(values ...corev1.Vol
return b
}
// WithPersistentVolumeClaimRetentionPolicy sets the PersistentVolumeClaimRetentionPolicy 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 PersistentVolumeClaimRetentionPolicy field is set to the value of the last call.
func (b *PrometheusSpecApplyConfiguration) WithPersistentVolumeClaimRetentionPolicy(value appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy) *PrometheusSpecApplyConfiguration {
b.PersistentVolumeClaimRetentionPolicy = &value
return b
}
// WithWeb sets the Web 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 Web field is set to the value of the last call.

View file

@ -19,6 +19,7 @@ package v1alpha1
import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
v1 "github.com/prometheus-operator/prometheus-operator/pkg/client/applyconfiguration/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@ -289,6 +290,14 @@ func (b *PrometheusAgentSpecApplyConfiguration) WithVolumeMounts(values ...corev
return b
}
// WithPersistentVolumeClaimRetentionPolicy sets the PersistentVolumeClaimRetentionPolicy 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 PersistentVolumeClaimRetentionPolicy field is set to the value of the last call.
func (b *PrometheusAgentSpecApplyConfiguration) WithPersistentVolumeClaimRetentionPolicy(value appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy) *PrometheusAgentSpecApplyConfiguration {
b.PersistentVolumeClaimRetentionPolicy = &value
return b
}
// WithWeb sets the Web 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 Web field is set to the value of the last call.

View file

@ -153,6 +153,10 @@ func makeStatefulSet(
statefulset.Spec.Template.Spec.Volumes = append(statefulset.Spec.Template.Spec.Volumes, cpf.Volumes...)
if cpf.PersistentVolumeClaimRetentionPolicy != nil {
statefulset.Spec.PersistentVolumeClaimRetentionPolicy = cpf.PersistentVolumeClaimRetentionPolicy
}
if cpf.HostNetwork {
statefulset.Spec.Template.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
}

View file

@ -216,6 +216,10 @@ func makeStatefulSet(
statefulset.Spec.Template.Spec.Volumes = append(statefulset.Spec.Template.Spec.Volumes, cpf.Volumes...)
if cpf.PersistentVolumeClaimRetentionPolicy != nil {
statefulset.Spec.PersistentVolumeClaimRetentionPolicy = cpf.PersistentVolumeClaimRetentionPolicy
}
if cpf.HostNetwork {
statefulset.Spec.Template.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
}

View file

@ -2806,3 +2806,26 @@ func TestPodHostNetworkConfig(t *testing.T) {
t.Fatalf("expected DNSPolicy configuration to match due to hostNetwork but failed")
}
}
func TestPersistentVolumeClaimRetentionPolicy(t *testing.T) {
sset, err := makeStatefulSetFromPrometheus(monitoringv1.Prometheus{
ObjectMeta: metav1.ObjectMeta{},
Spec: monitoringv1.PrometheusSpec{
CommonPrometheusFields: monitoringv1.CommonPrometheusFields{
PersistentVolumeClaimRetentionPolicy: &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{
WhenDeleted: appsv1.DeletePersistentVolumeClaimRetentionPolicyType,
WhenScaled: appsv1.DeletePersistentVolumeClaimRetentionPolicyType,
},
},
},
})
require.NoError(t, err)
if sset.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted != appsv1.DeletePersistentVolumeClaimRetentionPolicyType {
t.Fatalf("expected persistentVolumeClaimDeletePolicy.WhenDeleted to be %s but got %s", appsv1.DeletePersistentVolumeClaimRetentionPolicyType, sset.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted)
}
if sset.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled != appsv1.DeletePersistentVolumeClaimRetentionPolicyType {
t.Fatalf("expected persistentVolumeClaimDeletePolicy.WhenScaled to be %s but got %s", appsv1.DeletePersistentVolumeClaimRetentionPolicyType, sset.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled)
}
}