mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-16 01:06:27 +00:00
feat: Add support for configuring STS persistentVolumeClaimRetentionPolicy (#6038)
Signed-off-by: adinhodovic <hodovicadin@gmail.com>
This commit is contained in:
parent
b51d46e668
commit
c0f9cef3fa
16 changed files with 394 additions and 75 deletions
85
Documentation/api.md
generated
85
Documentation/api.md
generated
|
@ -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
44
bundle.yaml
generated
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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"`
|
||||
|
||||
|
|
6
pkg/apis/monitoring/v1/zz_generated.deepcopy.go
generated
6
pkg/apis/monitoring/v1/zz_generated.deepcopy.go
generated
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
@ -55,6 +56,7 @@ type CommonPrometheusFieldsApplyConfiguration struct {
|
|||
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"`
|
||||
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue