Documentation ¶
Index ¶
- func AddLabelToNode(nodeName string, labelName string, labelValue string, ...) error
- func CordonNode(name string, client kubernetes.Interface) error
- func DrainPods(pods []*v1.Pod, client kubernetes.Interface, unhealthyAfter time.Duration) []error
- func EvictOrForciblyDeletePod(pod *v1.Pod, apiVersion string, client kubernetes.Interface, ...) error
- func EvictPod(pod *v1.Pod, apiVersion string, client kubernetes.Interface) error
- func EvictPods(pods []*v1.Pod, apiVersion string, client kubernetes.Interface, ...) (evictionErrors []error)
- func ForciblyDeletePod(podName, podNamespace, nodeName string, client kubernetes.Interface) error
- func GetConfig(kubeconfig string) (*rest.Config, error)
- func IsCordoned(name string, client kubernetes.Interface) (bool, error)
- func NamespaceFlag(cmd *cobra.Command) string
- func NewCLIClientOrDie(kubeConfigFlags *genericclioptions.ConfigFlags) client.Client
- func NodeExists(name string, client kubernetes.Interface) (bool, error)
- func PatchNode(name string, patches []Patch, client kubernetes.Interface) error
- func PatchPod(name, namespace string, patches []Patch, client kubernetes.Interface) error
- func PodIsDaemonSet(pod *v1.Pod) bool
- func PodIsLongtermUnhealthy(podStatus v1.PodStatus, unhealthyAfter time.Duration, now time.Time) bool
- func PodIsStatic(pod *v1.Pod) bool
- func StartWatching(client kubernetes.Interface, namespace string, watchFn WatchResourceFunc, ...) cache.Indexer
- func SupportEviction(client kubernetes.Interface) (string, error)
- func UncordonNode(name string, client kubernetes.Interface) error
- func Watch(c cache.Getter, resource string, namespace string, ...) (cache.Indexer, cache.Controller)
- func WatchControllerRevisions(client kubernetes.Interface, namespace string, ...) (cache.Indexer, cache.Controller)
- func WatchDaemonSets(client kubernetes.Interface, namespace string, ...) (cache.Indexer, cache.Controller)
- func WatchNodes(client kubernetes.Interface, _ string, ...) (cache.Indexer, cache.Controller)
- func WatchPods(client kubernetes.Interface, namespace string, ...) (cache.Indexer, cache.Controller)
- type ControllerRevisionLister
- type DaemonSetLister
- type NodeLister
- type Patch
- type PodLister
- type WatchResourceFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLabelToNode ¶
func AddLabelToNode(nodeName string, labelName string, labelValue string, client kubernetes.Interface) error
AddLabelToNode performs a patch operation on a node to add a label to the node
func CordonNode ¶
func CordonNode(name string, client kubernetes.Interface) error
CordonNode performs a patch operation on a node to mark it as unschedulable
func DrainPods ¶
DrainPods attempts to delete or evict pods so that the node can be terminated. Will prioritise using Evict if the API server supports it. Pods that have been unhealthy for longer than the given duration will be forcibly removed to prevent stalling.
func EvictOrForciblyDeletePod ¶ added in v1.6.0
func EvictOrForciblyDeletePod(pod *v1.Pod, apiVersion string, client kubernetes.Interface, unhealthyAfter time.Duration, now time.Time) error
EvictOrForciblyDeletePod tries to evict a pod, and if that fails will then check if it can forcibly remove the pod instead.
func EvictPods ¶
func EvictPods(pods []*v1.Pod, apiVersion string, client kubernetes.Interface, unhealthyAfter time.Duration, now time.Time) (evictionErrors []error)
EvictPods evicts multiple pods from a Kubernetes node. Forcibly removes a pod if it is old and unhealthy and stopping the eviction as a result.
func ForciblyDeletePod ¶ added in v1.6.0
func ForciblyDeletePod(podName, podNamespace, nodeName string, client kubernetes.Interface) error
ForciblyDeletePod immediately terminates a given pod off the node, without waiting to check if it has been removed. This should only be called on workloads that can tolerate being removed like this, and as a last resort.
func IsCordoned ¶ added in v1.8.1
func IsCordoned(name string, client kubernetes.Interface) (bool, error)
IsCordoned checks if a node is cordoned
func NamespaceFlag ¶
NamespaceFlag gets the --namespace flag from the command
func NewCLIClientOrDie ¶
func NewCLIClientOrDie(kubeConfigFlags *genericclioptions.ConfigFlags) client.Client
NewCLIClientOrDie creates a new controller-runtime client for use with CRDs by wrapping the dynamic.Client
func NodeExists ¶ added in v1.8.3
func NodeExists(name string, client kubernetes.Interface) (bool, error)
NodeExists checks if a node exists
func PatchNode ¶
func PatchNode(name string, patches []Patch, client kubernetes.Interface) error
PatchNode patches a node
func PatchPod ¶
func PatchPod(name, namespace string, patches []Patch, client kubernetes.Interface) error
PatchPod patches a pod
func PodIsDaemonSet ¶
PodIsDaemonSet returns true if the pod is a daemonset
func PodIsLongtermUnhealthy ¶ added in v1.6.0
func PodIsLongtermUnhealthy(podStatus v1.PodStatus, unhealthyAfter time.Duration, now time.Time) bool
PodIsLongtermUnhealthy returns true if the pod has had container startup or restarting issues for a period of time
func StartWatching ¶
func StartWatching(client kubernetes.Interface, namespace string, watchFn WatchResourceFunc, stopCh <-chan struct{}) cache.Indexer
StartWatching starts watching with the watchFn and returns the cache to query from
func SupportEviction ¶
func SupportEviction(client kubernetes.Interface) (string, error)
SupportEviction uses Discovery API to find out if the API server supports the eviction subresource If there is support, it will return its groupVersion; Otherwise, it will return ""
func UncordonNode ¶
func UncordonNode(name string, client kubernetes.Interface) error
UncordonNode performs a patch operation on a node to mark it as schedulable
func Watch ¶
func Watch(c cache.Getter, resource string, namespace string, resourceEventHandler cache.ResourceEventHandler, objType runtime.Object, fieldSelector fields.Selector) (cache.Indexer, cache.Controller)
Watch returns a controller that will watch the specified resource
func WatchControllerRevisions ¶
func WatchControllerRevisions(client kubernetes.Interface, namespace string, resourceEventHandler cache.ResourceEventHandler) (cache.Indexer, cache.Controller)
WatchControllerRevisions watches all daemonsets
func WatchDaemonSets ¶
func WatchDaemonSets(client kubernetes.Interface, namespace string, resourceEventHandler cache.ResourceEventHandler) (cache.Indexer, cache.Controller)
WatchDaemonSets watches all daemonsets
func WatchNodes ¶
func WatchNodes(client kubernetes.Interface, _ string, resourceEventHandler cache.ResourceEventHandler) (cache.Indexer, cache.Controller)
WatchNodes watches all nodes
func WatchPods ¶
func WatchPods(client kubernetes.Interface, namespace string, resourceEventHandler cache.ResourceEventHandler) (cache.Indexer, cache.Controller)
WatchPods watches all pods
Types ¶
type ControllerRevisionLister ¶
type ControllerRevisionLister interface {
List(labels.Selector) ([]*v1.ControllerRevision, error)
}
ControllerRevisionLister defines a type that can list ControllerRevision with a selector
func NewCachedControllerRevisionList ¶
func NewCachedControllerRevisionList(caches ...cache.Indexer) ControllerRevisionLister
NewCachedControllerRevisionList creates a new cachedControllerRevisionList
type DaemonSetLister ¶
DaemonSetLister defines a type that can list DaemonSets with a selector
func NewCachedDaemonSetList ¶
func NewCachedDaemonSetList(caches ...cache.Indexer) DaemonSetLister
NewCachedDaemonSetList creates a new cachedDaemonSetList
type NodeLister ¶
NodeLister defines an object that can list nodes with a label selector
func NewCachedNodeList ¶
func NewCachedNodeList(cache cache.Indexer) NodeLister
NewCachedNodeList creates a new cachedNodeList
type Patch ¶
type Patch struct { Op string `json:"op"` Path string `json:"path"` Value interface{} `json:"value"` }
Patch describes a JSON Patch used to perform Patch operations on Kubernetes API objects via the API server.
type PodLister ¶
PodLister defines a type that can list pods with a label selector
func NewCachedPodList ¶
NewCachedPodList creates a new cachedPodList
type WatchResourceFunc ¶
type WatchResourceFunc func(kubernetes.Interface, string, cache.ResourceEventHandler) (cache.Indexer, cache.Controller)
WatchResourceFunc defines a function that can setup a cache and controller