k8s

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

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

func DrainPods(pods []*v1.Pod, client kubernetes.Interface) []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.

func EvictPod

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

EvictPod evicts a single pod from Kubernetes

func EvictPods

func EvictPods(pods []*v1.Pod, apiVersion string, client kubernetes.Interface) (evictionErrors []error)

EvictPods evicts multiple pods from Kubernetes

func GetConfig

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

GetConfig returns a new kubernetes config

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