k8s

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ToBeRemovedByAutoscalerKey specifies the key the autoscaler uses to taint nodes as MARKED
	ToBeRemovedByAutoscalerKey = "atlassian.com/escalator"
)

Variables

TaintEffectTypes a map of TaintEffect to boolean true used for validating supported taint types

Functions

func AddToBeRemovedTaint

func AddToBeRemovedTaint(node *apiv1.Node, client kubernetes.Interface, taintEffect apiv1.TaintEffect) (*apiv1.Node, error)

AddToBeRemovedTaint takes a k8s node and adds the ToBeRemovedByAutoscaler taint to the node returns the most recent update of the node that is successful

func CalculateNodesCapacityTotal

func CalculateNodesCapacityTotal(nodes []*v1.Node) (resource.Quantity, resource.Quantity, error)

CalculateNodesCapacityTotal calculates the total Allocatable node capacity for all nodes

func CalculatePodsRequestsTotal

func CalculatePodsRequestsTotal(pods []*v1.Pod) (resource.Quantity, resource.Quantity, error)

CalculatePodsRequestsTotal returns the total capacity of all pods

func CreateNodeNameToInfoMap

func CreateNodeNameToInfoMap(pods []*v1.Pod, nodes []*v1.Node) map[string]*NodeInfo

CreateNodeNameToInfoMap creates a map of NodeInfo which maps node names to nodes and pods to nodes From K8s cluster-autoscaler. Based off the old scheduler cache.NodeInfo

func DeleteNode

func DeleteNode(node *v1.Node, client kubernetes.Interface) error

DeleteNode deletes a single node from Kubernetes

func DeleteNodes

func DeleteNodes(nodes []*v1.Node, client kubernetes.Interface) error

DeleteNodes deletes multiple nodes from Kubernetes

func DeleteToBeRemovedTaint

func DeleteToBeRemovedTaint(node *apiv1.Node, client kubernetes.Interface) (*apiv1.Node, error)

DeleteToBeRemovedTaint removes the ToBeRemovedByAutoscaler taint fromt the node if it exists returns the latest successful update of the node

func GetLeaderElector added in v1.1.0

func GetLeaderElector(ctx context.Context, config LeaderElectConfig, coreClient v1.CoreV1Interface, coordClient coordinationv1.CoordinationV1Interface, recorder record.EventRecorder, resourceLockID string) (*leaderelection.LeaderElector, context.Context, <-chan struct{}, error)

GetLeaderElector returns a leader elector

func GetResourceLock added in v1.1.0

func GetResourceLock(ns string, name string, coreClient v1.CoreV1Interface, coordClient coordinationv1.CoordinationV1Interface, recorder record.EventRecorder, resourceLockID string) (resourcelock.Interface, error)

GetResourceLock returns a resource lock for leader election

func GetToBeRemovedTaint

func GetToBeRemovedTaint(node *apiv1.Node) (apiv1.Taint, bool)

GetToBeRemovedTaint returns whether the node is tainted with the ToBeRemovedByAutoscalerKey taint and the taint associated

func GetToBeRemovedTime

func GetToBeRemovedTime(node *apiv1.Node) (*time.Time, error)

GetToBeRemovedTime returns the time the node was tainted result will be nil if does not exist

func NewCacheNodeWatcher

func NewCacheNodeWatcher(client kubernetes.Interface, stop <-chan struct{}) (v1lister.NodeLister, cache.InformerSynced)

NewCacheNodeWatcher creates a new IndexerInformer for watching nodes from cache

func NewCachePodWatcher

func NewCachePodWatcher(client kubernetes.Interface, stop <-chan struct{}) (v1lister.PodLister, cache.InformerSynced)

NewCachePodWatcher creates a new IndexerInformer for watching pods from cache

func NewInClusterClient

func NewInClusterClient() (*kubernetes.Clientset, error)

NewInClusterClient returns a new kubernetes clientset from inside the cluster

func NewOutOfClusterClient

