statefulset

package
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 64 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager) error

Add creates a new StatefulSet Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller and Start it when the Manager is Started.

func ApplyRevision

func ApplyRevision(set *appsv1beta1.StatefulSet, revision *apps.ControllerRevision) (*appsv1beta1.StatefulSet, error)

ApplyRevision returns a new StatefulSet constructed by restoring the state in revision to set. If the returned error is nil, the returned StatefulSet is valid.

func GetStatefulsetConditition added in v0.3.0

func GetStatefulsetConditition(status appsv1beta1.StatefulSetStatus, condType apps.StatefulSetConditionType) *apps.StatefulSetCondition

GetStatefulsetConditition returns the condition with the provided type.

func Match

func Match(ss *appsv1beta1.StatefulSet, history *apps.ControllerRevision) (bool, error)

Match check if the given StatefulSet's template matches the template stored in the given history.

func NewStatefulsetCondition added in v0.3.0

func NewStatefulsetCondition(conditionType apps.StatefulSetConditionType, conditionStatus v1.ConditionStatus, reason, message string) apps.StatefulSetCondition

NewStatefulsetCondition creates a new statefulset condition.

func SetStatefulsetCondition added in v0.3.0

func SetStatefulsetCondition(status *appsv1beta1.StatefulSetStatus, condition apps.StatefulSetCondition)

SetStatefulsetCondition updates the statefulset to include the provided condition. If the condition that

func SortPodsAscendingOrdinal added in v0.9.0

func SortPodsAscendingOrdinal(pods []*v1.Pod)

SortPodsAscendingOrdinal sorts the given Pods according to their oridinals.

Types

type ReconcileStatefulSet

type ReconcileStatefulSet struct {
	// contains filtered or unexported fields
}

ReconcileStatefulSet reconciles a StatefulSet object

func (*ReconcileStatefulSet) Reconcile

func (ssc *ReconcileStatefulSet) Reconcile(ctx context.Context, request reconcile.Request) (res reconcile.Result, retErr error)

Reconcile reads that state of the cluster for a StatefulSet object and makes changes based on the state read and what is in the StatefulSet.Spec Automatically generate RBAC rules to allow the Controller to read and write Pods

type StatefulPodControl added in v1.1.0

type StatefulPodControl struct {
	// contains filtered or unexported fields
}

StatefulPodControl defines the interface that StatefulSetController uses to create, update, and delete Pods, Manipulation of objects is provided through objectMgr, which allows the k8s API to be mocked out for testing.

func NewStatefulPodControl added in v1.1.0

func NewStatefulPodControl(
	client clientset.Interface,
	podLister corelisters.PodLister,
	claimLister corelisters.PersistentVolumeClaimLister,
	recorder record.EventRecorder,
) *StatefulPodControl

NewStatefulPodControl constructs a StatefulPodControl using a realStatefulPodControlObjectManager with the given clientset, listers and EventRecorder.

func NewStatefulPodControlFromManager added in v1.1.0

func NewStatefulPodControlFromManager(om StatefulPodControlObjectManager, recorder record.EventRecorder) *StatefulPodControl

NewStatefulPodControlFromManager creates a StatefulPodControl using the given StatefulPodControlObjectManager and recorder.

func (*StatefulPodControl) ClaimsMatchRetentionPolicy added in v1.1.0

func (spc *StatefulPodControl) ClaimsMatchRetentionPolicy(set *appsv1beta1.StatefulSet, pod *v1.Pod) (bool, error)

ClaimsMatchRetentionPolicy returns false if the PVCs for pod are not consistent with set's PVC deletion policy. An error is returned if something is not consistent. This is expected if the pod is being otherwise updated, but a problem otherwise (see usage of this method in UpdateStatefulPod).

func (*StatefulPodControl) CreateStatefulPod added in v1.1.0

func (spc *StatefulPodControl) CreateStatefulPod(ctx context.Context, set *appsv1beta1.StatefulSet, pod *v1.Pod) error

func (*StatefulPodControl) DeleteStatefulPod added in v1.1.0

func (spc *StatefulPodControl) DeleteStatefulPod(set *appsv1beta1.StatefulSet, pod *v1.Pod) error

func (*StatefulPodControl) PodClaimIsStale added in v1.1.0

func (spc *StatefulPodControl) PodClaimIsStale(set *appsv1beta1.StatefulSet, pod *v1.Pod) (bool, error)

