k8s

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFinalizerToNode added in v1.9.1

func AddFinalizerToNode(node *v1.Node, finalizerName string, client kubernetes.Interface) error

AddFinalizerToNode updates a node to add a finalizer to it

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

func DrainPods(pods []*v1.Pod, client kubernetes.Interface, unhealthyAfter time.Duration) []error

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 EvictPod

func EvictPod(pod *v1.Pod, apiVersion string, client kubernetes.Interface) error

EvictPod evicts a single pod from a Kubernetes node

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 GetConfig

func GetConfig(kubeconfig string) (*rest.Config, error)

GetConfig returns a new kubernetes config

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

func NamespaceFlag(cmd *cobra.Command) string

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

func PodIsDaemonSet(pod *v1.Pod) bool

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 PodIsStatic

func PodIsStatic(pod *v1.Pod) bool

PodIsStatic returns true if the pod is static

func RemoveFinalizerFromNode added in v1.9.1

func RemoveFinalizerFromNode(node *v1.Node, finalizerName string, client kubernetes.Interface) error

RemoveFinalizerFromNode updates a node to remove a finalizer from it

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

type DaemonSetLister interface {
	List(labels.Selector) ([]*v1.DaemonSet, error)
}

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

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

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

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

PodLister defines a type that can list pods with a label selector

func NewCachedPodList

func NewCachedPodList(caches ...cache.Indexer) PodLister

NewCachedPodList creates a new cachedPodList

type WatchResourceFunc

WatchResourceFunc defines a function that can setup a cache and controller

Jump to

Keyboard shortcuts

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