func NewOutOfClusterClient(kubeconfig string) (*kubernetes.Clientset, error)

NewOutOfClusterClient returns a new kubernetes clientset using a kubeconfig file For running outside the cluster

func NodeEmpty

func NodeEmpty(node *v1.Node, nodeInfoMap map[string]*NodeInfo) bool

NodeEmpty returns if the node is empty of pods, except for daemonsets

func NodePodsRemaining

func NodePodsRemaining(node *v1.Node, nodeInfoMap map[string]*NodeInfo) (int, bool)

NodePodsRemaining returns the number of pods on the node, except for daemonset pods

func PodIsDaemonSet

func PodIsDaemonSet(pod *v1.Pod) bool

PodIsDaemonSet returns if the pod is a daemonset or not

func PodIsStatic

func PodIsStatic(pod *v1.Pod) bool

PodIsStatic returns if the pod is static or not

func WaitForSync

func WaitForSync(tries int, stopChan <-chan struct{}, informers ...cache.InformerSynced) bool

WaitForSync wait for the cache sync for all the registered listers it will try <tries> times and return the result

Types

type FilteredNodesLister

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

FilteredNodesLister lists nodes filtered by labels

func (*FilteredNodesLister) List

func (lister *FilteredNodesLister) List() ([]*v1.Node, error)

List lists all nodes from the cache filtered by labels

type FilteredPodsLister

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

FilteredPodsLister lists pods from a podLister and filters out by namespace

func (*FilteredPodsLister) List

func (lister *FilteredPodsLister) List() ([]*v1.Pod, error)

List lists all pods from the cache filtering by namespace

type LeaderElectConfig added in v1.1.0

type LeaderElectConfig struct {
	LeaseDuration time.Duration
	RenewDeadline time.Duration
	RetryPeriod   time.Duration
	Namespace     string
	Name          string
}

LeaderElectConfig stores the configuration for a leader election lock

type NodeFilterFunc

type NodeFilterFunc func(*v1.Node) bool

NodeFilterFunc provides a definition for a predicate based on matching a node return true for keep node

type NodeInfo added in v1.10.0

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

NodeInfo provides an abstraction on top of node to pods mappings replaces scheduler cache.NodeInfo that was removed from public in an older version of kubernetes Maintains the same interface NodeInfo this thread safe

func NewNodeInfo added in v1.10.0

func NewNodeInfo() *NodeInfo

NewNodeInfo creates a new empty NodeInfo struct

func (*NodeInfo) AddPod added in v1.10.0

func (i *NodeInfo) AddPod(pod *v1.Pod)

AddPod adds a pod to the list of pods for this node

func (*NodeInfo) Node added in v1.10.0

func (i *NodeInfo) Node() *v1.Node

Node returns the current node for these pods

func (*NodeInfo) Pods added in v1.10.0

func (i *NodeInfo) Pods() []*v1.Pod

Pods returns the list of pods for this node

func (*NodeInfo) SetNode added in v1.10.0

func (i *NodeInfo) SetNode(node *v1.Node)

SetNode sets the current node that the pods belong to

type NodeLister

type NodeLister interface {
	List() ([]*v1.Node, error)
}

NodeLister provides an interface for anything that can list a node

func NewFilteredNodesLister

func NewFilteredNodesLister(nodeLister v1lister.NodeLister, filterFunc NodeFilterFunc) NodeLister

NewFilteredNodesLister creates a new lister and informerSynced for all nodes filter by nodegroup (nodeLabels)

type PodFilterFunc

type PodFilterFunc func(*v1.Pod) bool

PodFilterFunc provides a definition for a predicate based on matching a pod return true for keep node

type PodLister

type PodLister interface {
	List() ([]*v1.Pod, error)
}

PodLister provides an interface for anything that can list a pod

func NewFilteredPodsLister

func NewFilteredPodsLister(podLister v1lister.PodLister, filterFunc PodFilterFunc) PodLister

NewFilteredPodsLister creates a new lister and informerSynced for a FilteredPodsLister

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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