package node
import "k8s.io/kubernetes/test/e2e/framework/node"
Index ¶
- func AddExtendedResource(ctx context.Context, clientSet clientset.Interface, nodeName string, extendedResourceName v1.ResourceName, extendedResourceQuantity resource.Quantity)
- func AddOrUpdateLabelOnNode(c clientset.Interface, nodeName string, labelKey, labelValue string)
- func AddOrUpdateTaintOnNode(ctx context.Context, c clientset.Interface, nodeName string, taint v1.Taint)
- func AllNodesReady(ctx context.Context, c clientset.Interface, timeout time.Duration) error
- func CheckReady(ctx context.Context, c clientset.Interface, size int, timeout time.Duration) ([]v1.Node, error)
- func CheckReadyForTests(ctx context.Context, c clientset.Interface, nonblockingTaints string, allowedNotReadyNodes, largeClusterThreshold int) func(ctx context.Context) (bool, error)
- func CollectAddresses(nodes *v1.NodeList, addressType v1.NodeAddressType) []string
- func CreatePodsPerNodeForSimpleApp(ctx context.Context, c clientset.Interface, namespace, appName string, podSpec func(n v1.Node) v1.PodSpec, maxCount int) map[string]string
- func ExpectNodeHasLabel(ctx context.Context, c clientset.Interface, nodeName string, labelKey string, labelValue string)
- func ExpectNodeHasTaint(ctx context.Context, c clientset.Interface, nodeName string, taint *v1.Taint)
- func Filter(nodeList *v1.NodeList, fn func(node v1.Node) bool)
- func FirstAddress(nodelist *v1.NodeList, addrType v1.NodeAddressType) string
- func FirstAddressByTypeAndFamily(nodelist *v1.NodeList, addrType v1.NodeAddressType, family v1.IPFamily) string
- func GetAddresses(node *v1.Node, addressType v1.NodeAddressType) (ips []string)
- func GetAddressesByTypeAndFamily(node *v1.Node, addressType v1.NodeAddressType, family v1.IPFamily) (ips []string)
- func GetBoundedReadySchedulableNodes(ctx context.Context, c clientset.Interface, maxNodes int) (nodes *v1.NodeList, err error)
- func GetClusterZones(ctx context.Context, c clientset.Interface) (sets.String, error)
- func GetNodeHeartbeatTime(node *v1.Node) metav1.Time
- func GetPublicIps(ctx context.Context, c clientset.Interface) ([]string, error)
- func GetRandomReadySchedulableNode(ctx context.Context, c clientset.Interface) (*v1.Node, error)
- func GetReadyNodesIncludingTainted(ctx context.Context, c clientset.Interface) (nodes *v1.NodeList, err error)
- func GetReadySchedulableNodes(ctx context.Context, c clientset.Interface) (nodes *v1.NodeList, err error)
- func GetSSHExternalIP(node *v1.Node) (string, error)
- func GetSSHInternalIP(node *v1.Node) (string, error)
- func GetSchedulableClusterZones(ctx context.Context, c clientset.Interface) (sets.Set[string], error)
- func IsARM64(node *v1.Node) bool
- func IsConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
- func IsConditionSetAsExpectedSilent(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
- func IsNodeReady(node *v1.Node) bool
- func IsNodeSchedulable(node *v1.Node) bool
- func NodeHasTaint(ctx context.Context, c clientset.Interface, nodeName string, taint *v1.Taint) (bool, error)
- func PickIP(ctx context.Context, c clientset.Interface) (string, error)
- func RemoveExtendedResource(ctx context.Context, clientSet clientset.Interface, nodeName string, extendedResourceName v1.ResourceName)
- func RemoveLabelOffNode(c clientset.Interface, nodeName string, labelKey string)
- func RemoveTaintOffNode(ctx context.Context, c clientset.Interface, nodeName string, taint v1.Taint)
- func RemoveTaintsOffNode(ctx context.Context, c clientset.Interface, nodeName string, taints []v1.Taint)
- func TotalReady(ctx context.Context, c clientset.Interface) (int, error)
- func TotalRegistered(ctx context.Context, c clientset.Interface) (int, error)
- func WaitConditionToBe(ctx context.Context, c clientset.Interface, name string, conditionType v1.NodeConditionType, wantTrue bool, timeout time.Duration) bool
- func WaitForAllNodesSchedulable(ctx context.Context, c clientset.Interface, timeout time.Duration) error
- func WaitForNodeHeartbeatAfter(ctx context.Context, c clientset.Interface, name string, after metav1.Time, timeout time.Duration)
- func WaitForNodeSchedulable(ctx context.Context, c clientset.Interface, name string, timeout time.Duration, wantSchedulable bool) bool
- func WaitForNodeToBeNotReady(ctx context.Context, c clientset.Interface, name string, timeout time.Duration) bool
- func WaitForNodeToBeReady(ctx context.Context, c clientset.Interface, name string, timeout time.Duration) bool
- func WaitForReadyNodes(ctx context.Context, c clientset.Interface, size int, timeout time.Duration) error
- func WaitForSSHTunnels(ctx context.Context, namespace string)
- func WaitForTotalHealthy(ctx context.Context, c clientset.Interface, timeout time.Duration) error
- type NodeKiller
- func NewNodeKiller(config framework.NodeKillerConfig, client clientset.Interface, provider string) *NodeKiller
- func (k *NodeKiller) Run(ctx context.Context)
- type PodNode
Functions ¶
func AddExtendedResource ¶
func AddExtendedResource(ctx context.Context, clientSet clientset.Interface, nodeName string, extendedResourceName v1.ResourceName, extendedResourceQuantity resource.Quantity)
AddExtendedResource adds a fake resource to the Node.
func AddOrUpdateLabelOnNode ¶
AddOrUpdateLabelOnNode adds the given label key and value to the given node or updates value.
func AddOrUpdateTaintOnNode ¶
func AddOrUpdateTaintOnNode(ctx context.Context, c clientset.Interface, nodeName string, taint v1.Taint)
AddOrUpdateTaintOnNode adds the given taint to the given node or updates taint.
func AllNodesReady ¶
AllNodesReady checks whether all registered nodes are ready. Setting -1 on framework.TestContext.AllowedNotReadyNodes will bypass the post test node readiness check. TODO: we should change the AllNodesReady call in AfterEach to WaitForAllNodesHealthy, and figure out how to do it in a configurable way, as we can't expect all setups to run default test add-ons.
func CheckReady ¶
func CheckReady(ctx context.Context, c clientset.Interface, size int, timeout time.Duration) ([]v1.Node, error)
CheckReady waits up to timeout for cluster to has desired size and there is no not-ready nodes in it. By cluster size we mean number of schedulable Nodes.
func CheckReadyForTests ¶
func CheckReadyForTests(ctx context.Context, c clientset.Interface, nonblockingTaints string, allowedNotReadyNodes, largeClusterThreshold int) func(ctx context.Context) (bool, error)
CheckReadyForTests returns a function which will return 'true' once the number of ready nodes is above the allowedNotReadyNodes threshold (i.e. to be used as a global gate for starting the tests).
func CollectAddresses ¶
func CollectAddresses(nodes *v1.NodeList, addressType v1.NodeAddressType) []string
CollectAddresses returns a list of addresses of the given addressType for the given list of nodes
func CreatePodsPerNodeForSimpleApp ¶
func CreatePodsPerNodeForSimpleApp(ctx context.Context, c clientset.Interface, namespace, appName string, podSpec func(n v1.Node) v1.PodSpec, maxCount int) map[string]string
CreatePodsPerNodeForSimpleApp creates pods w/ labels. Useful for tests which make a bunch of pods w/o any networking.
func ExpectNodeHasLabel ¶
func ExpectNodeHasLabel(ctx context.Context, c clientset.Interface, nodeName string, labelKey string, labelValue string)
ExpectNodeHasLabel expects that the given node has the given label pair.
func ExpectNodeHasTaint ¶
func ExpectNodeHasTaint(ctx context.Context, c clientset.Interface, nodeName string, taint *v1.Taint)
ExpectNodeHasTaint expects that the node has the given taint.
func Filter ¶
Filter filters nodes in NodeList in place, removing nodes that do not satisfy the given condition
func FirstAddress ¶
func FirstAddress(nodelist *v1.NodeList, addrType v1.NodeAddressType) string
FirstAddress returns the first address of the given type of each node.
func FirstAddressByTypeAndFamily ¶
func FirstAddressByTypeAndFamily(nodelist *v1.NodeList, addrType v1.NodeAddressType, family v1.IPFamily) string
FirstAddressByTypeAndFamily returns the first address that matches the given type and family of the list of nodes
func GetAddresses ¶
func GetAddresses(node *v1.Node, addressType v1.NodeAddressType) (ips []string)
GetAddresses returns a list of addresses of the given addressType for the given node
func GetAddressesByTypeAndFamily ¶
func GetAddressesByTypeAndFamily(node *v1.Node, addressType v1.NodeAddressType, family v1.IPFamily) (ips []string)
GetAddressesByTypeAndFamily returns a list of addresses of the given addressType for the given node and filtered by IPFamily
func GetBoundedReadySchedulableNodes ¶
func GetBoundedReadySchedulableNodes(ctx context.Context, c clientset.Interface, maxNodes int) (nodes *v1.NodeList, err error)
GetBoundedReadySchedulableNodes is like GetReadySchedulableNodes except that it returns at most maxNodes nodes. Use this to keep your test case from blowing up when run on a large cluster.
func GetClusterZones ¶
GetClusterZones returns the values of zone label collected from all nodes.
func GetNodeHeartbeatTime ¶
GetNodeHeartbeatTime returns the timestamp of the last status update of the node.
func GetPublicIps ¶
GetPublicIps returns a public IP list of nodes.
func GetRandomReadySchedulableNode ¶
GetRandomReadySchedulableNode gets a single randomly-selected node which is available for running pods on. If there are no available nodes it will return an error.
func GetReadyNodesIncludingTainted ¶
func GetReadyNodesIncludingTainted(ctx context.Context, c clientset.Interface) (nodes *v1.NodeList, err error)
GetReadyNodesIncludingTainted returns all ready nodes, even those which are tainted. There are cases when we care about tainted nodes E.g. in tests related to nodes with gpu we care about nodes despite presence of nvidia.com/gpu=present:NoSchedule taint
func GetReadySchedulableNodes ¶
func GetReadySchedulableNodes(ctx context.Context, c clientset.Interface) (nodes *v1.NodeList, err error)
GetReadySchedulableNodes addresses the common use case of getting nodes you can do work on. 1) Needs to be schedulable. 2) Needs to be ready. If EITHER 1 or 2 is not true, most tests will want to ignore the node entirely. If there are no nodes that are both ready and schedulable, this will return an error.
func GetSSHExternalIP ¶
GetSSHExternalIP returns node external IP concatenated with port 22 for ssh e.g. 1.2.3.4:22
func GetSSHInternalIP ¶
GetSSHInternalIP returns node internal IP concatenated with port 22 for ssh
func GetSchedulableClusterZones ¶
func GetSchedulableClusterZones(ctx context.Context, c clientset.Interface) (sets.Set[string], error)
GetSchedulableClusterZones returns the values of zone label collected from all nodes which are schedulable.
func IsARM64 ¶
IsARM64 checks whether the k8s Node has arm64 arch.
func IsConditionSetAsExpected ¶
func IsConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
IsConditionSetAsExpected returns a wantTrue value if the node has a match to the conditionType, otherwise returns an opposite value of the wantTrue with detailed logging.
func IsConditionSetAsExpectedSilent ¶
func IsConditionSetAsExpectedSilent(node *v1.Node, conditionType v1.NodeConditionType, wantTrue bool) bool
IsConditionSetAsExpectedSilent returns a wantTrue value if the node has a match to the conditionType, otherwise returns an opposite value of the wantTrue.
func IsNodeReady ¶
IsNodeReady returns true if: 1) it's Ready condition is set to true 2) doesn't have NetworkUnavailable condition set to true
func IsNodeSchedulable ¶
IsNodeSchedulable returns true if: 1) doesn't have "unschedulable" field set 2) it also returns true from IsNodeReady
func NodeHasTaint ¶
func NodeHasTaint(ctx context.Context, c clientset.Interface, nodeName string, taint *v1.Taint) (bool, error)
NodeHasTaint returns true if the node has the given taint, else returns false.
func PickIP ¶
PickIP picks one public node IP
func RemoveExtendedResource ¶
func RemoveExtendedResource(ctx context.Context, clientSet clientset.Interface, nodeName string, extendedResourceName v1.ResourceName)
RemoveExtendedResource removes a fake resource from the Node.
func RemoveLabelOffNode ¶
RemoveLabelOffNode is for cleaning up labels temporarily added to node, won't fail if target label doesn't exist or has been removed.
func RemoveTaintOffNode ¶
func RemoveTaintOffNode(ctx context.Context, c clientset.Interface, nodeName string, taint v1.Taint)
RemoveTaintOffNode removes the given taint from the given node.
func RemoveTaintsOffNode ¶
func RemoveTaintsOffNode(ctx context.Context, c clientset.Interface, nodeName string, taints []v1.Taint)
RemoveTaintsOffNode removes a list of taints from the given node It is simply a helper wrapper for RemoveTaintOffNode
func TotalReady ¶
TotalReady returns number of ready schedulable Nodes.
func TotalRegistered ¶
TotalRegistered returns number of schedulable Nodes.
func WaitConditionToBe ¶
func WaitConditionToBe(ctx context.Context, c clientset.Interface, name string, conditionType v1.NodeConditionType, wantTrue bool, timeout time.Duration) bool
WaitConditionToBe returns whether node "name's" condition state matches wantTrue within timeout. If wantTrue is true, it will ensure the node condition status is ConditionTrue; if it's false, it ensures the node condition is in any state other than ConditionTrue (e.g. not true or unknown).
func WaitForAllNodesSchedulable ¶
func WaitForAllNodesSchedulable(ctx context.Context, c clientset.Interface, timeout time.Duration) error
WaitForAllNodesSchedulable waits up to timeout for all (but TestContext.AllowedNotReadyNodes) to become schedulable.
func WaitForNodeHeartbeatAfter ¶
func WaitForNodeHeartbeatAfter(ctx context.Context, c clientset.Interface, name string, after metav1.Time, timeout time.Duration)
WaitForNodeHeartbeatAfter waits up to timeout for node to send the next heartbeat after the given timestamp.
To ensure the node status is posted by a restarted kubelet process, after should be retrieved by GetNodeHeartbeatTime while the kubelet is down.
func WaitForNodeSchedulable ¶
func WaitForNodeSchedulable(ctx context.Context, c clientset.Interface, name string, timeout time.Duration, wantSchedulable bool) bool
func WaitForNodeToBeNotReady ¶
func WaitForNodeToBeNotReady(ctx context.Context, c clientset.Interface, name string, timeout time.Duration) bool
WaitForNodeToBeNotReady returns whether node name is not ready (i.e. the readiness condition is anything but ready, e.g false or unknown) within timeout.
func WaitForNodeToBeReady ¶
func WaitForNodeToBeReady(ctx context.Context, c clientset.Interface, name string, timeout time.Duration) bool
WaitForNodeToBeReady returns whether node name is ready within timeout.
func WaitForReadyNodes ¶
func WaitForReadyNodes(ctx context.Context, c clientset.Interface, size int, timeout time.Duration) error
WaitForReadyNodes waits up to timeout for cluster to has desired size and there is no not-ready nodes in it. By cluster size we mean number of schedulable Nodes.
func WaitForSSHTunnels ¶
WaitForSSHTunnels waits for establishing SSH tunnel to busybox pod.
func WaitForTotalHealthy ¶
WaitForTotalHealthy checks whether all registered nodes are ready and all required Pods are running on them.
Types ¶
type NodeKiller ¶
type NodeKiller struct {
// contains filtered or unexported fields
}
NodeKiller is a utility to simulate node failures.
func NewNodeKiller ¶
func NewNodeKiller(config framework.NodeKillerConfig, client clientset.Interface, provider string) *NodeKiller
NewNodeKiller creates new NodeKiller.
func (*NodeKiller) Run ¶
func (k *NodeKiller) Run(ctx context.Context)
Run starts NodeKiller until stopCh is closed.
type PodNode ¶
type PodNode struct { // Pod represents pod name Pod string // Node represents node name Node string }
PodNode is a pod-node pair indicating which node a given pod is running on
func PodNodePairs ¶
PodNodePairs return podNode pairs for all pods in a namespace
Source Files ¶
helper.go node_killer.go resource.go ssh.go wait.go
Directories ¶
Path | Synopsis |
---|---|
test/e2e/framework/node/init | Package init registers node.AllNodesReady. |
test/e2e/framework/node/runtimeclass |
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 28 packages
- Last checked
- 3 hours ago –
Tools for package owners.