statefulset

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatefulSetPoll is a poll interval for StatefulSet tests
	StatefulSetPoll = 10 * time.Second
	// StatefulSetTimeout is a timeout interval for StatefulSet operations
	StatefulSetTimeout = 10 * time.Minute
	// StatefulPodTimeout is a timeout for stateful pods to change state
	StatefulPodTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

func BreakHTTPProbe

func BreakHTTPProbe(c clientset.Interface, ss *appsv1.StatefulSet) error

BreakHTTPProbe breaks the readiness probe for Nginx StatefulSet containers in ss.

func BreakPodHTTPProbe

func BreakPodHTTPProbe(ss *appsv1.StatefulSet, pod *v1.Pod) error

BreakPodHTTPProbe breaks the readiness probe for Nginx StatefulSet containers in one pod.

func CheckHostname

func CheckHostname(c clientset.Interface, ss *appsv1.StatefulSet) error

CheckHostname verifies that all Pods in ss have the correct Hostname. If the returned error is not nil than verification failed.

func CheckMount

func CheckMount(c clientset.Interface, ss *appsv1.StatefulSet, mountPath string) error

CheckMount checks that the mount at mountPath is valid for all Pods in ss.

func CheckServiceName

func CheckServiceName(ss *appsv1.StatefulSet, expectedServiceName string) error

CheckServiceName asserts that the ServiceName for ss is equivalent to expectedServiceName.

func CreateStatefulSet

func CreateStatefulSet(c clientset.Interface, manifestPath, ns string) *appsv1.StatefulSet

CreateStatefulSet creates a StatefulSet from the manifest at manifestPath in the Namespace ns using kubectl create.

func CreateStatefulSetService

func CreateStatefulSetService(name string, labels map[string]string) *v1.Service

CreateStatefulSetService creates a Headless Service with Name name and Selector set to match labels.

func DeleteAllStatefulSets

func DeleteAllStatefulSets(c clientset.Interface, ns string)

DeleteAllStatefulSets deletes all StatefulSet API Objects in Namespace ns.

func DeleteStatefulPodAtIndex

func DeleteStatefulPodAtIndex(c clientset.Interface, index int, ss *appsv1.StatefulSet)

DeleteStatefulPodAtIndex deletes the Pod with ordinal index in ss.

func ExecInStatefulPods

func ExecInStatefulPods(c clientset.Interface, ss *appsv1.StatefulSet, cmd string) error

ExecInStatefulPods executes cmd in all Pods in ss. If a error occurs it is returned and cmd is not execute in any subsequent Pods.

func GetPodList

func GetPodList(c clientset.Interface, ss *appsv1.StatefulSet) *v1.PodList

GetPodList gets the current Pods in ss.

func GetStatefulSet

func GetStatefulSet(c clientset.Interface, namespace, name string) *appsv1.StatefulSet

GetStatefulSet gets the StatefulSet named name in namespace.

func NewStatefulSet

func NewStatefulSet(name, ns, governingSvcName string, replicas int32, statefulPodMounts []v1.VolumeMount, podMounts []v1.VolumeMount, labels map[string]string) *appsv1.StatefulSet

NewStatefulSet creates a new Webserver StatefulSet for testing. The StatefulSet is named name, is in namespace ns, statefulPodsMounts are the mounts that will be backed by PVs. podsMounts are the mounts that are mounted directly to the Pod. labels are the labels that will be usd for the StatefulSet selector.

func NewStatefulSetPVC

func NewStatefulSetPVC(name string) v1.PersistentVolumeClaim

NewStatefulSetPVC returns a PersistentVolumeClaim named name, for testing StatefulSets.

func PauseNewPods

func PauseNewPods(ss *appsv1.StatefulSet)

PauseNewPods adds an always-failing ReadinessProbe to the StatefulSet PodTemplate. This causes all newly-created Pods to stay Unready until they are manually resumed with ResumeNextPod(). Note that this cannot be used together with SetHTTPProbe().

func Restart

func Restart(c clientset.Interface, ss *appsv1.StatefulSet)

Restart scales ss to 0 and then back to its previous number of replicas.

func RestoreHTTPProbe

func RestoreHTTPProbe(c clientset.Interface, ss *appsv1.StatefulSet) error

RestoreHTTPProbe restores the readiness probe for Nginx StatefulSet containers in ss.

func RestorePodHTTPProbe

func RestorePodHTTPProbe(ss *appsv1.StatefulSet, pod *v1.Pod) error

RestorePodHTTPProbe restores the readiness probe for Nginx StatefulSet containers in pod.

func ResumeNextPod

func ResumeNextPod(c clientset.Interface, ss *appsv1.StatefulSet)

ResumeNextPod allows the next Pod in the StatefulSet to continue by removing the ReadinessProbe added by PauseNewPods(), if it's still there. It fails the test if it finds any pods that are not in phase Running, or if it finds more than one paused Pod existing at the same time. This is a no-op if there are no paused pods.

