pod

package
v1.26.5 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: Apache-2.0 Imports: 49 Imported by: 147

Documentation

Index

Constants

View Source
const (
	VolumeMountPathTemplate = "/mnt/volume%d"
	VolumeMountPath1        = "/mnt/volume1"
)
View Source
const DefaultNonRootUser = 1000

DefaultNonRootUser is the default user ID used for running restricted (non-root) containers.

View Source
const DefaultNonRootUserName = "ContainerUser"

DefaultNonRootUserName is the default username in Windows used for running restricted (non-root) containers

View Source
const (
	// DefaultPodDeletionTimeout is the default timeout for deleting pod
	DefaultPodDeletionTimeout = 3 * time.Minute
)
View Source
const LabelLogOnPodFailure = "log-on-pod-failure"

LabelLogOnPodFailure can be used to mark which Pods will have their logs logged in the case of a test failure. By default, if there are no Pods with this label, only the first 5 Pods will have their logs fetched.

View Source
const (
	// PodDeleteTimeout is how long to wait for a pod to be deleted.
	PodDeleteTimeout = 5 * time.Minute
)

Variables

View Source
var ImagePrePullList sets.String

ImagePrePullList is the images used in the current test suite. It should be initialized in test suite and the images in the list should be pre-pulled in the test suite. Currently, this is only used by node e2e test.

Functions

func CheckPodsRunningReady

