Documentation ¶
Index ¶
- Constants
- Variables
- func BuildConfigFromFlags(apiserver, kubecfg string) (*rest.Config, error)
- func IsTimeout(err error) bool
- func LocalStoragePodFilter(p core.Pod) (bool, error)
- func MirrorPodFilter(p core.Pod) (bool, error)
- func NewEventRecorder(c kubernetes.Interface) record.EventRecorder
- func NewNodeConditionFilter(ct []string) func(o interface{}) bool
- func NewNodeLabelFilter(labels map[string]string) func(o interface{}) bool
- func NodeSchedulableFilter(o interface{}) bool
- func UnreplicatedPodFilter(p core.Pod) (bool, error)
- type APICordonDrainer
- type APICordonDrainerOption
- type CordonDrainer
- type Cordoner
- type Drainer
- type DrainingResourceEventHandler
- type DrainingResourceEventHandlerOption
- type NodeProcessed
- type NodeStore
- type NodeWatch
- type NoopCordonDrainer
- type PodFilterFunc
Constants ¶
const ( DefaultMaxGracePeriod time.Duration = 8 * time.Minute DefaultEvictionOverhead time.Duration = 30 * time.Second )
Default pod eviction settings.
const Component = "draino"
Component is the name of this application.
const ( // DefaultDrainBuffer is the default minimum time between node drains. DefaultDrainBuffer = 10 * time.Minute )
Variables ¶
var ( MeasureNodesCordoned = stats.Int64("draino/nodes_cordoned", "Number of nodes cordoned.", stats.UnitDimensionless) MeasureNodesDrained = stats.Int64("draino/nodes_drained", "Number of nodes drained.", stats.UnitDimensionless) TagNodeName, _ = tag.NewKey("node_name") TagResult, _ = tag.NewKey("result") )
Opencensus measurements.
Functions ¶
func BuildConfigFromFlags ¶
BuildConfigFromFlags is clientcmd.BuildConfigFromFlags with no annoying dependencies on glog. https://godoc.org/k8s.io/client-go/tools/clientcmd#BuildConfigFromFlags
func LocalStoragePodFilter ¶
LocalStoragePodFilter returns true if the supplied pod does not have local storage, i.e. does not use any 'empty dir' volumes.
func MirrorPodFilter ¶
MirrorPodFilter returns true if the supplied pod is not a mirror pod, i.e. a pod created by a manifest on the node rather than the API server.
func NewEventRecorder ¶
func NewEventRecorder(c kubernetes.Interface) record.EventRecorder
NewEventRecorder returns a new record.EventRecorder for the given client.
func NewNodeConditionFilter ¶
NewNodeConditionFilter returns a filter that returns true if the supplied object is a node with any of the supplied node conditions.
func NewNodeLabelFilter ¶
NewNodeLabelFilter returns a filter that returns true if the supplied object is a node with all of the supplied labels.
func NodeSchedulableFilter ¶
func NodeSchedulableFilter(o interface{}) bool
NodeSchedulableFilter returns true if the supplied object is a schedulable node.
Types ¶
type APICordonDrainer ¶
type APICordonDrainer struct {
// contains filtered or unexported fields
}
APICordonDrainer drains Kubernetes nodes via the Kubernetes API.
func NewAPICordonDrainer ¶
func NewAPICordonDrainer(c kubernetes.Interface, ao ...APICordonDrainerOption) *APICordonDrainer
NewAPICordonDrainer returns a CordonDrainer that cordons and drains nodes via the Kubernetes API.
type APICordonDrainerOption ¶
type APICordonDrainerOption func(d *APICordonDrainer)
APICordonDrainerOption configures an APICordonDrainer.
func EvictionHeadroom ¶
func EvictionHeadroom(h time.Duration) APICordonDrainerOption
EvictionHeadroom configures an amount of time to wait in addition to the MaxGracePeriod for the API server to report a pod deleted.
func MaxGracePeriod ¶
func MaxGracePeriod(m time.Duration) APICordonDrainerOption
MaxGracePeriod configures the maximum time to wait for a pod eviction. Pod containers will be allowed this much time to shutdown once they receive a SIGTERM before they are sent a SIGKILL.
func WithPodFilter ¶
func WithPodFilter(f PodFilterFunc) APICordonDrainerOption
WithPodFilter configures a filter that may be used to exclude certain pods from eviction when draining.
type CordonDrainer ¶
A CordonDrainer both cordons and drains nodes!
type Cordoner ¶
type Cordoner interface { // Cordon the supplied node. Marks it unschedulable for new pods. Cordon(n *core.Node) error }
A Cordoner cordons nodes.
type Drainer ¶
type Drainer interface { // Drain the supplied node. Evicts the node of all but mirror and DaemonSet pods. Drain(n *core.Node) error }
A Drainer drains nodes.
type DrainingResourceEventHandler ¶
type DrainingResourceEventHandler struct {
// contains filtered or unexported fields
}
A DrainingResourceEventHandler cordons and drains any added or updated nodes.
func NewDrainingResourceEventHandler ¶
func NewDrainingResourceEventHandler(d CordonDrainer, e record.EventRecorder, ho ...DrainingResourceEventHandlerOption) *DrainingResourceEventHandler
NewDrainingResourceEventHandler returns a new DrainingResourceEventHandler.
func (*DrainingResourceEventHandler) OnAdd ¶
func (h *DrainingResourceEventHandler) OnAdd(obj interface{})
OnAdd cordons and drains the added node.
func (*DrainingResourceEventHandler) OnDelete ¶
func (h *DrainingResourceEventHandler) OnDelete(_ interface{})
OnDelete does nothing. There's no point cordoning or draining deleted nodes.
func (*DrainingResourceEventHandler) OnUpdate ¶
func (h *DrainingResourceEventHandler) OnUpdate(_, newObj interface{})
OnUpdate cordons and drains the updated node.
type DrainingResourceEventHandlerOption ¶
type DrainingResourceEventHandlerOption func(d *DrainingResourceEventHandler)
DrainingResourceEventHandlerOption configures an DrainingResourceEventHandler.
func WithDrainBuffer ¶
func WithDrainBuffer(d time.Duration) DrainingResourceEventHandlerOption
WithDrainBuffer configures the minimum time between scheduled drains.
func WithLogger ¶
func WithLogger(l *zap.Logger) DrainingResourceEventHandlerOption
WithLogger configures a DrainingResourceEventHandler to use the supplied logger.
type NodeProcessed ¶
NodeProcessed tracks whether nodes have been processed before using a map.
func NewNodeProcessed ¶
func NewNodeProcessed() NodeProcessed
NewNodeProcessed returns a new node processed filter.
func (NodeProcessed) Filter ¶
func (processed NodeProcessed) Filter(o interface{}) bool
Filter returns true if the supplied object is a node that this filter has not seen before. It is not threadsafe and should always be the last filter applied.
type NodeStore ¶
type NodeStore interface { // Get an node by name. Returns an error if the node does not exist. Get(name string) (*core.Node, error) }
An NodeStore is a cache of node resources.
type NodeWatch ¶
type NodeWatch struct {
}An NodeWatch is a cache of node resources that notifies registered handlers when its contents change.
func NewNodeWatch ¶
func NewNodeWatch(c kubernetes.Interface, rs ...cache.ResourceEventHandler) *NodeWatch
NewNodeWatch creates a watch on node resources. Nodes are cached and the provided ResourceEventHandlers are called when the cache changes.
type NoopCordonDrainer ¶
type NoopCordonDrainer struct{}
A NoopCordonDrainer does nothing.
type PodFilterFunc ¶
A PodFilterFunc returns true if the supplied pod passes the filter.
func NewDaemonSetPodFilter ¶
func NewDaemonSetPodFilter(client kubernetes.Interface) PodFilterFunc
NewDaemonSetPodFilter returns a FilterFunc that returns true if the supplied pod is not managed by an extant DaemonSet.
func NewPodFilters ¶
func NewPodFilters(filters ...PodFilterFunc) PodFilterFunc
NewPodFilters returns a FilterFunc that returns true if all of the supplied FilterFuncs return true.