package pod
import "k8s.io/kubernetes/test/e2e/framework/pod"
Index ¶
- Constants
- Variables
- func BeInPhase(phase v1.PodPhase) types.GomegaMatcher
- func BeRunningNoRetries() types.GomegaMatcher
- func BeRunningReadyNoRetries() types.GomegaMatcher
- func CheckPodsRunningReady(ctx context.Context, c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool
- func CheckPodsRunningReadyOrSucceeded(ctx context.Context, c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool
- func CreateClientPod(ctx context.Context, c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim) (*v1.Pod, error)
- func CreateExecPodOrFail(ctx context.Context, client clientset.Interface, ns, generateName string, tweak func(*v1.Pod)) *v1.Pod
- func CreatePod(ctx context.Context, client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, securityLevel admissionapi.Level, command string) (*v1.Pod, error)
- func CreateSecPod(ctx context.Context, client clientset.Interface, podConfig *Config, timeout time.Duration) (*v1.Pod, error)
- func CreateSecPodWithNodeSelection(ctx context.Context, client clientset.Interface, podConfig *Config, timeout time.Duration) (*v1.Pod, error)
- func CreateUnschedulablePod(ctx context.Context, client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, securityLevel admissionapi.Level, command string) (*v1.Pod, error)
- func DeletePodOrFail(ctx context.Context, c clientset.Interface, ns, name string)
- func DeletePodWithGracePeriod(ctx context.Context, c clientset.Interface, pod *v1.Pod, grace int64) error
- func DeletePodWithGracePeriodByName(ctx context.Context, c clientset.Interface, podName, podNamespace string, grace int64) error
- func DeletePodWithWait(ctx context.Context, c clientset.Interface, pod *v1.Pod) error
- func DeletePodWithWaitByName(ctx context.Context, c clientset.Interface, podName, podNamespace string) error
- func DeletePodsWithGracePeriod(ctx context.Context, c clientset.Interface, pods []v1.Pod, grace int64) error
- func DumpAllPodInfoForNamespace(ctx context.Context, c clientset.Interface, namespace, reportDir string)
- func ExecCommandInContainer(f *framework.Framework, podName, containerName string, cmd ...string) string
- func ExecCommandInContainerWithFullOutput(f *framework.Framework, podName, containerName string, cmd ...string) (string, string, error)
- func ExecShellInContainer(f *framework.Framework, podName, containerName string, cmd string) string
- func ExecShellInPod(ctx context.Context, f *framework.Framework, podName string, cmd string) string
- func ExecShellInPodWithFullOutput(ctx context.Context, f *framework.Framework, podName string, cmd string) (string, string, error)
- func ExecWithOptions(f *framework.Framework, options ExecOptions) (string, string, error)
- func ExecWithOptionsContext(ctx context.Context, f *framework.Framework, options ExecOptions) (string, string, error)
- func ExpectPodResized(ctx context.Context, f *framework.Framework, resizedPod *v1.Pod, expectedContainers []ResizableContainerInfo)
- func FilterActivePods(pods []*v1.Pod) []*v1.Pod
- func FilterNonRestartablePods(pods []*v1.Pod) []*v1.Pod
- func FindContainerInPod(pod *v1.Pod, containerName string) *v1.Container
- func FindContainerStatusInPod(pod *v1.Pod, containerName string) *v1.ContainerStatus
- func FindPodConditionByType(podStatus *v1.PodStatus, conditionType v1.PodConditionType) *v1.PodCondition
- func FormatPod(pod *v1.Pod) string
- func GenerateContainerSecurityContext(level psaapi.Level) *v1.SecurityContext
- func GeneratePodSecurityContext(fsGroup *int64, seLinuxOptions *v1.SELinuxOptions) *v1.PodSecurityContext
- func GenerateScriptCmd(command string) []string
- func Get(c clientset.Interface, pod framework.NamedObject) framework.GetFunc[*v1.Pod]
- func GetCPULimitCgroupExpectations(cpuLimit *resource.Quantity) []string
- func GetDefaultNonRootUser() *int64
- func GetDefaultTestImage() string
- func GetDefaultTestImageID() imageutils.ImageID
- func GetLinuxLabel() *v1.SELinuxOptions
- func GetPodLogs(ctx context.Context, c clientset.Interface, namespace, podName, containerName string) (string, error)
- func GetPodLogsSince(ctx context.Context, c clientset.Interface, namespace, podName, containerName string, since time.Time) (string, error)
- func GetPodSecretUpdateTimeout(ctx context.Context, c clientset.Interface) time.Duration
- func GetPods(ctx context.Context, c clientset.Interface, ns string, matchLabels map[string]string) ([]v1.Pod, error)
- func GetPodsInNamespace(ctx context.Context, c clientset.Interface, ns string, ignoreLabels map[string]string) ([]*v1.Pod, error)
- func GetPreviousPodLogs(ctx context.Context, c clientset.Interface, namespace, podName, containerName string) (string, error)
- func GetRestrictedContainerSecurityContext() *v1.SecurityContext
- func GetRestrictedPodSecurityContext() *v1.PodSecurityContext
- func GetTestImage(id imageutils.ImageID) string
- func GetTestImageID(id imageutils.ImageID) imageutils.ImageID
- func IsPodActive(p *v1.Pod) bool
- func IsPodOnCgroupv2Node(f *framework.Framework, pod *v1.Pod) bool
- func LogPodStates(pods []v1.Pod)
- func MakePod(ns string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, securityLevel admissionapi.Level, command string) *v1.Pod
- func MakePodSpec(podConfig *Config) *v1.PodSpec
- func MakePodWithResizableContainers(ns, name, timeStamp string, tcInfo []ResizableContainerInfo) *v1.Pod
- func MakeSecPod(podConfig *Config) (*v1.Pod, error)
- func MixinRestrictedPodSecurity(pod *v1.Pod) error
- func MustMixinRestrictedPodSecurity(pod *v1.Pod) *v1.Pod
- func NewAgnhostContainer(containerName string, mounts []v1.VolumeMount, ports []v1.ContainerPort, args ...string) v1.Container
- func NewAgnhostPod(ns, podName string, volumes []v1.Volume, mounts []v1.VolumeMount, ports []v1.ContainerPort, args ...string) *v1.Pod
- func NewAgnhostPodFromContainers(ns, podName string, volumes []v1.Volume, containers ...v1.Container) *v1.Pod
- func NewExecPodSpec(ns, name string, hostNetwork bool) *v1.Pod
- func NewTransport(client kubernetes.Interface, restConfig *rest.Config) *http.Transport
- func PodsCreatedByLabel(ctx context.Context, c clientset.Interface, ns, name string, replicas int32, label labels.Selector) (*v1.PodList, error)
- func ResizeContainerPatch(containers []ResizableContainerInfo) (string, error)
- func RunningReady(p *v1.Pod) bool
- func SetAffinity(nodeSelection *NodeSelection, nodeName string)
- func SetAntiAffinity(nodeSelection *NodeSelection, nodeName string)
- func SetNodeAffinity(podSpec *v1.PodSpec, nodeName string)
- func SetNodeAffinityTopologyRequirement(nodeSelection *NodeSelection, topology map[string]string)
- func SetNodeSelection(podSpec *v1.PodSpec, nodeSelection NodeSelection)
- func VerifyCgroupValue(f *framework.Framework, pod *v1.Pod, cName, cgPath string, expectedCgValues ...string) error
- func VerifyExecInPodFail(ctx context.Context, f *framework.Framework, pod *v1.Pod, shExec string, exitCode int) error
- func VerifyExecInPodSucceed(ctx context.Context, f *framework.Framework, pod *v1.Pod, shExec string) error
- func VerifyOomScoreAdjValue(f *framework.Framework, pod *v1.Pod, cName, expectedOomScoreAdj string) error
- func VerifyPodContainersCgroupValues(ctx context.Context, f *framework.Framework, pod *v1.Pod, tcInfo []ResizableContainerInfo) error
- func VerifyPodHasConditionWithType(ctx context.Context, f *framework.Framework, pod *v1.Pod, cType v1.PodConditionType)
- func VerifyPodResizePolicy(gotPod *v1.Pod, wantInfo []ResizableContainerInfo)
- func VerifyPodResources(gotPod *v1.Pod, wantInfo []ResizableContainerInfo)
- func VerifyPodStatusResources(gotPod *v1.Pod, wantInfo []ResizableContainerInfo) error
- func VerifyPods(ctx context.Context, c clientset.Interface, ns, name string, selector labels.Selector, wantName bool, replicas int32) error
- func VerifyPodsRunning(ctx context.Context, c clientset.Interface, ns, name string, selector labels.Selector, wantName bool, replicas int32) error
- func WaitForAlmostAllPodsReady(ctx context.Context, c clientset.Interface, ns string, minPods, allowedNotReadyPods int, timeout time.Duration) error
- func WaitForContainerRunning(ctx context.Context, c clientset.Interface, namespace, podName, containerName string, timeout time.Duration) error
- func WaitForContainerTerminated(ctx context.Context, c clientset.Interface, namespace, podName, containerName string, timeout time.Duration) error
- func WaitForNRestartablePods(ctx context.Context, ps *testutils.PodStore, expect int, timeout time.Duration) ([]string, error)
- func WaitForNumberOfPods(ctx context.Context, c clientset.Interface, ns string, num int, timeout time.Duration) (pods *v1.PodList, err error)
- func WaitForPodCondition(ctx context.Context, c clientset.Interface, ns, podName, conditionDesc string, timeout time.Duration, condition podCondition) error
- func WaitForPodConditionObservedGeneration(ctx context.Context, c clientset.Interface, ns, podName string, conditionType v1.PodConditionType, expectedGeneration int64, timeout time.Duration) error
- func WaitForPodContainerStarted(ctx context.Context, c clientset.Interface, namespace, podName string, containerIndex int, timeout time.Duration) error
- func WaitForPodContainerToFail(ctx context.Context, c clientset.Interface, namespace, podName string, containerIndex int, reason string, timeout time.Duration) error
- func WaitForPodFailedReason(ctx context.Context, c clientset.Interface, pod *v1.Pod, reason string, timeout time.Duration) error
- func WaitForPodInitContainerStarted(ctx context.Context, c clientset.Interface, namespace, podName string, initContainerIndex int, timeout time.Duration) error
- func WaitForPodNameRunningInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string) error
- func WaitForPodNameUnschedulableInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string) error
- func WaitForPodNoLongerRunningInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string) error
- func WaitForPodNotFoundInNamespace(ctx context.Context, c clientset.Interface, podName, ns string, timeout time.Duration) error
- func WaitForPodNotPending(ctx context.Context, c clientset.Interface, ns, podName string) error
- func WaitForPodObservedGeneration(ctx context.Context, c clientset.Interface, ns, podName string, expectedGeneration int64, timeout time.Duration) error
- func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podClient *PodClient, pod *v1.Pod, expectedContainers []ResizableContainerInfo) *v1.Pod
- func WaitForPodRunningInNamespace(ctx context.Context, c clientset.Interface, pod *v1.Pod) error
- func WaitForPodRunningInNamespaceSlow(ctx context.Context, c clientset.Interface, podName, namespace string) error
- func WaitForPodScheduled(ctx context.Context, c clientset.Interface, namespace, podName string) error
- func WaitForPodSuccessInNamespace(ctx context.Context, c clientset.Interface, podName string, namespace string) error
- func WaitForPodSuccessInNamespaceTimeout(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
- func WaitForPodTerminatedInNamespace(ctx context.Context, c clientset.Interface, podName, reason, namespace string) error
- func WaitForPodTerminatingInNamespaceTimeout(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
- func WaitForPods(ctx context.Context, c clientset.Interface, ns string, opts metav1.ListOptions, r Range, timeout time.Duration, conditionDesc string, condition func(*v1.Pod) bool) (*v1.PodList, error)
- func WaitForPodsResponding(ctx context.Context, c clientset.Interface, ns string, controllerName string, selector labels.Selector, wantName bool, timeout time.Duration, pods *v1.PodList) error
- func WaitForPodsRunning(ctx context.Context, c clientset.Interface, ns string, num int, timeout time.Duration) error
- func WaitForPodsRunningReady(ctx context.Context, c clientset.Interface, ns string, minPods int, timeout time.Duration) error
- func WaitForPodsSchedulingGated(ctx context.Context, c clientset.Interface, ns string, num int, timeout time.Duration) error
- func WaitForPodsWithLabel(ctx context.Context, c clientset.Interface, ns string, label labels.Selector) (*v1.PodList, error)
- func WaitForPodsWithLabelRunningReady(ctx context.Context, c clientset.Interface, ns string, label labels.Selector, num int, timeout time.Duration) (pods *v1.PodList, err error)
- func WaitForPodsWithLabelScheduled(ctx context.Context, c clientset.Interface, ns string, label labels.Selector) (pods *v1.PodList, err error)
- func WaitForPodsWithSchedulingGates(ctx context.Context, c clientset.Interface, ns string, num int, timeout time.Duration, schedulingGates []v1.PodSchedulingGate) error
- func WaitTimeoutForPodNoLongerRunningInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
- func WaitTimeoutForPodReadyInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
- func WaitTimeoutForPodRunningInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
- func WaitTimeoutForPodRunningReadyInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
- func WithWindowsHostProcess(pod *v1.Pod, username string)
- type Addr
- func ParseAddr(addr string) (*Addr, error)
- func (a Addr) Network() string
- func (a Addr) String() string
- type Config
- type ContainerResources
- type Dialer
- func NewDialer(client kubernetes.Interface, restConfig *rest.Config) *Dialer
- func (d *Dialer) DialContainerPort(ctx context.Context, addr Addr) (conn net.Conn, finalErr error)
- type ExecOptions
- type LocalAddr
- type NodeSelection
- type PodClient
- func NewPodClient(f *framework.Framework) *PodClient
- func PodClientNS(f *framework.Framework, namespace string) *PodClient
- func (c *PodClient) AddEphemeralContainerSync(ctx context.Context, pod *v1.Pod, ec *v1.EphemeralContainer, timeout time.Duration) error
- func (c *PodClient) Create(ctx context.Context, pod *v1.Pod) *v1.Pod
- func (c *PodClient) CreateBatch(ctx context.Context, pods []*v1.Pod) []*v1.Pod
- func (c *PodClient) CreateSync(ctx context.Context, pod *v1.Pod) *v1.Pod
- func (c *PodClient) DeleteSync(ctx context.Context, name string, options metav1.DeleteOptions, timeout time.Duration)
- func (c *PodClient) MatchContainerOutput(ctx context.Context, name string, containerName string, expectedRegexp string) error
- func (c *PodClient) PodIsReady(ctx context.Context, name string) bool
- func (c *PodClient) RemoveFinalizer(ctx context.Context, podName string, finalizerName string)
- func (c *PodClient) Update(ctx context.Context, name string, updateFn func(pod *v1.Pod))
- func (c *PodClient) WaitForErrorEventOrSuccess(ctx context.Context, pod *v1.Pod) (*v1.Event, error)
- func (c *PodClient) WaitForErrorEventOrSuccessWithTimeout(ctx context.Context, pod *v1.Pod, timeout time.Duration) (*v1.Event, error)
- func (c *PodClient) WaitForFinish(ctx context.Context, name string, timeout time.Duration)
- func (c *PodClient) WaitForSuccess(ctx context.Context, name string, timeout time.Duration)
- func (c PodClient) WithOwnerTracking(value bool) *PodClient
- type Range
- type ResizableContainerInfo
Constants ¶
const ( VolumeMountPathTemplate = "/mnt/volume%d" VolumeMountPath1 = "/mnt/volume1" )
const ( // DefaultPodDeletionTimeout is the default timeout for deleting pod DefaultPodDeletionTimeout = 3 * time.Minute // which test created this pod? AnnotationTestOwner = "owner.test" )
const ( CgroupCPUPeriod string = "/sys/fs/cgroup/cpu/cpu.cfs_period_us" string = "/sys/fs/cgroup/cpu/cpu.shares" CgroupCPUQuota string = "/sys/fs/cgroup/cpu/cpu.cfs_quota_us" CgroupMemLimit string = "/sys/fs/cgroup/memory/memory.limit_in_bytes" Cgroupv2MemLimit string = "/sys/fs/cgroup/memory.max" Cgroupv2MemRequest string = "/sys/fs/cgroup/memory.min" Cgroupv2CPULimit string = "/sys/fs/cgroup/cpu.max" Cgroupv2CPURequest string = "/sys/fs/cgroup/cpu.weight" CPUPeriod string = "100000" MinContainerRuntimeVersion string = "1.6.9" )
const DefaultNonRootUser = 1000
DefaultNonRootUser is the default user ID used for running restricted (non-root) containers.
const DefaultNonRootUserName = "ContainerUser"
DefaultNonRootUserName is the default username in Windows used for running restricted (non-root) containers
const InfiniteSleepCommand = "trap exit TERM; while true; do sleep 1; done"
This command runs an infinite loop, sleeping for 1 second in each iteration. It sets up a trap to exit gracefully when a TERM signal is received.
This is useful for testing scenarios where the container is terminated with a zero exit code.
const InfiniteSleepCommandWithoutGracefulShutdown = "while true; do sleep 100000; done"
This command will cause the shell to remain in a sleep state indefinitely, and it won't exit unless it receives a KILL signal.
This is useful for testing scenarios where the container is terminated with a non-zero exit code.
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.
const ( // PodDeleteTimeout is how long to wait for a pod to be deleted. PodDeleteTimeout = 5 * time.Minute )
Variables ¶
var ( // GlobalOwnerTracking controls if newly created PodClients should automatically annotate // the pod with the owner test. The owner test is identified by "sourcecodepath:linenumber". // Annotating the pods this way is useful to troubleshoot tests which do insufficient cleanup. // Default is false to maximize backward compatibility. // See also: WithOwnerTracking, AnnotationTestOwner GlobalOwnerTracking bool )
global flags so we can enable features per-suite instead of per-client.
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 BeInPhase ¶
func BeInPhase(phase v1.PodPhase) types.GomegaMatcher
BeInPhase matches if pod.status.phase is the expected phase.
func BeRunningNoRetries ¶
func BeRunningNoRetries() types.GomegaMatcher
BeRunningNoRetries verifies that a pod starts running. It's a permanent failure when the pod enters some other permanent phase.
func BeRunningReadyNoRetries ¶
func BeRunningReadyNoRetries() types.GomegaMatcher
BeRunningReadyNoRetries verifies that a pod starts running and has a ready condition of status true. It's a permanent failure when the pod enters some other permanent phase.
func CheckPodsRunningReady ¶
func CheckPodsRunningReady(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, securityLevel admissionapi.Level, command string) (*v1.Pod, error)
CreatePod with given claims based on node selector
func CreateSecPod ¶
func CreateSecPod(ctx context.Context, client clientset.Interface, podConfig *Config, timeout time.Duration) (*v1.Pod, error)
CreateSecPod creates security pod with given claims
func CreateSecPodWithNodeSelection ¶
func CreateSecPodWithNodeSelection(ctx context.Context, client clientset.Interface, podConfig *Config, timeout time.Duration) (*v1.Pod, error)
CreateSecPodWithNodeSelection creates security pod with given claims
func CreateUnschedulablePod ¶
func CreateUnschedulablePod(ctx context.Context, client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, securityLevel admissionapi.Level, command string) (*v1.Pod, error)
CreateUnschedulablePod with given claims based on node selector
func DeletePodOrFail ¶
DeletePodOrFail deletes the pod of the specified namespace and name. Resilient to the pod not existing.
func DeletePodWithGracePeriod ¶
func DeletePodWithGracePeriod(ctx context.Context, c clientset.Interface, pod *v1.Pod, grace int64) error
DeletePodWithGracePeriod deletes the passed-in pod. Resilient to the pod not existing.
func DeletePodWithGracePeriodByName ¶
func DeletePodWithGracePeriodByName(ctx context.Context, 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 ¶
DeletePodWithWait deletes the passed-in pod and waits for the pod to be terminated. Resilient to the pod not existing.
func DeletePodWithWaitByName ¶
func DeletePodWithWaitByName(ctx context.Context, 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 ¶
func DeletePodsWithGracePeriod(ctx context.Context, 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(ctx context.Context, c clientset.Interface, namespace, reportDir string)
DumpAllPodInfoForNamespace logs all pod information for a given namespace.
func ExecCommandInContainer ¶
func ExecCommandInContainer(f *framework.Framework, podName, containerName string, cmd ...string) string
ExecCommandInContainer executes a command in the specified container.
func ExecCommandInContainerWithFullOutput ¶
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 ¶
ExecShellInContainer executes the specified command on the pod's container.
func ExecShellInPod ¶
ExecShellInPod executes the specified command on the pod.
func ExecShellInPodWithFullOutput ¶
func ExecShellInPodWithFullOutput(ctx context.Context, 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 ¶
ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.
func ExecWithOptionsContext ¶
func ExecWithOptionsContext(ctx context.Context, f *framework.Framework, options ExecOptions) (string, string, error)
func ExpectPodResized ¶
func ExpectPodResized(ctx context.Context, f *framework.Framework, resizedPod *v1.Pod, expectedContainers []ResizableContainerInfo)
func FilterActivePods ¶
FilterActivePods returns pods that have not terminated.
func FilterNonRestartablePods ¶
FilterNonRestartablePods filters out pods that will never get recreated if deleted after termination.
func FindContainerInPod ¶
FindContainerInPod finds the container in a pod by its name
func FindContainerStatusInPod ¶
func FindContainerStatusInPod(pod *v1.Pod, containerName string) *v1.ContainerStatus
FindContainerStatusInPod finds a container status by its name in the provided pod
func FindPodConditionByType ¶
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 FormatPod ¶
FormatPod returns a string representing a pod in a consistent human readable format, with pod name, namespace and pod UID as part of the string. This code is taken from k/k/pkg/kubelet/util/format/pod.go to remove e2e framework -> k/k/pkg/kubelet dependency.
func GenerateContainerSecurityContext ¶
func GenerateContainerSecurityContext(level psaapi.Level) *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 ¶
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 ¶
GenerateScriptCmd generates the corresponding command lines to execute a command.
func Get ¶
Get creates a function which retrieves the pod anew each time the function is called. Fatal errors are detected by framework.GetObject and cause polling to stop.
func GetCPULimitCgroupExpectations ¶
TODO: Remove the rounded cpu limit values when https://github.com/opencontainers/runc/issues/4622 is fixed.
func GetDefaultNonRootUser ¶
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 ¶
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 ¶
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 ¶
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(ctx context.Context, c clientset.Interface, namespace, podName, containerName string) (string, error)
GetPodLogs returns the logs of the specified container (namespace/pod/container).
func GetPodLogsSince ¶
func GetPodLogsSince(ctx context.Context, 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 ¶
GetPodSecretUpdateTimeout returns the timeout duration for updating pod secret.
func GetPods ¶
func GetPods(ctx context.Context, 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(ctx context.Context, c clientset.Interface, ns string, ignoreLabels map[string]string) ([]*v1.Pod, error)
GetPodsInNamespace returns the pods in the given namespace.
func GetPreviousPodLogs ¶
func GetPreviousPodLogs(ctx context.Context, 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 ¶
func GetRestrictedContainerSecurityContext() *v1.SecurityContext
GetRestrictedContainerSecurityContext returns a minimal restricted container security context.
func GetRestrictedPodSecurityContext ¶
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 ¶
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 ¶
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 IsPodActive ¶
IsPodActive return true if the pod meets certain conditions.
func IsPodOnCgroupv2Node ¶
IsPodOnCgroupv2Node checks whether the pod is running on cgroupv2 node. TODO: Deduplicate this function with NPD cluster e2e test: https://github.com/kubernetes/kubernetes/blob/2049360379bcc5d6467769cef112e6e492d3d2f0/test/e2e/node/node_problem_detector.go#L369
func LogPodStates ¶
LogPodStates logs basic info of provided pods for debugging.
func MakePod ¶
func MakePod(ns string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, securityLevel admissionapi.Level, 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 ¶
MakePodSpec returns a PodSpec definition
func MakePodWithResizableContainers ¶
func MakePodWithResizableContainers(ns, name, timeStamp string, tcInfo []ResizableContainerInfo) *v1.Pod
func MakeSecPod ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func NewAgnhostPodFromContainers(ns, podName string, volumes []v1.Volume, containers ...v1.Container) *v1.Pod
func NewExecPodSpec ¶
NewExecPodSpec returns the pod spec of hostexec pod
func NewTransport ¶
NewTransport creates a transport which uses the port forward dialer. URLs must use <namespace>.<pod>:<port> as host.
func PodsCreatedByLabel ¶
func PodsCreatedByLabel(ctx context.Context, 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 ResizeContainerPatch ¶
func ResizeContainerPatch(containers []ResizableContainerInfo) (string, error)
ResizeContainerPatch generates a patch string to resize the pod container.
func RunningReady ¶
RunningReady checks whether pod p's phase is running and it has a ready condition of status true.
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 ¶
SetNodeAffinity modifies the given pod object with NodeAffinity to the given node name.
func SetNodeAffinityTopologyRequirement ¶
func SetNodeAffinityTopologyRequirement(nodeSelection *NodeSelection, topology map[string]string)
SetNodeAffinityTopologyRequirement sets node affinity to a specified topology
func SetNodeSelection ¶
func SetNodeSelection(podSpec *v1.PodSpec, nodeSelection NodeSelection)
SetNodeSelection modifies the given pod object with the specified NodeSelection
func VerifyCgroupValue ¶
func VerifyCgroupValue(f *framework.Framework, pod *v1.Pod, cName, cgPath string, expectedCgValues ...string) error
VerifyCgroupValue verifies that the given cgroup path has the expected value in the specified container of the pod. It execs into the container to retrieve the cgroup value, and ensures that the retrieved cgroup value is equivalent to at least one of the values in expectedCgValues.
func VerifyExecInPodFail ¶
func VerifyExecInPodFail(ctx context.Context, f *framework.Framework, pod *v1.Pod, shExec string, exitCode int) error
VerifyExecInPodFail verifies shell cmd in target pod fail with certain exit code
func VerifyExecInPodSucceed ¶
func VerifyExecInPodSucceed(ctx context.Context, f *framework.Framework, pod *v1.Pod, shExec string) error
VerifyExecInPodSucceed verifies shell cmd in target pod succeed
func VerifyOomScoreAdjValue ¶
func VerifyOomScoreAdjValue(f *framework.Framework, pod *v1.Pod, cName, expectedOomScoreAdj string) error
VerifyOomScoreAdjValue verifies that oom_score_adj for pid 1 (pidof init/systemd -> app) has the expected value in specified container of the pod. It execs into the container, reads the oom_score_adj value from procfs, and compares it against the expected value.
func VerifyPodContainersCgroupValues ¶
func VerifyPodContainersCgroupValues(ctx context.Context, f *framework.Framework, pod *v1.Pod, tcInfo []ResizableContainerInfo) error
func VerifyPodHasConditionWithType ¶
func VerifyPodHasConditionWithType(ctx context.Context, f *framework.Framework, pod *v1.Pod, cType v1.PodConditionType)
VerifyPodHasConditionWithType verifies the pod has the expected condition by type
func VerifyPodResizePolicy ¶
func VerifyPodResizePolicy(gotPod *v1.Pod, wantInfo []ResizableContainerInfo)
func VerifyPodResources ¶
func VerifyPodResources(gotPod *v1.Pod, wantInfo []ResizableContainerInfo)
func VerifyPodStatusResources ¶
func VerifyPodStatusResources(gotPod *v1.Pod, wantInfo []ResizableContainerInfo) error
func VerifyPods ¶
func VerifyPods(ctx context.Context, c clientset.Interface, ns, name string, selector labels.Selector, wantName bool, replicas int32) error
VerifyPods checks if the specified pod is responding.
func VerifyPodsRunning ¶
func VerifyPodsRunning(ctx context.Context, c clientset.Interface, ns, name string, selector labels.Selector, wantName bool, replicas int32) error
VerifyPodsRunning checks if the specified pod is running.
func WaitForAlmostAllPodsReady ¶
func WaitForAlmostAllPodsReady(ctx context.Context, c clientset.Interface, ns string, minPods, allowedNotReadyPods int, timeout time.Duration) error
WaitForAlmostAllReady waits up to timeout for the following conditions: 1. At least minPods Pods in Namespace ns are Running and Ready 2. All Pods in Namespace ns are either Ready or Succeeded 3. All Pods part of a ReplicaSet or ReplicationController in Namespace ns are Ready
After the timeout has elapsed, an error is returned if the number of Pods in a Pending Phase is greater than allowedNotReadyPods.
It is generally recommended to use WaitForPodsRunningReady instead of this function whenever possible, because its behavior is more intuitive. Similar to WaitForPodsRunningReady, this function requests the list of pods on every iteration, making it useful for situations where the set of Pods is likely changing, such as during cluster startup.
If minPods or allowedNotReadyPods are -1, this method returns immediately without waiting.
func WaitForContainerRunning ¶
func WaitForContainerRunning(ctx context.Context, 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 WaitForContainerTerminated ¶
func WaitForContainerTerminated(ctx context.Context, c clientset.Interface, namespace, podName, containerName string, timeout time.Duration) error
WaitForContainerTerminated waits for the given Pod container to have a state of terminated
func WaitForNRestartablePods ¶
func WaitForNRestartablePods(ctx context.Context, 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 ¶
func WaitForNumberOfPods(ctx context.Context, 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(ctx context.Context, c clientset.Interface, ns, podName, conditionDesc string, timeout time.Duration, condition podCondition) error
WaitForPodCondition waits for a pod to be matched to the given condition. The condition callback may use gomega.StopTrying to abort early.
func WaitForPodConditionObservedGeneration ¶
func WaitForPodConditionObservedGeneration(ctx context.Context, c clientset.Interface, ns, podName string, conditionType v1.PodConditionType, expectedGeneration int64, timeout time.Duration) error
WaitForPodConditionObservedGeneration waits for a pod condition to have the given observed generation.
func WaitForPodContainerStarted ¶
func WaitForPodContainerStarted(ctx context.Context, 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 ¶
func WaitForPodContainerToFail(ctx context.Context, 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 ¶
func WaitForPodFailedReason(ctx context.Context, c clientset.Interface, pod *v1.Pod, reason string, timeout time.Duration) error
WaitForPodFailedReason wait for pod failed reason in status, for example "SysctlForbidden".
func WaitForPodInitContainerStarted ¶
func WaitForPodInitContainerStarted(ctx context.Context, c clientset.Interface, namespace, podName string, initContainerIndex int, timeout time.Duration) error
WaitForPodInitContainerStarted waits for the given Pod init container to start.
func WaitForPodNameRunningInNamespace ¶
func WaitForPodNameRunningInNamespace(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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" and that error is final, that error is returned and the wait stops.
func WaitForPodNotPending ¶
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 WaitForPodObservedGeneration ¶
func WaitForPodObservedGeneration(ctx context.Context, c clientset.Interface, ns, podName string, expectedGeneration int64, timeout time.Duration) error
WaitForPodObservedGeneration waits for a pod to have the given observed generation.
func WaitForPodResizeActuation ¶
func WaitForPodResizeActuation(ctx context.Context, f *framework.Framework, podClient *PodClient, pod *v1.Pod, expectedContainers []ResizableContainerInfo) *v1.Pod
func WaitForPodRunningInNamespace ¶
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(ctx context.Context, 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 WaitForPodScheduled ¶
func WaitForPodScheduled(ctx context.Context, c clientset.Interface, namespace, podName string) error
WaitForPodScheduled waits for the pod to be schedule, ie. the .spec.nodeName is set
func WaitForPodSuccessInNamespace ¶
func WaitForPodSuccessInNamespace(ctx context.Context, 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 WaitForPodSuccessInNamespaceTimeout ¶
func WaitForPodSuccessInNamespaceTimeout(ctx context.Context, 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(ctx context.Context, 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 ¶
func WaitForPodTerminatingInNamespaceTimeout(ctx context.Context, 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 WaitForPods ¶
func WaitForPods(ctx context.Context, c clientset.Interface, ns string, opts metav1.ListOptions, r Range, timeout time.Duration, conditionDesc string, condition func(*v1.Pod) bool) (*v1.PodList, error)
WaitForPods waits for pods in the given namespace to match the given condition. How many pods must exist and how many must match the condition is determined by the range parameter. The condition callback may use gomega.StopTrying(...).Now() to abort early. The condition description will be used with "expected pods to <description>".
func WaitForPodsResponding ¶
func WaitForPodsResponding(ctx context.Context, c clientset.Interface, ns string, controllerName string, selector labels.Selector, wantName bool, timeout time.Duration, pods *v1.PodList) error
WaitForPodsResponding waits for the pods to response.
func WaitForPodsRunning ¶
func WaitForPodsRunning(ctx context.Context, 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(ctx context.Context, c clientset.Interface, ns string, minPods int, timeout time.Duration) error
WaitForPodsRunningReady waits up to timeout for the following conditions:
- At least minPods Pods in Namespace ns are Running and Ready
- No Pods in Namespace ns are Failed and not owned by a controller or Pending
An error is returned if either of these conditions are not met within the timeout.
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.
func WaitForPodsSchedulingGated ¶
func WaitForPodsSchedulingGated(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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 ¶
func WaitForPodsWithSchedulingGates(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
WaitTimeoutForPodRunningInNamespace waits the given timeout duration for the specified pod to become running. It does not need to exist yet when this function gets called and the pod is not expected to be recreated when it succeeds or fails.
func WaitTimeoutForPodRunningReadyInNamespace ¶
func WaitTimeoutForPodRunningReadyInNamespace(ctx context.Context, c clientset.Interface, podName, namespace string, timeout time.Duration) error
WaitTimeoutForPodRunningReadyInNamespace waits the given timeout duration for the specified pod to become running and have a ready condition of status true. It does not need to exist yet when this function gets called and the pod is not expected to be recreated when it succeeds or fails.
func WithWindowsHostProcess ¶
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 ¶
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 ¶
ParseAddr expects a <namespace>.<pod>:<port number> as produced by Addr.String.
func (Addr) Network ¶
func (Addr) String ¶
type Config ¶
type Config struct { NS string PVCs []*v1.PersistentVolumeClaim PVCsReadOnly bool InlineVolumeSources []*v1.VolumeSource SecurityLevel admissionapi.Level 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 ContainerResources ¶
type ContainerResources struct { CPUReq string CPULim string MemReq string MemLim string EphStorReq string EphStorLim string ExtendedResourceReq string ExtendedResourceLim string }
func (*ContainerResources) ResourceRequirements ¶
func (cr *ContainerResources) ResourceRequirements() *v1.ResourceRequirements
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
Dialer holds the relevant parameters that are independent of a particular connection.
func NewDialer ¶
func NewDialer(client kubernetes.Interface, restConfig *rest.Config) *Dialer
NewDialer creates a dialer that supports connecting to container ports.
func (*Dialer) DialContainerPort ¶
DialContainerPort connects to a certain container port in a pod.
type ExecOptions ¶
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 LocalAddr ¶
type LocalAddr struct{}
func (LocalAddr) Network ¶
func (LocalAddr) String ¶
type NodeSelection ¶
NodeSelection specifies where to run a pod, using a combination of fixed node name, node selector and/or affinity.
type PodClient ¶
type PodClient struct { v1core.PodInterface // contains filtered or unexported fields }
PodClient is a struct for pod client.
func NewPodClient ¶
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 ¶
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 ¶
func (c *PodClient) AddEphemeralContainerSync(ctx context.Context, 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 ¶
Create creates a new pod according to the framework specifications (don't wait for it to start).
func (*PodClient) CreateBatch ¶
CreateBatch create a batch of pods. All pods are created before waiting.
func (*PodClient) CreateSync ¶
CreateSync creates a new pod according to the framework specifications, and wait for it to start and be running and ready.
func (*PodClient) DeleteSync ¶
func (c *PodClient) DeleteSync(ctx context.Context, 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 ¶
func (c *PodClient) MatchContainerOutput(ctx context.Context, name string, containerName string, expectedRegexp string) error
MatchContainerOutput gets output of a container and match expected regexp in the output.
func (*PodClient) PodIsReady ¶
PodIsReady returns true if the specified pod is ready. Otherwise false.
func (*PodClient) RemoveFinalizer ¶
RemoveFinalizer removes the pod's finalizer
func (*PodClient) Update ¶
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 ¶
WaitForErrorEventOrSuccess waits for pod to succeed or an error event for that pod.
func (*PodClient) WaitForErrorEventOrSuccessWithTimeout ¶
func (c *PodClient) WaitForErrorEventOrSuccessWithTimeout(ctx context.Context, pod *v1.Pod, timeout time.Duration) (*v1.Event, error)
WaitForErrorEventOrSuccessWithTimeout waits for pod to succeed or an error event for that pod for a specified time
func (*PodClient) WaitForFinish ¶
WaitForFinish waits for pod to finish running, regardless of success or failure.
func (*PodClient) WaitForSuccess ¶
WaitForSuccess waits for pod to succeed. TODO(random-liu): Move pod wait function into this file
func (PodClient) WithOwnerTracking ¶
WithOwnerTracking controls automatic add of annotations recording the code location which created a pod. This is helpful when troubleshooting e2e tests (like e2e_node) which leak pods because insufficient cleanup. Note we want a shallow clone to avoid mutating the receiver. The default is the value of GlobalOwnerTracking *when the client was created*.
type Range ¶
type Range struct { // MinMatching must be <= actual matching items or <= 0. MinMatching int // MaxMatching must be >= actual matching items or <= 0. // To check for "no matching items", set NonMatching. MaxMatching int // NoneMatching indicates that no item must match. NoneMatching bool // AllMatching indicates that all items must match. AllMatching bool // MinFound must be <= existing items or <= 0. MinFound int }
Range determines how many items must exist and how many must match a certain condition. Values <= 0 are ignored. TODO (?): move to test/e2e/framework/range
func (Range) Min ¶
Min returns how many items must exist.
type ResizableContainerInfo ¶
type ResizableContainerInfo struct { Name string Resources *ContainerResources CPUPolicy *v1.ResourceResizeRestartPolicy MemPolicy *v1.ResourceResizeRestartPolicy RestartCount int32 RestartPolicy v1.ContainerRestartPolicy InitCtr bool }
func UpdateExpectedContainerRestarts ¶
func UpdateExpectedContainerRestarts(ctx context.Context, pod *v1.Pod, expectedContainers []ResizableContainerInfo) []ResizableContainerInfo
UpdateExpectedContainerRestarts updates the RestartCounts in expectedContainers by adding them to the existing RestartCounts in the containerStatuses of the provided pod. This reduces the flakiness of the RestartCount assertions by grabbing the current restart count right before the resize operation, and verify the expected increment (0 or 1) rather than the absolute count.
Source Files ¶
create.go delete.go dial.go exec_util.go get.go node_selection.go pod_client.go resize.go resource.go utils.go wait.go
Directories ¶
Path | Synopsis |
---|---|
test/e2e/framework/pod/output |
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 56 packages
- Last checked
- 3 hours ago –
Tools for package owners.