k8s

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: Apache-2.0 Imports: 21 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"
	// MaximumTaints we can taint at one time
	MaximumTaints = 10
)

Variables

This section is empty.

Functions

func AddToBeRemovedTaint

func AddToBeRemovedTaint(node *apiv1.Node, client kubernetes.Interface) (*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 BeginTaintFailSafe

func BeginTaintFailSafe(target int) error

BeginTaintFailSafe locks the tainting function to taint a max of maximum nodes

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]*cache.NodeInfo

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

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 EndTaintFailSafe

func EndTaintFailSafe(actualTainted int) error

EndTaintFailSafe unlocks the tainting function and ensures proper use by programmer

func GetLeaderElector added in v1.1.0

func GetLeaderElector(ctx context.Context, config LeaderElectConfig, client v1.CoreV1Interface, 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, client v1.CoreV1Interface, 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 IncrementTaintCount

func IncrementTaintCount()

IncrementTaintCount is used to increase the taint count. Exposed to use in dry mode testing

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

NewInClusterClient returns a new kubernetes clientset from inside the cluster

func NewOutOfClusterClient

func NewOutOfClusterClient(kubeconfig string) *kubernetes.Clientset

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]*cache.NodeInfo) bool

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

func NodePodsRemaining

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

NodeEmpty 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 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

Jump to

Keyboard shortcuts

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