func CheckPodsRunningReady(c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool

CheckPodsRunningReady returns whether all pods whose names are listed in podNames in namespace ns are running and ready, using c and waiting at most timeout.

func CheckPodsRunningReadyOrSucceeded

func CheckPodsRunningReadyOrSucceeded(c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool

CheckPodsRunningReadyOrSucceeded returns whether all pods whose names are listed in podNames in namespace ns are running and ready, or succeeded; use c and waiting at most timeout.

func CreateClientPod

func CreateClientPod(c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim) (*v1.Pod, error)

CreateClientPod defines and creates a pod with a mounted PV. Pod runs infinite loop until killed.

func CreateExecPodOrFail

func CreateExecPodOrFail(client clientset.Interface, ns, generateName string, tweak func(*v1.Pod)) *v1.Pod

CreateExecPodOrFail creates a agnhost pause pod used as a vessel for kubectl exec commands. Pod name is uniquely generated.

func CreatePod

func CreatePod(client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string) (*v1.Pod, error)

CreatePod with given claims based on node selector

func CreateSecPod

func CreateSecPod(client clientset.Interface, podConfig *Config, timeout time.Duration) (*v1.Pod, error)

CreateSecPod creates security pod with given claims

func CreateSecPodWithNodeSelection

func CreateSecPodWithNodeSelection(client clientset.Interface, podConfig *Config, timeout time.Duration) (*v1.Pod, error)

CreateSecPodWithNodeSelection creates security pod with given claims

func CreateUnschedulablePod

func CreateUnschedulablePod(client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string) (*v1.Pod, error)

CreateUnschedulablePod with given claims based on node selector

func DeletePodOrFail

func DeletePodOrFail(c clientset.Interface, ns, name string)

DeletePodOrFail deletes the pod of the specified namespace and name. Resilient to the pod not existing.

func DeletePodWithGracePeriod added in v1.19.0

func DeletePodWithGracePeriod(c clientset.Interface, pod *v1.Pod, grace int64) error

DeletePodWithGracePeriod deletes the passed-in pod. Resilient to the pod not existing.

func DeletePodWithGracePeriodByName added in v1.19.0

func DeletePodWithGracePeriodByName(c clientset.Interface, podName, podNamespace string, grace int64) error

DeletePodWithGracePeriodByName deletes a pod by name and namespace. Resilient to the pod not existing.

func DeletePodWithWait

func DeletePodWithWait(c clientset.Interface, pod *v1.Pod) error

DeletePodWithWait deletes the passed-in pod and waits for the pod to be terminated. Resilient to the pod not existing.

func DeletePodWithWaitByName

func DeletePodWithWaitByName(c clientset.Interface, podName, podNamespace string) error

DeletePodWithWaitByName deletes the named and namespaced pod and waits for the pod to be terminated. Resilient to the pod not existing.

func DeletePodsWithGracePeriod added in v1.19.0

func DeletePodsWithGracePeriod(c clientset.Interface, pods []v1.Pod, grace int64) error

DeletePodsWithGracePeriod deletes the passed-in pods. Resilient to the pods not existing.

func DumpAllPodInfoForNamespace

func DumpAllPodInfoForNamespace(c clientset.Interface, namespace, reportDir string)

DumpAllPodInfoForNamespace logs all pod information for a given namespace.

func ExecCommandInContainer added in v1.26.0

func ExecCommandInContainer(f *framework.Framework, podName, containerName string, cmd ...string) string

ExecCommandInContainer executes a command in the specified container.

func ExecCommandInContainerWithFullOutput added in v1.26.0

func ExecCommandInContainerWithFullOutput(f *framework.Framework, podName, containerName string, cmd ...string) (string, string, error)

ExecCommandInContainerWithFullOutput executes a command in the specified container and return stdout, stderr and error

func ExecShellInContainer added in v1.26.0

func ExecShellInContainer(f *framework.Framework, podName, containerName string, cmd string) string

ExecShellInContainer executes the specified command on the pod's container.

func ExecShellInPod added in v1.26.0

func ExecShellInPod(f *framework.Framework, podName string, cmd string) string

ExecShellInPod executes the specified command on the pod.

func ExecShellInPodWithFullOutput added in v1.26.0

func ExecShellInPodWithFullOutput(f *framework.Framework, podName string, cmd string) (string, string, error)

ExecShellInPodWithFullOutput executes the specified command on the Pod and returns stdout, stderr and error.

func ExecWithOptions added in v1.26.0

func ExecWithOptions(f *framework.Framework, options ExecOptions) (string, string, error)

ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.

func FilterActivePods added in v1.19.0

func FilterActivePods(pods []*v1.Pod) []*v1.Pod

FilterActivePods returns pods that have not terminated.

func FilterNonRestartablePods

func FilterNonRestartablePods(pods []*v1.Pod) []*v1.Pod

FilterNonRestartablePods filters out pods that will never get recreated if deleted after termination.

func FinalError added in v1.26.0

func FinalError(err error) error

FinalError constructs an error that indicates to a poll function that polling can be stopped immediately because some permanent error has been encountered that is not going to go away.

TODO (@pohly): move this into framework once the refactoring from https://github.com/kubernetes/kubernetes/pull/112043 allows it. Right now it leads to circular dependencies.

func FindPodConditionByType added in v1.26.0

func FindPodConditionByType(podStatus *v1.PodStatus, conditionType v1.PodConditionType) *v1.PodCondition

FindPodConditionByType loops through all pod conditions in pod status and returns the specified condition.

func GenerateContainerSecurityContext added in v1.21.0

func GenerateContainerSecurityContext(privileged bool) *v1.SecurityContext

GenerateContainerSecurityContext generates the corresponding container security context with the given inputs If the Node OS is windows, currently we will ignore the inputs and return nil. TODO: Will modify it after windows has its own security context

func GeneratePodSecurityContext added in v1.21.0

func GeneratePodSecurityContext(fsGroup *int64, seLinuxOptions *v1.SELinuxOptions) *v1.PodSecurityContext

GeneratePodSecurityContext generates the corresponding pod security context with the given inputs If the Node OS is windows, currently we will ignore the inputs and return nil. TODO: Will modify it after windows has its own security context

func GenerateScriptCmd added in v1.21.0

func GenerateScriptCmd(command string) []string

GenerateScriptCmd generates the corresponding command lines to execute a command.

func GetDefaultNonRootUser added in v1.25.0

func GetDefaultNonRootUser() *int64

GetDefaultNonRootUser returns default non root user If the Node OS is windows, we return nill due to issue with invalid permissions set on projected volumes https://github.com/kubernetes/kubernetes/issues/102849

func GetDefaultTestImage added in v1.21.0

func GetDefaultTestImage() string

GetDefaultTestImage returns the default test image based on OS. If the node OS is windows, currently we return Agnhost image for Windows node due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35. If the node OS is linux, return busybox image

func GetDefaultTestImageID added in v1.21.0

func GetDefaultTestImageID() imageutils.ImageID

GetDefaultTestImageID returns the default test image id based on OS. If the node OS is windows, currently we return Agnhost image for Windows node due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35. If the node OS is linux, return busybox image

func GetLinuxLabel added in v1.21.0

func GetLinuxLabel() *v1.SELinuxOptions

GetLinuxLabel returns the default SELinuxLabel based on OS. If the node OS is windows, it will return nil

func GetPodLogs

func GetPodLogs(c clientset.Interface, namespace, podName, containerName string) (string, error)

GetPodLogs returns the logs of the specified container (namespace/pod/container).

func GetPodLogsSince added in v1.19.3

func GetPodLogsSince(c clientset.Interface, namespace, podName, containerName string, since time.Time) (string, error)

GetPodLogsSince returns the logs of the specified container (namespace/pod/container) since a timestamp.

func GetPodSecretUpdateTimeout added in v1.19.0

func GetPodSecretUpdateTimeout(c clientset.Interface) time.Duration

GetPodSecretUpdateTimeout returns the timeout duration for updating pod secret.

func GetPods added in v1.20.0

func GetPods(c clientset.Interface, ns string, matchLabels map[string]string) ([]v1.Pod, error)

GetPods return the label matched pods in the given ns

func GetPodsInNamespace

func GetPodsInNamespace(c clientset.Interface, ns string, ignoreLabels map[string]string) ([]*v1.Pod, error)

GetPodsInNamespace returns the pods in the given namespace.

func GetPreviousPodLogs

func GetPreviousPodLogs(c clientset.Interface, namespace, podName, containerName string) (string, error)

GetPreviousPodLogs returns the logs of the previous instance of the specified container (namespace/pod/container).

func GetRestrictedContainerSecurityContext added in v1.24.0

func GetRestrictedContainerSecurityContext() *v1.SecurityContext

GetRestrictedContainerSecurityContext returns a minimal restricted container security context.

func GetRestrictedPodSecurityContext added in v1.24.0

func GetRestrictedPodSecurityContext() *v1.PodSecurityContext

GetRestrictedPodSecurityContext returns a restricted pod security context. This includes setting RunAsUser for convenience, to pass the RunAsNonRoot check. Tests that require a specific user ID should override this.

func GetTestImage added in v1.21.0

func GetTestImage(id imageutils.ImageID) string

GetTestImage returns the image name with the given input If the Node OS is windows, currently we return Agnhost image for Windows node due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.

func GetTestImageID added in v1.21.0

func GetTestImageID(id imageutils.ImageID) imageutils.ImageID

GetTestImageID returns the image id with the given input If the Node OS is windows, currently we return Agnhost image for Windows node due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.

func IsFinal added in v1.26.0

func IsFinal(err error) bool

IsFinal checks whether the error was marked as final by wrapping some error with FinalError.

func IsPodActive added in v1.19.0

func IsPodActive(p *v1.Pod) bool

IsPodActive return true if the pod meets certain conditions.

func IsTimeout added in v1.25.0

func IsTimeout(err error) bool

func LogPodStates

func LogPodStates(pods []v1.Pod)

LogPodStates logs basic info of provided pods for debugging.

func MakePod

func MakePod(ns string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string) *v1.Pod

MakePod returns a pod definition based on the namespace. The pod references the PVC's name. A slice of BASH commands can be supplied as args to be run by the pod

func MakePodSpec added in v1.21.0

func MakePodSpec(podConfig *Config) *v1.PodSpec

MakePodSpec returns a PodSpec definition

func MakeSecPod

func MakeSecPod(podConfig *Config) (*v1.Pod, error)

MakeSecPod returns a pod definition based on the namespace. The pod references the PVC's name. A slice of BASH commands can be supplied as args to be run by the pod.

func MixinRestrictedPodSecurity added in v1.25.0

func MixinRestrictedPodSecurity(pod *v1.Pod) error

MixinRestrictedPodSecurity makes the given pod compliant with the restricted pod security level. If doing so would overwrite existing non-conformant configuration, an error is returned. Note that this sets a default RunAsUser. See GetRestrictedPodSecurityContext. TODO(#105919): Handle PodOS for windows pods.

func MustMixinRestrictedPodSecurity added in v1.25.0

func MustMixinRestrictedPodSecurity(pod *v1.Pod) *v1.Pod

MustMixinRestrictedPodSecurity makes the given pod compliant with the restricted pod security level. If doing so would overwrite existing non-conformant configuration, a test failure is triggered.

func NewAgnhostContainer added in v1.19.9

func NewAgnhostContainer(containerName string, mounts []v1.VolumeMount, ports []v1.ContainerPort, args ...string) v1.Container

NewAgnhostContainer returns the container Spec of an agnhost container.

func NewAgnhostPod added in v1.19.9

func NewAgnhostPod(ns, podName string, volumes []v1.Volume, mounts []v1.VolumeMount, ports []v1.ContainerPort, args ...string) *v1.Pod

NewAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands that behave the same, no matter the underlying OS. If no args are given, it defaults to the pause subcommand. For more information about agnhost subcommands, see: https://github.com/kubernetes/kubernetes/tree/master/test/images/agnhost#agnhost

func NewAgnhostPodFromContainers added in v1.26.0

func NewAgnhostPodFromContainers(ns, podName string, volumes []v1.Volume, containers ...v1.Container) *v1.Pod

func NewExecPodSpec

func NewExecPodSpec(ns, name string, hostNetwork bool) *v1.Pod

NewExecPodSpec returns the pod spec of hostexec pod

func NewTransport added in v1.21.6

func NewTransport(client kubernetes.Interface, restConfig *rest.Config) *http.Transport

NewTransport creates a transport which uses the port forward dialer. URLs must use <namespace>.<pod>:<port> as host.

func NodeOSDistroIs added in v1.21.0

func NodeOSDistroIs(distro string) bool

NodeOSDistroIs returns true if the distro is the same as `--node-os-distro` the package framework/pod can't import the framework package (see #81245) we need to check if the --node-os-distro=windows is set and the framework package is the one that's parsing the flags, as a workaround this method is looking for the same flag again TODO: replace with `framework.NodeOSDistroIs` when #81245 is complete

func PodsCreated

func PodsCreated(c clientset.Interface, ns, name string, replicas int32) (*v1.PodList, error)

PodsCreated returns a pod list matched by the given name.

func PodsCreatedByLabel

func PodsCreatedByLabel(c clientset.Interface, ns, name string, replicas int32, label labels.Selector) (*v1.PodList, error)

PodsCreatedByLabel returns a created pod list matched by the given label.

func PodsResponding

func PodsResponding(c clientset.Interface, ns, name string, wantName bool, pods *v1.PodList) error

PodsResponding waits for the pods to response.

func SetAffinity

func SetAffinity(nodeSelection *NodeSelection, nodeName string)

SetAffinity sets affinity to nodeName to nodeSelection

func SetAntiAffinity

func SetAntiAffinity(nodeSelection *NodeSelection, nodeName string)

SetAntiAffinity sets anti-affinity to nodeName to nodeSelection

func SetNodeAffinity added in v1.18.0

func SetNodeAffinity(podSpec *v1.PodSpec, nodeName string)

SetNodeAffinity modifies the given pod object with NodeAffinity to the given node name.

func SetNodeAffinityTopologyRequirement added in v1.18.0

func SetNodeAffinityTopologyRequirement(nodeSelection *NodeSelection, topology map[string]string)

SetNodeAffinityTopologyRequirement sets node affinity to a specified topology

func SetNodeSelection added in v1.18.0

func SetNodeSelection(podSpec *v1.PodSpec, nodeSelection NodeSelection)

SetNodeSelection modifies the given pod object with the specified NodeSelection

func TimeoutError added in v1.25.0

func TimeoutError(msg string, observedObjects ...interface{}) *timeoutError

func VerifyPodHasConditionWithType added in v1.26.0

func VerifyPodHasConditionWithType(f *framework.Framework, pod *v1.Pod, cType v1.PodConditionType)

VerifyPodHasConditionWithType verifies the pod has the expected condition by type

func VerifyPods

func VerifyPods(c clientset.Interface, ns, name string, wantName bool, replicas int32) error

VerifyPods checks if the specified pod is responding.

func VerifyPodsRunning

func VerifyPodsRunning(c clientset.Interface, ns, name string, wantName bool, replicas int32) error

VerifyPodsRunning checks if the specified pod is running.

func WaitForAllPodsCondition added in v1.25.0

func WaitForAllPodsCondition(c clientset.Interface, ns string, opts metav1.ListOptions, minPods int, conditionDesc string, timeout time.Duration, condition podCondition) (*v1.PodList, error)

WaitForAllPodsCondition waits for the listed pods to match the given condition. To succeed, at least minPods must be listed, and all listed pods must match the condition.

func WaitForContainerRunning added in v1.23.0

func WaitForContainerRunning(c clientset.Interface, namespace, podName, containerName string, timeout time.Duration) error

WaitForContainerRunning waits for the given Pod container to have a state of running

func WaitForNRestartablePods

func WaitForNRestartablePods(ps *testutils.PodStore, expect int, timeout time.Duration) ([]string, error)

WaitForNRestartablePods tries to list restarting pods using ps until it finds expect of them, returning their names if it can do so before timeout.

func WaitForNumberOfPods added in v1.22.0

func WaitForNumberOfPods(c clientset.Interface, ns string, num int, timeout time.Duration) (pods *v1.PodList, err error)

WaitForNumberOfPods waits up to timeout to ensure there are exact `num` pods in namespace `ns`. It returns the matching Pods or a timeout error.

func WaitForPodCondition

func WaitForPodCondition(c clientset.Interface, ns, podName, conditionDesc string, timeout time.Duration, condition podCondition) error

WaitForPodCondition waits a pods to be matched to the given condition. If the condition callback returns an error that matches FinalErr (checked with IsFinal), then polling aborts early.

func WaitForPodContainerStarted added in v1.21.0

func WaitForPodContainerStarted(c clientset.Interface, namespace, podName string, containerIndex int, timeout time.Duration) error

WaitForPodContainerStarted waits for the given Pod container to start, after a successful run of the startupProbe.

func WaitForPodContainerToFail added in v1.20.0

func WaitForPodContainerToFail(c clientset.Interface, namespace, podName string, containerIndex int, reason string, timeout time.Duration) error

WaitForPodContainerToFail waits for the given Pod container to fail with the given reason, specifically due to invalid container configuration. In this case, the container will remain in a waiting state with a specific reason set, which should match the given reason.

func WaitForPodFailedReason added in v1.23.0

func WaitForPodFailedReason(c clientset.Interface, pod *v1.Pod, reason string, timeout time.Duration) error

WaitForPodFailedReason wait for pod failed reason in status, for example "SysctlForbidden".

func WaitForPodNameRunningInNamespace

func WaitForPodNameRunningInNamespace(c clientset.Interface, podName, namespace string) error

WaitForPodNameRunningInNamespace waits default amount of time (PodStartTimeout) for the specified pod to become running. Returns an error if timeout occurs first, or pod goes in to failed state.

func WaitForPodNameUnschedulableInNamespace

func WaitForPodNameUnschedulableInNamespace(c clientset.Interface, podName, namespace string) error

WaitForPodNameUnschedulableInNamespace returns an error if it takes too long for the pod to become Pending and have condition Status equal to Unschedulable, if the pod Get api returns an error (IsNotFound or other), or if the pod failed with an unexpected reason. Typically called to test that the passed-in pod is Pending and Unschedulable.

func WaitForPodNoLongerRunningInNamespace

func WaitForPodNoLongerRunningInNamespace(c clientset.Interface, podName, namespace string) error

WaitForPodNoLongerRunningInNamespace waits default amount of time (defaultPodDeletionTimeout) for the specified pod to stop running. Returns an error if timeout occurs first.

func WaitForPodNotFoundInNamespace

func WaitForPodNotFoundInNamespace(c clientset.Interface, podName, ns string, timeout time.Duration) error

WaitForPodNotFoundInNamespace returns an error if it takes too long for the pod to fully terminate. Unlike `waitForPodTerminatedInNamespace`, the pod's Phase and Reason are ignored. If the pod Get api returns IsNotFound then the wait stops and nil is returned. If the Get api returns an error other than "not found" then that error is returned and the wait stops.

func WaitForPodNotPending

func WaitForPodNotPending(c clientset.Interface, ns, podName string) error

WaitForPodNotPending returns an error if it took too long for the pod to go out of pending state. The resourceVersion is used when Watching object changes, it tells since when we care about changes to the pod.

func WaitForPodRunningInNamespace

func WaitForPodRunningInNamespace(c clientset.Interface, pod *v1.Pod) error

WaitForPodRunningInNamespace waits default amount of time (podStartTimeout) for the specified pod to become running. Returns an error if timeout occurs first, or pod goes in to failed state.

func WaitForPodRunningInNamespaceSlow

func WaitForPodRunningInNamespaceSlow(c clientset.Interface, podName, namespace string) error

WaitForPodRunningInNamespaceSlow waits an extended amount of time (slowPodStartTimeout) for the specified pod to become running. The resourceVersion is used when Watching object changes, it tells since when we care about changes to the pod. Returns an error if timeout occurs first, or pod goes in to failed state.

func WaitForPodSuccessInNamespace

func WaitForPodSuccessInNamespace(c clientset.Interface, podName string, namespace string) error

WaitForPodSuccessInNamespace returns nil if the pod reached state success, or an error if it reached failure or until podStartupTimeout.

func WaitForPodSuccessInNamespaceSlow

func WaitForPodSuccessInNamespaceSlow(c clientset.Interface, podName string, namespace string) error

WaitForPodSuccessInNamespaceSlow returns nil if the pod reached state success, or an error if it reached failure or until slowPodStartupTimeout.

func WaitForPodSuccessInNamespaceTimeout added in v1.21.0

func WaitForPodSuccessInNamespaceTimeout(c clientset.Interface, podName, namespace string, timeout time.Duration) error

WaitForPodSuccessInNamespaceTimeout returns nil if the pod reached state success, or an error if it reached failure or ran too long.

func WaitForPodTerminatedInNamespace

func WaitForPodTerminatedInNamespace(c clientset.Interface, podName, reason, namespace string) error

WaitForPodTerminatedInNamespace returns an error if it takes too long for the pod to terminate, if the pod Get api returns an error (IsNotFound or other), or if the pod failed (and thus did not terminate) with an unexpected reason. Typically called to test that the passed-in pod is fully terminated (reason==""), but may be called to detect if a pod did *not* terminate according to the supplied reason.

func WaitForPodTerminatingInNamespaceTimeout added in v1.26.0

func WaitForPodTerminatingInNamespaceTimeout(c clientset.Interface, podName, namespace string, timeout time.Duration) error

WaitForPodTerminatingInNamespaceTimeout returns if the pod is terminating, or an error if it is not after the timeout.

func WaitForPodToDisappear

func WaitForPodToDisappear(c clientset.Interface, ns, podName string, label labels.Selector, interval, timeout time.Duration) error

WaitForPodToDisappear waits the given timeout duration for the specified pod to disappear.

func WaitForPodsRunning added in v1.26.0

func WaitForPodsRunning(c clientset.Interface, ns string, num int, timeout time.Duration) error

WaitForPodsRunning waits for a given `timeout` to evaluate if a certain amount of pods in given `ns` are running.

func WaitForPodsRunningReady

func WaitForPodsRunningReady(c clientset.Interface, ns string, minPods, allowedNotReadyPods int32, timeout time.Duration, ignoreLabels map[string]string) error

WaitForPodsRunningReady waits up to timeout to ensure that all pods in namespace ns are either running and ready, or failed but controlled by a controller. Also, it ensures that at least minPods are running and ready. It has separate behavior from other 'wait for' pods functions in that it requests the list of pods on every iteration. This is useful, for example, in cluster startup, because the number of pods increases while waiting. All pods that are in SUCCESS state are not counted.

If ignoreLabels is not empty, pods matching this selector are ignored.

If minPods or allowedNotReadyPods are -1, this method returns immediately without waiting.

func WaitForPodsSchedulingGated added in v1.26.0

func WaitForPodsSchedulingGated(c clientset.Interface, ns string, num int, timeout time.Duration) error

WaitForPodsSchedulingGated waits for a given `timeout` to evaluate if a certain amount of pods in given `ns` stay in scheduling gated state.

func WaitForPodsWithLabel

func WaitForPodsWithLabel(c clientset.Interface, ns string, label labels.Selector) (*v1.PodList, error)

WaitForPodsWithLabel waits up to podListTimeout for getting pods with certain label

func WaitForPodsWithLabelRunningReady

func WaitForPodsWithLabelRunningReady(c clientset.Interface, ns string, label labels.Selector, num int, timeout time.Duration) (pods *v1.PodList, err error)

WaitForPodsWithLabelRunningReady waits for exact amount of matching pods to become running and ready. Return the list of matching pods.

func WaitForPodsWithLabelScheduled

func WaitForPodsWithLabelScheduled(c clientset.Interface, ns string, label labels.Selector) (pods *v1.PodList, err error)

WaitForPodsWithLabelScheduled waits for all matching pods to become scheduled and at least one matching pod exists. Return the list of matching pods.

func WaitForPodsWithSchedulingGates added in v1.26.0

func WaitForPodsWithSchedulingGates(c clientset.Interface, ns string, num int, timeout time.Duration, schedulingGates []v1.PodSchedulingGate) error

WaitForPodsWithSchedulingGates waits for a given `timeout` to evaluate if a certain amount of pods in given `ns` match the given `schedulingGates`stay in scheduling gated state.

func WaitTimeoutForPodNoLongerRunningInNamespace

func WaitTimeoutForPodNoLongerRunningInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error

WaitTimeoutForPodNoLongerRunningInNamespace waits the given timeout duration for the specified pod to stop.

func WaitTimeoutForPodReadyInNamespace

func WaitTimeoutForPodReadyInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error

WaitTimeoutForPodReadyInNamespace waits the given timeout duration for the specified pod to be ready and running.

func WaitTimeoutForPodRunningInNamespace

func WaitTimeoutForPodRunningInNamespace(c clientset.Interface, podName, namespace string, timeout time.Duration) error

WaitTimeoutForPodRunningInNamespace waits the given timeout duration for the specified pod to become running.

func WithWindowsHostProcess added in v1.24.0

func WithWindowsHostProcess(pod *v1.Pod, username string)

WithWindowsHostProcess sets the Pod's Windows HostProcess option to true. When this option is set, HostNetwork can be enabled. Containers running as HostProcess will require certain usernames to be set, otherwise the Pod will not start: NT AUTHORITY\SYSTEM, NT AUTHORITY\Local service, NT AUTHORITY\NetworkService. If the given username is empty, NT AUTHORITY\SYSTEM will be used instead. See: https://kubernetes.io/docs/tasks/configure-pod-container/create-hostprocess-pod/

Types

type Addr added in v1.21.6

type Addr struct {
	Namespace, PodName string
	Port               int
}

Addr contains all relevant parameters for a certain port in a pod. The container should be running before connections are attempted, otherwise the connection will fail.

func ParseAddr added in v1.21.6

func ParseAddr(addr string) (*Addr, error)

ParseAddr expects a <namespace>.<pod>:<port number> as produced by Addr.String.

func (Addr) Network added in v1.21.6

func (a Addr) Network() string

func (Addr) String added in v1.21.6

func (a Addr) String() string

type Config added in v1.19.0

type Config struct {
	NS                     string
	PVCs                   []*v1.PersistentVolumeClaim
	PVCsReadOnly           bool
	InlineVolumeSources    []*v1.VolumeSource
	IsPrivileged           bool
	Command                string
	HostIPC                bool
	HostPID                bool
	SeLinuxLabel           *v1.SELinuxOptions
	FsGroup                *int64
	NodeSelection          NodeSelection
	ImageID                imageutils.ImageID
	PodFSGroupChangePolicy *v1.PodFSGroupChangePolicy
}

Config is a struct containing all arguments for creating a pod. SELinux testing requires to pass HostIPC and HostPID as boolean arguments.

type Dialer added in v1.21.6

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

Dialer holds the relevant parameters that are independent of a particular connection.

func NewDialer added in v1.21.6

func NewDialer(client kubernetes.Interface, restConfig *rest.Config) *Dialer

NewDialer creates a dialer that supports connecting to container ports.

func (*Dialer) DialContainerPort added in v1.21.6

func (d *Dialer) DialContainerPort(ctx context.Context, addr Addr) (conn net.Conn, finalErr error)

DialContainerPort connects to a certain container port in a pod.

type ExecOptions added in v1.26.0

type ExecOptions struct {
	Command       []string
	Namespace     string
	PodName       string
	ContainerName string
	Stdin         io.Reader
	CaptureStdout bool
	CaptureStderr bool
	// If false, whitespace in std{err,out} will be removed.
	PreserveWhitespace bool
	Quiet              bool
}

ExecOptions passed to ExecWithOptions

type FinalErr added in v1.26.0

type FinalErr struct {
	Err error
}

func (*FinalErr) Error added in v1.26.0

func (err *FinalErr) Error() string

func (*FinalErr) Unwrap added in v1.26.0

func (err *FinalErr) Unwrap() error

type LocalAddr added in v1.21.6

type LocalAddr struct{}

func (LocalAddr) Network added in v1.21.6

func (l LocalAddr) Network() string

func (LocalAddr) String added in v1.21.6

func (l LocalAddr) String() string

type NodeSelection

type NodeSelection struct {
	Name     string
	Selector map[string]string
	Affinity *v1.Affinity
}

NodeSelection specifies where to run a pod, using a combination of fixed node name, node selector and/or affinity.

type PodClient added in v1.26.0

type PodClient struct {
	v1core.PodInterface
	// contains filtered or unexported fields
}

PodClient is a struct for pod client.

func NewPodClient added in v1.26.0

func NewPodClient(f *framework.Framework) *PodClient

NewPodClient is a convenience method for getting a pod client interface in the framework's namespace, possibly applying test-suite specific transformations to the pod spec, e.g. for node e2e pod scheduling.

func PodClientNS added in v1.26.0

func PodClientNS(f *framework.Framework, namespace string) *PodClient

PodClientNS is a convenience method for getting a pod client interface in an alternative namespace, possibly applying test-suite specific transformations to the pod spec, e.g. for node e2e pod scheduling.

func (*PodClient) AddEphemeralContainerSync added in v1.26.0

func (c *PodClient) AddEphemeralContainerSync(pod *v1.Pod, ec *v1.EphemeralContainer, timeout time.Duration) error

AddEphemeralContainerSync adds an EphemeralContainer to a pod and waits for it to be running.

func (*PodClient) Create added in v1.26.0

func (c *PodClient) Create(pod *v1.Pod) *v1.Pod

Create creates a new pod according to the framework specifications (don't wait for it to start).

func (*PodClient) CreateBatch added in v1.26.0

func (c *PodClient) CreateBatch(pods []*v1.Pod) []*v1.Pod

CreateBatch create a batch of pods. All pods are created before waiting.

func (*PodClient) CreateSync added in v1.26.0

func (c *PodClient) CreateSync(pod *v1.Pod) *v1.Pod

CreateSync creates a new pod according to the framework specifications, and wait for it to start and be running and ready.

func (*PodClient) DeleteSync added in v1.26.0

func (c *PodClient) DeleteSync(name string, options metav1.DeleteOptions, timeout time.Duration)

DeleteSync deletes the pod and wait for the pod to disappear for `timeout`. If the pod doesn't disappear before the timeout, it will fail the test.

func (*PodClient) MatchContainerOutput added in v1.26.0

func (c *PodClient) MatchContainerOutput(name string, containerName string, expectedRegexp string) error

MatchContainerOutput gets output of a container and match expected regexp in the output.

func (*PodClient) PodIsReady added in v1.26.0

func (c *PodClient) PodIsReady(name string) bool

PodIsReady returns true if the specified pod is ready. Otherwise false.

func (*PodClient) RemoveFinalizer added in v1.26.0

func (c *PodClient) RemoveFinalizer(podName string, finalizerName string)

RemovePodFinalizer removes the pod's finalizer

func (*PodClient) Update added in v1.26.0

func (c *PodClient) Update(name string, updateFn func(pod *v1.Pod))

Update updates the pod object. It retries if there is a conflict, throw out error if there is any other apierrors. name is the pod name, updateFn is the function updating the pod object.

func (*PodClient) WaitForErrorEventOrSuccess added in v1.26.0

func (c *PodClient) WaitForErrorEventOrSuccess(pod *v1.Pod) (*v1.Event, error)

WaitForErrorEventOrSuccess waits for pod to succeed or an error event for that pod.

func (*PodClient) WaitForFinish added in v1.26.0

func (c *PodClient) WaitForFinish(name string, timeout time.Duration)

WaitForFinish waits for pod to finish running, regardless of success or failure.

func (*PodClient) WaitForSuccess added in v1.26.0

func (c *PodClient) WaitForSuccess(name string, timeout time.Duration)

WaitForSuccess waits for pod to succeed. TODO(random-liu): Move pod wait function into this file

type ProxyResponseChecker

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

ProxyResponseChecker is a context for checking pods responses by issuing GETs to them (via the API proxy) and verifying that they answer with their own pod name.

func NewProxyResponseChecker

func NewProxyResponseChecker(c clientset.Interface, ns string, label labels.Selector, controllerName string, respondName bool, pods *v1.PodList) ProxyResponseChecker

NewProxyResponseChecker returns a context for checking pods responses.

func (ProxyResponseChecker) CheckAllResponses

func (r ProxyResponseChecker) CheckAllResponses() (done bool, err error)

CheckAllResponses issues GETs to all pods in the context and verify they reply with their own pod name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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