mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
statefulset PersistentVolumeClaimDeletePolicy api change
This commit is contained in:
parent
0feba0c4ee
commit
e4e735cd1c
@ -40,6 +40,17 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
|||||||
if len(s.Spec.UpdateStrategy.Type) == 0 {
|
if len(s.Spec.UpdateStrategy.Type) == 0 {
|
||||||
s.Spec.UpdateStrategy.Type = apps.RollingUpdateStatefulSetStrategyType
|
s.Spec.UpdateStrategy.Type = apps.RollingUpdateStatefulSetStrategyType
|
||||||
}
|
}
|
||||||
|
if s.Spec.PersistentVolumeClaimRetentionPolicy == nil {
|
||||||
|
policies := []apps.PersistentVolumeClaimRetentionPolicyType{
|
||||||
|
apps.RetainPersistentVolumeClaimRetentionPolicyType,
|
||||||
|
apps.DeletePersistentVolumeClaimRetentionPolicyType,
|
||||||
|
}
|
||||||
|
choice := int32(c.Rand.Int31())
|
||||||
|
s.Spec.PersistentVolumeClaimRetentionPolicy = &apps.StatefulSetPersistentVolumeClaimRetentionPolicy{
|
||||||
|
WhenDeleted: policies[choice&1],
|
||||||
|
WhenScaled: policies[(choice>>1)&1],
|
||||||
|
}
|
||||||
|
}
|
||||||
if s.Spec.RevisionHistoryLimit == nil {
|
if s.Spec.RevisionHistoryLimit == nil {
|
||||||
s.Spec.RevisionHistoryLimit = new(int32)
|
s.Spec.RevisionHistoryLimit = new(int32)
|
||||||
*s.Spec.RevisionHistoryLimit = 10
|
*s.Spec.RevisionHistoryLimit = 10
|
||||||
|
@ -97,6 +97,40 @@ type RollingUpdateStatefulSetStrategy struct {
|
|||||||
Partition int32
|
Partition int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine
|
||||||
|
// when volumes from the VolumeClaimTemplates will be deleted when the controlling StatefulSet is
|
||||||
|
// deleted or scaled down.
|
||||||
|
type PersistentVolumeClaimRetentionPolicyType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RetainPersistentVolumeClaimRetentionPolicyType is the default
|
||||||
|
// PersistentVolumeClaimRetentionPolicy and specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will not be deleted.
|
||||||
|
RetainPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Retain"
|
||||||
|
// DeletePersistentVolumeClaimRetentionPolicyType specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will be deleted in the scenario specified in
|
||||||
|
// StatefulSetPersistentVolumeClaimPolicy.
|
||||||
|
DeletePersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs
|
||||||
|
// created from the StatefulSet VolumeClaimTemplates.
|
||||||
|
type StatefulSetPersistentVolumeClaimRetentionPolicy struct {
|
||||||
|
// 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.
|
||||||
|
WhenDeleted PersistentVolumeClaimRetentionPolicyType
|
||||||
|
// 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.
|
||||||
|
WhenScaled PersistentVolumeClaimRetentionPolicyType
|
||||||
|
}
|
||||||
|
|
||||||
// A StatefulSetSpec is the specification of a StatefulSet.
|
// A StatefulSetSpec is the specification of a StatefulSet.
|
||||||
type StatefulSetSpec struct {
|
type StatefulSetSpec struct {
|
||||||
// Replicas is the desired number of replicas of the given Template.
|
// Replicas is the desired number of replicas of the given Template.
|
||||||
@ -164,6 +198,12 @@ type StatefulSetSpec struct {
|
|||||||
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
||||||
// +optional
|
// +optional
|
||||||
MinReadySeconds int32
|
MinReadySeconds int32
|
||||||
|
|
||||||
|
// PersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from
|
||||||
|
// the StatefulSet VolumeClaimTemplates. This requires the
|
||||||
|
// StatefulSetAutoDeletePVC feature gate to be enabled, which is alpha.
|
||||||
|
// +optional
|
||||||
|
PersistentVolumeClaimRetentionPolicy *StatefulSetPersistentVolumeClaimRetentionPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatefulSetStatus represents the current state of a StatefulSet.
|
// StatefulSetStatus represents the current state of a StatefulSet.
|
||||||
|
@ -20,6 +20,8 @@ import (
|
|||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
|
"k8s.io/kubernetes/pkg/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||||
@ -117,6 +119,18 @@ func SetDefaults_StatefulSet(obj *appsv1.StatefulSet) {
|
|||||||
*obj.Spec.UpdateStrategy.RollingUpdate.Partition = 0
|
*obj.Spec.UpdateStrategy.RollingUpdate.Partition = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetAutoDeletePVC) {
|
||||||
|
if obj.Spec.PersistentVolumeClaimRetentionPolicy == nil {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy = &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{}
|
||||||
|
}
|
||||||
|
if len(obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted) == 0 {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted = appsv1.RetainPersistentVolumeClaimRetentionPolicyType
|
||||||
|
}
|
||||||
|
if len(obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled) == 0 {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled = appsv1.RetainPersistentVolumeClaimRetentionPolicyType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if obj.Spec.Replicas == nil {
|
if obj.Spec.Replicas == nil {
|
||||||
obj.Spec.Replicas = new(int32)
|
obj.Spec.Replicas = new(int32)
|
||||||
*obj.Spec.Replicas = 1
|
*obj.Spec.Replicas = 1
|
||||||
|
@ -21,6 +21,8 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
|
"k8s.io/kubernetes/pkg/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||||
@ -46,6 +48,19 @@ func SetDefaults_StatefulSet(obj *appsv1beta1.StatefulSet) {
|
|||||||
obj.Labels = labels
|
obj.Labels = labels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetAutoDeletePVC) {
|
||||||
|
if obj.Spec.PersistentVolumeClaimRetentionPolicy == nil {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy = &appsv1beta1.StatefulSetPersistentVolumeClaimRetentionPolicy{}
|
||||||
|
}
|
||||||
|
if len(obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted) == 0 {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted = appsv1beta1.RetainPersistentVolumeClaimRetentionPolicyType
|
||||||
|
}
|
||||||
|
if len(obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled) == 0 {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled = appsv1beta1.RetainPersistentVolumeClaimRetentionPolicyType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if obj.Spec.Replicas == nil {
|
if obj.Spec.Replicas == nil {
|
||||||
obj.Spec.Replicas = new(int32)
|
obj.Spec.Replicas = new(int32)
|
||||||
*obj.Spec.Replicas = 1
|
*obj.Spec.Replicas = 1
|
||||||
|
@ -20,6 +20,8 @@ import (
|
|||||||
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
|
"k8s.io/kubernetes/pkg/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||||
@ -72,6 +74,18 @@ func SetDefaults_StatefulSet(obj *appsv1beta2.StatefulSet) {
|
|||||||
*obj.Spec.UpdateStrategy.RollingUpdate.Partition = 0
|
*obj.Spec.UpdateStrategy.RollingUpdate.Partition = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetAutoDeletePVC) {
|
||||||
|
if obj.Spec.PersistentVolumeClaimRetentionPolicy == nil {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy = &appsv1beta2.StatefulSetPersistentVolumeClaimRetentionPolicy{}
|
||||||
|
}
|
||||||
|
if len(obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted) == 0 {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenDeleted = appsv1beta2.RetainPersistentVolumeClaimRetentionPolicyType
|
||||||
|
}
|
||||||
|
if len(obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled) == 0 {
|
||||||
|
obj.Spec.PersistentVolumeClaimRetentionPolicy.WhenScaled = appsv1beta2.RetainPersistentVolumeClaimRetentionPolicyType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if obj.Spec.Replicas == nil {
|
if obj.Spec.Replicas == nil {
|
||||||
obj.Spec.Replicas = new(int32)
|
obj.Spec.Replicas = new(int32)
|
||||||
*obj.Spec.Replicas = 1
|
*obj.Spec.Replicas = 1
|
||||||
|
@ -69,6 +69,26 @@ func ValidatePodTemplateSpecForStatefulSet(template *api.PodTemplateSpec, select
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ValidatePersistentVolumeClaimRetentionPolicyType(policy apps.PersistentVolumeClaimRetentionPolicyType, fldPath *field.Path) field.ErrorList {
|
||||||
|
var allErrs field.ErrorList
|
||||||
|
switch policy {
|
||||||
|
case apps.RetainPersistentVolumeClaimRetentionPolicyType:
|
||||||
|
case apps.DeletePersistentVolumeClaimRetentionPolicyType:
|
||||||
|
default:
|
||||||
|
allErrs = append(allErrs, field.NotSupported(fldPath, policy, []string{string(apps.RetainPersistentVolumeClaimRetentionPolicyType), string(apps.DeletePersistentVolumeClaimRetentionPolicyType)}))
|
||||||
|
}
|
||||||
|
return allErrs
|
||||||
|
}
|
||||||
|
|
||||||
|
func ValidatePersistentVolumeClaimRetentionPolicy(policy *apps.StatefulSetPersistentVolumeClaimRetentionPolicy, fldPath *field.Path) field.ErrorList {
|
||||||
|
var allErrs field.ErrorList
|
||||||
|
if policy != nil {
|
||||||
|
allErrs = append(allErrs, ValidatePersistentVolumeClaimRetentionPolicyType(policy.WhenDeleted, fldPath.Child("whenDeleted"))...)
|
||||||
|
allErrs = append(allErrs, ValidatePersistentVolumeClaimRetentionPolicyType(policy.WhenScaled, fldPath.Child("whenScaled"))...)
|
||||||
|
}
|
||||||
|
return allErrs
|
||||||
|
}
|
||||||
|
|
||||||
// ValidateStatefulSetSpec tests if required fields in the StatefulSet spec are set.
|
// ValidateStatefulSetSpec tests if required fields in the StatefulSet spec are set.
|
||||||
func ValidateStatefulSetSpec(spec *apps.StatefulSetSpec, fldPath *field.Path, opts apivalidation.PodValidationOptions) field.ErrorList {
|
func ValidateStatefulSetSpec(spec *apps.StatefulSetSpec, fldPath *field.Path, opts apivalidation.PodValidationOptions) field.ErrorList {
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
@ -108,6 +128,8 @@ func ValidateStatefulSetSpec(spec *apps.StatefulSetSpec, fldPath *field.Path, op
|
|||||||
apps.OnDeleteStatefulSetStrategyType)))
|
apps.OnDeleteStatefulSetStrategyType)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allErrs = append(allErrs, ValidatePersistentVolumeClaimRetentionPolicy(spec.PersistentVolumeClaimRetentionPolicy, fldPath.Child("persistentVolumeClaimRetentionPolicy"))...)
|
||||||
|
|
||||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.Replicas), fldPath.Child("replicas"))...)
|
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.Replicas), fldPath.Child("replicas"))...)
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetMinReadySeconds) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetMinReadySeconds) {
|
||||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.MinReadySeconds), fldPath.Child("minReadySeconds"))...)
|
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.MinReadySeconds), fldPath.Child("minReadySeconds"))...)
|
||||||
@ -152,18 +174,18 @@ func ValidateStatefulSetUpdate(statefulSet, oldStatefulSet *apps.StatefulSet) fi
|
|||||||
// statefulset updates aren't super common and general updates are likely to be touching spec, so we'll do this
|
// statefulset updates aren't super common and general updates are likely to be touching spec, so we'll do this
|
||||||
// deep copy right away. This avoids mutating our inputs
|
// deep copy right away. This avoids mutating our inputs
|
||||||
newStatefulSetClone := statefulSet.DeepCopy()
|
newStatefulSetClone := statefulSet.DeepCopy()
|
||||||
newStatefulSetClone.Spec.Replicas = oldStatefulSet.Spec.Replicas // +k8s:verify-mutation:reason=clone
|
newStatefulSetClone.Spec.Replicas = oldStatefulSet.Spec.Replicas // +k8s:verify-mutation:reason=clone
|
||||||
newStatefulSetClone.Spec.Template = oldStatefulSet.Spec.Template // +k8s:verify-mutation:reason=clone
|
newStatefulSetClone.Spec.Template = oldStatefulSet.Spec.Template // +k8s:verify-mutation:reason=clone
|
||||||
newStatefulSetClone.Spec.UpdateStrategy = oldStatefulSet.Spec.UpdateStrategy // +k8s:verify-mutation:reason=clone
|
newStatefulSetClone.Spec.UpdateStrategy = oldStatefulSet.Spec.UpdateStrategy // +k8s:verify-mutation:reason=clone
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetMinReadySeconds) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetMinReadySeconds) {
|
||||||
newStatefulSetClone.Spec.MinReadySeconds = oldStatefulSet.Spec.MinReadySeconds // +k8s:verify-mutation:reason=clone
|
newStatefulSetClone.Spec.MinReadySeconds = oldStatefulSet.Spec.MinReadySeconds // +k8s:verify-mutation:reason=clone
|
||||||
}
|
}
|
||||||
|
newStatefulSetClone.Spec.PersistentVolumeClaimRetentionPolicy = oldStatefulSet.Spec.PersistentVolumeClaimRetentionPolicy // +k8s:verify-mutation:reason=clone
|
||||||
if !apiequality.Semantic.DeepEqual(newStatefulSetClone.Spec, oldStatefulSet.Spec) {
|
if !apiequality.Semantic.DeepEqual(newStatefulSetClone.Spec, oldStatefulSet.Spec) {
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetMinReadySeconds) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetMinReadySeconds) {
|
||||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to statefulset spec for fields other than 'replicas', 'template', 'minReadySeconds' and 'updateStrategy' are forbidden"))
|
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to statefulset spec for fields other than 'replicas', 'template', 'updateStrategy' and 'persistentVolumeClaimRetentionPolicy' are forbidden"))
|
||||||
} else {
|
} else {
|
||||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to statefulset spec for fields other than 'replicas', 'template' and 'updateStrategy' are forbidden"))
|
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to statefulset spec for fields other than 'replicas', 'template', 'updateStrategy', 'minReadySeconds' and 'persistentVolumeClaimRetentionPolicy' are forbidden"))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(statefulSet.Spec.Replicas), field.NewPath("spec", "replicas"))...)
|
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(statefulSet.Spec.Replicas), field.NewPath("spec", "replicas"))...)
|
||||||
|
@ -88,6 +88,7 @@ func (statefulSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obj
|
|||||||
statefulSet.Status = apps.StatefulSetStatus{}
|
statefulSet.Status = apps.StatefulSetStatus{}
|
||||||
|
|
||||||
statefulSet.Generation = 1
|
statefulSet.Generation = 1
|
||||||
|
|
||||||
dropStatefulSetDisabledFields(statefulSet, nil)
|
dropStatefulSetDisabledFields(statefulSet, nil)
|
||||||
pod.DropDisabledTemplateFields(&statefulSet.Spec.Template, nil)
|
pod.DropDisabledTemplateFields(&statefulSet.Spec.Template, nil)
|
||||||
}
|
}
|
||||||
@ -122,6 +123,12 @@ func dropStatefulSetDisabledFields(newSS *apps.StatefulSet, oldSS *apps.Stateful
|
|||||||
newSS.Spec.MinReadySeconds = int32(0)
|
newSS.Spec.MinReadySeconds = int32(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetAutoDeletePVC) {
|
||||||
|
if oldStatefulSet == nil || oldStatefulSet.Spec.PersistentVolumeClaimRetentionPolicy == nil {
|
||||||
|
newStatefulSet.Spec.PersistentVolumeClaimRetentionPolicy = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// minReadySecondsFieldsInUse returns true if fields related to StatefulSet minReadySeconds are set and
|
// minReadySecondsFieldsInUse returns true if fields related to StatefulSet minReadySeconds are set and
|
||||||
|
@ -116,6 +116,40 @@ type RollingUpdateStatefulSetStrategy struct {
|
|||||||
Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"`
|
Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine
|
||||||
|
// when volumes from the VolumeClaimTemplates will be deleted when the controlling StatefulSet is
|
||||||
|
// deleted or scaled down.
|
||||||
|
type PersistentVolumeClaimRetentionPolicyType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RetainPersistentVolumeClaimRetentionPolicyType is the default
|
||||||
|
// PersistentVolumeClaimRetentionPolicy and specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will not be deleted.
|
||||||
|
RetainPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Retain"
|
||||||
|
// RetentionPersistentVolumeClaimRetentionPolicyType specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will be deleted in the scenario specified in
|
||||||
|
// StatefulSetPersistentVolumeClaimRetentionPolicy.
|
||||||
|
DeletePersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs
|
||||||
|
// created from the StatefulSet VolumeClaimTemplates.
|
||||||
|
type StatefulSetPersistentVolumeClaimRetentionPolicy struct {
|
||||||
|
// 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.
|
||||||
|
WhenDeleted PersistentVolumeClaimRetentionPolicyType `json:"whenDeleted,omitempty" protobuf:"bytes,1,opt,name=whenDeleted,casttype=PersistentVolumeClaimRetentionPolicyType"`
|
||||||
|
// 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.
|
||||||
|
WhenScaled PersistentVolumeClaimRetentionPolicyType `json:"whenScaled,omitempty" protobuf:"bytes,2,opt,name=whenScaled,casttype=PersistentVolumeClaimRetentionPolicyType"`
|
||||||
|
}
|
||||||
|
|
||||||
// A StatefulSetSpec is the specification of a StatefulSet.
|
// A StatefulSetSpec is the specification of a StatefulSet.
|
||||||
type StatefulSetSpec struct {
|
type StatefulSetSpec struct {
|
||||||
// replicas is the desired number of replicas of the given Template.
|
// replicas is the desired number of replicas of the given Template.
|
||||||
@ -182,6 +216,15 @@ type StatefulSetSpec struct {
|
|||||||
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
||||||
// +optional
|
// +optional
|
||||||
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
|
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
|
||||||
|
|
||||||
|
// persistentVolumeClaimRetentionPolicy describes the lifecycle of persistent
|
||||||
|
// volume claims created from volumeClaimTemplates. By default, all persistent
|
||||||
|
// volume claims are created as needed and retained until manually deleted. This
|
||||||
|
// policy allows the lifecycle to be altered, for example by deleting persistent
|
||||||
|
// volume claims when their stateful set is deleted, or when their pod is scaled
|
||||||
|
// down. This requires the StatefulSetAutoDeletePVC feature gate to be enabled,
|
||||||
|
// which is alpha. +optional
|
||||||
|
PersistentVolumeClaimRetentionPolicy *StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty" protobuf:"bytes,9,opt,name=persistentVolumeClaimRetentionPolicy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatefulSetStatus represents the current state of a StatefulSet.
|
// StatefulSetStatus represents the current state of a StatefulSet.
|
||||||
|
@ -158,6 +158,40 @@ type RollingUpdateStatefulSetStrategy struct {
|
|||||||
Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"`
|
Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine
|
||||||
|
// when volumes from the VolumeClaimTemplates will be deleted when the controlling StatefulSet is
|
||||||
|
// deleted or scaled down.
|
||||||
|
type PersistentVolumeClaimRetentionPolicyType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RetainPersistentVolumeClaimRetentionPolicyType is the default
|
||||||
|
// PersistentVolumeClaimRetentionPolicy and specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will not be deleted.
|
||||||
|
RetainPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Retain"
|
||||||
|
// RetentionPersistentVolumeClaimRetentionPolicyType specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will be deleted in the scenario specified in
|
||||||
|
// StatefulSetPersistentVolumeClaimRetentionPolicy.
|
||||||
|
RetentionPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs
|
||||||
|
// created from the StatefulSet VolumeClaimTemplates.
|
||||||
|
type StatefulSetPersistentVolumeClaimRetentionPolicy struct {
|
||||||
|
// 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.
|
||||||
|
WhenDeleted PersistentVolumeClaimRetentionPolicyType `json:"whenDeleted,omitempty" protobuf:"bytes,1,opt,name=whenDeleted,casttype=PersistentVolumeClaimRetentionPolicyType"`
|
||||||
|
// 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.
|
||||||
|
WhenScaled PersistentVolumeClaimRetentionPolicyType `json:"whenScaled,omitempty" protobuf:"bytes,2,opt,name=whenScaled,casttype=PersistentVolumeClaimRetentionPolicyType"`
|
||||||
|
}
|
||||||
|
|
||||||
// A StatefulSetSpec is the specification of a StatefulSet.
|
// A StatefulSetSpec is the specification of a StatefulSet.
|
||||||
type StatefulSetSpec struct {
|
type StatefulSetSpec struct {
|
||||||
// replicas is the desired number of replicas of the given Template.
|
// replicas is the desired number of replicas of the given Template.
|
||||||
@ -225,6 +259,12 @@ type StatefulSetSpec struct {
|
|||||||
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
||||||
// +optional
|
// +optional
|
||||||
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
|
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
|
||||||
|
|
||||||
|
// PersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from
|
||||||
|
// the StatefulSet VolumeClaimTemplates. This requires the
|
||||||
|
// StatefulSetAutoDeletePVC feature gate to be enabled, which is alpha.
|
||||||
|
// +optional
|
||||||
|
PersistentVolumeClaimRetentionPolicy *StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty" protobuf:"bytes,10,opt,name=persistentVolumeClaimRetentionPolicy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatefulSetStatus represents the current state of a StatefulSet.
|
// StatefulSetStatus represents the current state of a StatefulSet.
|
||||||
|
@ -169,6 +169,40 @@ type RollingUpdateStatefulSetStrategy struct {
|
|||||||
Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"`
|
Partition *int32 `json:"partition,omitempty" protobuf:"varint,1,opt,name=partition"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine
|
||||||
|
// when volumes from the VolumeClaimTemplates will be deleted when the controlling StatefulSet is
|
||||||
|
// deleted or scaled down.
|
||||||
|
type PersistentVolumeClaimRetentionPolicyType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RetainPersistentVolumeClaimRetentionPolicyType is the default
|
||||||
|
// PersistentVolumeClaimRetentionPolicy and specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will not be deleted.
|
||||||
|
RetainPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Retain"
|
||||||
|
// RetentionPersistentVolumeClaimRetentionPolicyType specifies that
|
||||||
|
// PersistentVolumeClaims associated with StatefulSet VolumeClaimTemplates
|
||||||
|
// will be deleted in the scenario specified in
|
||||||
|
// StatefulSetPersistentVolumeClaimRetentionPolicy.
|
||||||
|
RetentionPersistentVolumeClaimRetentionPolicyType PersistentVolumeClaimRetentionPolicyType = "Delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs
|
||||||
|
// created from the StatefulSet VolumeClaimTemplates.
|
||||||
|
type StatefulSetPersistentVolumeClaimRetentionPolicy struct {
|
||||||
|
// 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.
|
||||||
|
WhenDeleted PersistentVolumeClaimRetentionPolicyType `json:"whenDeleted,omitempty" protobuf:"bytes,1,opt,name=whenDeleted,casttype=PersistentVolumeClaimRetentionPolicyType"`
|
||||||
|
// 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.
|
||||||
|
WhenScaled PersistentVolumeClaimRetentionPolicyType `json:"whenScaled,omitempty" protobuf:"bytes,2,opt,name=whenScaled,casttype=PersistentVolumeClaimRetentionPolicyType"`
|
||||||
|
}
|
||||||
|
|
||||||
// A StatefulSetSpec is the specification of a StatefulSet.
|
// A StatefulSetSpec is the specification of a StatefulSet.
|
||||||
type StatefulSetSpec struct {
|
type StatefulSetSpec struct {
|
||||||
// replicas is the desired number of replicas of the given Template.
|
// replicas is the desired number of replicas of the given Template.
|
||||||
@ -235,6 +269,12 @@ type StatefulSetSpec struct {
|
|||||||
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
|
||||||
// +optional
|
// +optional
|
||||||
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
|
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
|
||||||
|
|
||||||
|
// PersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from
|
||||||
|
// the StatefulSet VolumeClaimTemplates. This requires the
|
||||||
|
// StatefulSetAutoDeletePVC feature gate to be enabled, which is alpha.
|
||||||
|
// +optional
|
||||||
|
PersistentVolumeClaimRetentionPolicy *StatefulSetPersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty" protobuf:"bytes,10,opt,name=persistentVolumeClaimRetentionPolicy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatefulSetStatus represents the current state of a StatefulSet.
|
// StatefulSetStatus represents the current state of a StatefulSet.
|
||||||
|
Loading…
Reference in New Issue
Block a user