func Saturate

func Saturate(c clientset.Interface, ss *appsv1.StatefulSet)

Saturate waits for all Pods in ss to become Running and Ready.

func Scale

Scale scales ss to count replicas.

func SetHTTPProbe

func SetHTTPProbe(ss *appsv1.StatefulSet)

SetHTTPProbe sets the pod template's ReadinessProbe for Webserver StatefulSet containers. This probe can then be controlled with BreakHTTPProbe() and RestoreHTTPProbe(). Note that this cannot be used together with PauseNewPods().

func SortStatefulPods

func SortStatefulPods(pods *v1.PodList)

SortStatefulPods sorts pods by their ordinals

func UpdateReplicas

func UpdateReplicas(c clientset.Interface, ss *appsv1.StatefulSet, count int32)

UpdateReplicas updates the replicas of ss to count.

func UpdateStatefulSetWithRetries

func UpdateStatefulSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate updateStatefulSetFunc) (statefulSet *appsv1.StatefulSet, err error)

UpdateStatefulSetWithRetries updates statfulset template with retries.

func VerifyPodAtIndex

func VerifyPodAtIndex(c clientset.Interface, index int, ss *appsv1.StatefulSet, verify VerifyStatefulPodFunc)

VerifyPodAtIndex applies a visitor pattern to the Pod at index in ss. verify is applied to the Pod to "visit" it.

func WaitForPartitionedRollingUpdate

func WaitForPartitionedRollingUpdate(c clientset.Interface, set *appsv1.StatefulSet) (*appsv1.StatefulSet, *v1.PodList)

WaitForPartitionedRollingUpdate waits for all Pods in set to exist and have the correct revision. set must have a RollingUpdateStatefulSetStrategyType with a non-nil RollingUpdate and Partition. All Pods with ordinals less than or equal to the Partition are expected to be at set's current revision. All other Pods are expected to be at its update revision.

func WaitForPodNotReady

func WaitForPodNotReady(c clientset.Interface, set *appsv1.StatefulSet, podName string) (*appsv1.StatefulSet, *v1.PodList)

WaitForPodNotReady waits for the Pod named podName in set to exist and to not have a Ready condition.

func WaitForPodReady

func WaitForPodReady(c clientset.Interface, set *appsv1.StatefulSet, podName string) (*appsv1.StatefulSet, *v1.PodList)

WaitForPodReady waits for the Pod named podName in set to exist and have a Ready condition.

func WaitForRollingUpdate

func WaitForRollingUpdate(c clientset.Interface, set *appsv1.StatefulSet) (*appsv1.StatefulSet, *v1.PodList)

WaitForRollingUpdate waits for all Pods in set to exist and have the correct revision and for the RollingUpdate to complete. set must have a RollingUpdateStatefulSetStrategyType.

func WaitForRunning

func WaitForRunning(c clientset.Interface, numPodsRunning, numPodsReady int32, ss *appsv1.StatefulSet)

WaitForRunning waits for numPodsRunning in ss to be Running and for the first numPodsReady ordinals to be Ready.

func WaitForRunningAndNotReady

func WaitForRunningAndNotReady(c clientset.Interface, numStatefulPods int32, ss *appsv1.StatefulSet)

WaitForRunningAndNotReady waits for numStatefulPods in ss to be Running and not Ready.

func WaitForRunningAndReady

func WaitForRunningAndReady(c clientset.Interface, numStatefulPods int32, ss *appsv1.StatefulSet)

WaitForRunningAndReady waits for numStatefulPods in ss to be Running and Ready.

func WaitForState

func WaitForState(c clientset.Interface, ss *appsv1.StatefulSet, until func(*appsv1.StatefulSet, *v1.PodList) (bool, error))

WaitForState periodically polls for the ss and its pods until the until function returns either true or an error

func WaitForStatus

func WaitForStatus(c clientset.Interface, set *appsv1.StatefulSet) *appsv1.StatefulSet

WaitForStatus waits for the StatefulSetStatus's ObservedGeneration to be greater than or equal to set's Generation. The returned StatefulSet contains such a StatefulSetStatus

func WaitForStatusReadyReplicas

func WaitForStatusReadyReplicas(c clientset.Interface, ss *appsv1.StatefulSet, expectedReplicas int32)

WaitForStatusReadyReplicas waits for the ss.Status.ReadyReplicas to be equal to expectedReplicas

func WaitForStatusReplicas

func WaitForStatusReplicas(c clientset.Interface, ss *appsv1.StatefulSet, expectedReplicas int32)

WaitForStatusReplicas waits for the ss.Status.Replicas to be equal to expectedReplicas

Types

type VerifyStatefulPodFunc

type VerifyStatefulPodFunc func(*v1.Pod)

VerifyStatefulPodFunc is a func that examines a StatefulSetPod.

Jump to

Keyboard shortcuts

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