PodClaimIsStale returns true for a stale PVC that should block pod creation. If the scaling policy is deletion, and a PVC has an ownerRef that does not match the pod, the PVC is stale. This includes pods whose UID has not been created.

func (*StatefulPodControl) UpdatePodClaimForRetentionPolicy added in v1.1.0

func (spc *StatefulPodControl) UpdatePodClaimForRetentionPolicy(set *appsv1beta1.StatefulSet, pod *v1.Pod) error

UpdatePodClaimForRetentionPolicy updates the PVCs used by pod to match the PVC deletion policy of set.

func (*StatefulPodControl) UpdateStatefulPod added in v1.1.0

func (spc *StatefulPodControl) UpdateStatefulPod(set *appsv1beta1.StatefulSet, pod *v1.Pod) error

type StatefulPodControlObjectManager added in v1.1.0

type StatefulPodControlObjectManager interface {
	CreatePod(ctx context.Context, pod *v1.Pod) error
	GetPod(namespace, podName string) (*v1.Pod, error)
	UpdatePod(pod *v1.Pod) error
	DeletePod(pod *v1.Pod) error
	CreateClaim(claim *v1.PersistentVolumeClaim) error
	GetClaim(namespace, claimName string) (*v1.PersistentVolumeClaim, error)
	UpdateClaim(claim *v1.PersistentVolumeClaim) error
}

StatefulPodControlObjectManager abstracts the manipulation of Pods and PVCs. The real controller implements this with a clientset for writes and listers for reads; for tests we provide stubs.

type StatefulSetControlInterface added in v1.1.0

type StatefulSetControlInterface interface {
	// UpdateStatefulSet implements the control logic for Pod creation, update, and deletion, and
	// persistent volume creation, update, and deletion.
	// If an implementation returns a non-nil error, the invocation will be retried using a rate-limited strategy.
	// Implementors should sink any errors that they do not wish to trigger a retry, and they may feel free to
	// exit exceptionally at any point provided they wish the update to be re-run at a later point in time.
	UpdateStatefulSet(ctx context.Context, set *appsv1beta1.StatefulSet, pods []*v1.Pod) error
	// ListRevisions returns a array of the ControllerRevisions that represent the revisions of set. If the returned
	// error is nil, the returns slice of ControllerRevisions is valid.
	ListRevisions(set *appsv1beta1.StatefulSet) ([]*apps.ControllerRevision, error)
	// AdoptOrphanRevisions adopts any orphaned ControllerRevisions that match set's Selector. If all adoptions are
	// successful the returned error is nil.
	AdoptOrphanRevisions(set *appsv1beta1.StatefulSet, revisions []*apps.ControllerRevision) error
}

StatefulSetControlInterface implements the control logic for updating StatefulSets and their children Pods. It is implemented as an interface to allow for extensions that provide different semantics. Currently, there is only one implementation.

func NewDefaultStatefulSetControl

func NewDefaultStatefulSetControl(
	podControl *StatefulPodControl,
	inplaceControl inplaceupdate.Interface,
	lifecycleControl lifecycle.Interface,
	statusUpdater StatusUpdaterInterface,
	controllerHistory history.Interface,
	recorder record.EventRecorder) StatefulSetControlInterface

NewDefaultStatefulSetControl returns a new instance of the default implementation ControlInterface that implements the documented semantics for StatefulSets. podControl is the PodControlInterface used to create, update, and delete Pods and to create PersistentVolumeClaims. statusUpdater is the StatusUpdaterInterface used to update the status of StatefulSets. You should use an instance returned from NewRealStatefulPodControl() for any scenario other than testing.

type StatusUpdaterInterface

type StatusUpdaterInterface interface {
	// UpdateStatefulSetStatus sets the set's Status to status. Implementations are required to retry on conflicts,
	// but fail on other errors. If the returned error is nil set's Status has been successfully set to status.
	UpdateStatefulSetStatus(ctx context.Context, set *appsv1beta1.StatefulSet, status *appsv1beta1.StatefulSetStatus) error
}

StatusUpdaterInterface is an interface used to update the StatefulSetStatus associated with a StatefulSet. For any use other than testing, clients should create an instance using NewRealStatefulSetStatusUpdater.

func NewRealStatefulSetStatusUpdater

func NewRealStatefulSetStatusUpdater(
	client clientset.Interface,
	setLister appslisters.StatefulSetLister) StatusUpdaterInterface

NewRealStatefulSetStatusUpdater returns a StatusUpdaterInterface that updates the Status of a StatefulSet, using the supplied client and setLister.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL