Documentation ¶
Index ¶
- func MakeNodesAndPods(pod *v1.Pod, existingPodsNum, allNodesNum, filteredNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node, filteredNodes []*v1.Node)
- type FakeControllerLister
- type FakeNodeLister
- type FakePDBLister
- type FakePersistentVolumeClaimLister
- type FakePodLister
- type FakeReplicaSetLister
- type FakeServiceLister
- type FakeStatefulSetLister
- type LabelSelectorWrapper
- func (s *LabelSelectorWrapper) Exists(k string) *LabelSelectorWrapper
- func (s *LabelSelectorWrapper) In(key string, vals []string) *LabelSelectorWrapper
- func (s *LabelSelectorWrapper) Label(k, v string) *LabelSelectorWrapper
- func (s *LabelSelectorWrapper) NotExist(k string) *LabelSelectorWrapper
- func (s *LabelSelectorWrapper) NotIn(key string, vals []string) *LabelSelectorWrapper
- func (s *LabelSelectorWrapper) Obj() *metav1.LabelSelector
- type NodeSelectorWrapper
- type NodeWrapper
- type PodWrapper
- func (p *PodWrapper) Container(s string) *PodWrapper
- func (p *PodWrapper) Label(k, v string) *PodWrapper
- func (p *PodWrapper) Name(s string) *PodWrapper
- func (p *PodWrapper) Namespace(s string) *PodWrapper
- func (p *PodWrapper) Node(s string) *PodWrapper
- func (p *PodWrapper) NodeAffinityIn(key string, vals []string) *PodWrapper
- func (p *PodWrapper) NodeAffinityNotIn(key string, vals []string) *PodWrapper
- func (p *PodWrapper) NodeSelector(m map[string]string) *PodWrapper
- func (p *PodWrapper) Obj() *v1.Pod
- func (p *PodWrapper) Priority(val int32) *PodWrapper
- func (p *PodWrapper) SpreadConstraint(maxSkew int, tpKey string, mode v1.UnsatisfiableConstraintAction, ...) *PodWrapper
- func (p *PodWrapper) ZeroTerminationGracePeriod() *PodWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeNodesAndPods ¶
func MakeNodesAndPods(pod *v1.Pod, existingPodsNum, allNodesNum, filteredNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node, filteredNodes []*v1.Node)
MakeNodesAndPods serves as a testing helper for EvenPodsSpread feature. It builds a fake cluster containing running Pods and Nodes. The size of Pods and Nodes are determined by input arguments. The specs of Pods and Nodes are generated with the following rules:
- If `pod` has "node" as a topologyKey, each generated node is applied with a unique label: "node: node<i>".
- If `pod` has "zone" as a topologyKey, each generated node is applied with a rotating label: "zone: zone[0-9]".
- Depending on "lableSelector.MatchExpressions[0].Key" the `pod` has in each topologySpreadConstraint, each generated pod will be applied with label "key1", "key1,key2", ..., "key1,key2,...,keyN" in a rotating manner.
Types ¶
type FakeControllerLister ¶
type FakeControllerLister []*v1.ReplicationController
FakeControllerLister implements ControllerLister on []v1.ReplicationController for test purposes.
func (FakeControllerLister) GetPodControllers ¶
func (f FakeControllerLister) GetPodControllers(pod *v1.Pod) (controllers []*v1.ReplicationController, err error)
GetPodControllers gets the ReplicationControllers that have the selector that match the labels on the given pod
func (FakeControllerLister) List ¶
func (f FakeControllerLister) List(labels.Selector) ([]*v1.ReplicationController, error)
List returns []v1.ReplicationController, the list of all ReplicationControllers.
type FakeNodeLister ¶
FakeNodeLister implements NodeLister on a []string for test purposes.
func (FakeNodeLister) ListNodes ¶
func (f FakeNodeLister) ListNodes() []*v1.Node
ListNodes returns nodes as a []*v1.Node.
type FakePDBLister ¶
type FakePDBLister []*policy.PodDisruptionBudget
FakePDBLister implements PDBLister on a slice of PodDisruptionBudgets for test purposes.
func (FakePDBLister) List ¶
func (f FakePDBLister) List(labels.Selector) ([]*policy.PodDisruptionBudget, error)
List returns a list of PodDisruptionBudgets.
type FakePersistentVolumeClaimLister ¶
type FakePersistentVolumeClaimLister []*v1.PersistentVolumeClaim
FakePersistentVolumeClaimLister implements PersistentVolumeClaimLister on []*v1.PersistentVolumeClaim for test purposes.
func (FakePersistentVolumeClaimLister) List ¶
func (f FakePersistentVolumeClaimLister) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error)
List returns not implemented error.
func (FakePersistentVolumeClaimLister) PersistentVolumeClaims ¶
func (f FakePersistentVolumeClaimLister) PersistentVolumeClaims(namespace string) corelisters.PersistentVolumeClaimNamespaceLister
PersistentVolumeClaims returns a FakePersistentVolumeClaimLister object.
type FakePodLister ¶
FakePodLister implements PodLister on an []v1.Pods for test purposes.
func (FakePodLister) FilteredList ¶
func (f FakePodLister) FilteredList(podFilter algorithm.PodFilter, s labels.Selector) (selected []*v1.Pod, err error)
FilteredList returns pods matching a pod filter and a label selector.
type FakeReplicaSetLister ¶
type FakeReplicaSetLister []*apps.ReplicaSet
FakeReplicaSetLister implements ControllerLister on []extensions.ReplicaSet for test purposes.
func (FakeReplicaSetLister) GetPodReplicaSets ¶
func (f FakeReplicaSetLister) GetPodReplicaSets(pod *v1.Pod) (rss []*apps.ReplicaSet, err error)
GetPodReplicaSets gets the ReplicaSets that have the selector that match the labels on the given pod
type FakeServiceLister ¶
FakeServiceLister implements ServiceLister on []v1.Service for test purposes.
func (FakeServiceLister) GetPodServices ¶
GetPodServices gets the services that have the selector that match the labels on the given pod.
type FakeStatefulSetLister ¶
type FakeStatefulSetLister []*apps.StatefulSet
FakeStatefulSetLister implements ControllerLister on []apps.StatefulSet for testing purposes.
func (FakeStatefulSetLister) GetPodStatefulSets ¶
func (f FakeStatefulSetLister) GetPodStatefulSets(pod *v1.Pod) (sss []*apps.StatefulSet, err error)
GetPodStatefulSets gets the StatefulSets that have the selector that match the labels on the given pod.
type LabelSelectorWrapper ¶
type LabelSelectorWrapper struct{ metav1.LabelSelector }
LabelSelectorWrapper wraps a LabelSelector inside.
func MakeLabelSelector ¶
func MakeLabelSelector() *LabelSelectorWrapper
MakeLabelSelector creates a LabelSelector wrapper.
func (*LabelSelectorWrapper) Exists ¶
func (s *LabelSelectorWrapper) Exists(k string) *LabelSelectorWrapper
Exists injects a matchExpression (with an operator Exists) to the inner labelSelector.
func (*LabelSelectorWrapper) In ¶
func (s *LabelSelectorWrapper) In(key string, vals []string) *LabelSelectorWrapper
In injects a matchExpression (with an operator In) to the inner labelSelector.
func (*LabelSelectorWrapper) Label ¶
func (s *LabelSelectorWrapper) Label(k, v string) *LabelSelectorWrapper
Label applies a {k,v} pair to the inner LabelSelector.
func (*LabelSelectorWrapper) NotExist ¶
func (s *LabelSelectorWrapper) NotExist(k string) *LabelSelectorWrapper
NotExist injects a matchExpression (with an operator NotExist) to the inner labelSelector.
func (*LabelSelectorWrapper) NotIn ¶
func (s *LabelSelectorWrapper) NotIn(key string, vals []string) *LabelSelectorWrapper
NotIn injects a matchExpression (with an operator NotIn) to the inner labelSelector.
func (*LabelSelectorWrapper) Obj ¶
func (s *LabelSelectorWrapper) Obj() *metav1.LabelSelector
Obj returns the inner LabelSelector.
type NodeSelectorWrapper ¶
type NodeSelectorWrapper struct{ v1.NodeSelector }
NodeSelectorWrapper wraps a NodeSelector inside.
func MakeNodeSelector ¶
func MakeNodeSelector() *NodeSelectorWrapper
MakeNodeSelector creates a NodeSelector wrapper.
func (*NodeSelectorWrapper) In ¶
func (s *NodeSelectorWrapper) In(key string, vals []string) *NodeSelectorWrapper
In injects a matchExpression (with an operator IN) as a selectorTerm to the inner nodeSelector. NOTE: appended selecterTerms are ORed.
func (*NodeSelectorWrapper) NotIn ¶
func (s *NodeSelectorWrapper) NotIn(key string, vals []string) *NodeSelectorWrapper
NotIn injects a matchExpression (with an operator NotIn) as a selectorTerm to the inner nodeSelector.
func (*NodeSelectorWrapper) Obj ¶
func (s *NodeSelectorWrapper) Obj() *v1.NodeSelector
Obj returns the inner NodeSelector.
type NodeWrapper ¶
NodeWrapper wraps a Node inside.
func (*NodeWrapper) Label ¶
func (n *NodeWrapper) Label(k, v string) *NodeWrapper
Label applies a {k,v} label pair to the inner node.
func (*NodeWrapper) Name ¶
func (n *NodeWrapper) Name(s string) *NodeWrapper
Name sets `s` as the name of the inner pod.
type PodWrapper ¶
PodWrapper wraps a Pod inside.
func (*PodWrapper) Container ¶
func (p *PodWrapper) Container(s string) *PodWrapper
Container appends a container into PodSpec of the inner pod.
func (*PodWrapper) Label ¶
func (p *PodWrapper) Label(k, v string) *PodWrapper
Label sets a {k,v} pair to the inner pod.
func (*PodWrapper) Name ¶
func (p *PodWrapper) Name(s string) *PodWrapper
Name sets `s` as the name of the inner pod.
func (*PodWrapper) Namespace ¶
func (p *PodWrapper) Namespace(s string) *PodWrapper
Namespace sets `s` as the namespace of the inner pod.
func (*PodWrapper) Node ¶
func (p *PodWrapper) Node(s string) *PodWrapper
Node sets `s` as the nodeName of the inner pod.
func (*PodWrapper) NodeAffinityIn ¶
func (p *PodWrapper) NodeAffinityIn(key string, vals []string) *PodWrapper
NodeAffinityIn creates a HARD node affinity (with the operator In) and injects into the innner pod.
func (*PodWrapper) NodeAffinityNotIn ¶
func (p *PodWrapper) NodeAffinityNotIn(key string, vals []string) *PodWrapper
NodeAffinityNotIn creates a HARD node affinity (with the operator NotIn) and injects into the innner pod.
func (*PodWrapper) NodeSelector ¶
func (p *PodWrapper) NodeSelector(m map[string]string) *PodWrapper
NodeSelector sets `m` as the nodeSelector of the inner pod.
func (*PodWrapper) Priority ¶
func (p *PodWrapper) Priority(val int32) *PodWrapper
Priority sets a priority value into PodSpec of the inner pod.
func (*PodWrapper) SpreadConstraint ¶
func (p *PodWrapper) SpreadConstraint(maxSkew int, tpKey string, mode v1.UnsatisfiableConstraintAction, selector *metav1.LabelSelector) *PodWrapper
SpreadConstraint constructs a TopologySpreadConstraint object and injects into the inner pod.
func (*PodWrapper) ZeroTerminationGracePeriod ¶
func (p *PodWrapper) ZeroTerminationGracePeriod() *PodWrapper
ZeroTerminationGracePeriod sets the TerminationGracePeriodSeconds of the inner pod to zero.