Documentation ¶
Index ¶
- Variables
- type Client
- func (c Client) Get(ctx context.Context, nodeName string) (v1.Node, error)
- func (c Client) GetLabels(ctx context.Context, nodeName string) (map[string]string, error)
- func (c Client) Label(ctx context.Context, n v1.Node, labels map[string]string) error
- func (c Client) ListAll(ctx context.Context) ([]v1.Node, error)
- func (c Client) ListWorkers(ctx context.Context) ([]v1.Node, error)
- func (c Client) TaintWorkers(ctx context.Context, t []v1.Taint) error
- func (c Client) UnlabelAll(ctx context.Context, labelsKeys []string) error
- func (c Client) UntaintAll(ctx context.Context, t []v1.Taint) error
- type ErrNodeGet
- type ErrNodeUpdate
Constants ¶
This section is empty.
Variables ¶
var ( // Well known taints for master nodes, see // https://kubernetes.io/docs/reference/labels-annotations-taints/. // Tainting such nodes might result in a broken cluster should one of the // control plane components fail during the test runs. MasterTaintKeys = map[string]struct{}{ "node-role.kubernetes.io/master": {}, "node-role.kubernetes.io/control-plane": {}, } )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Nodes corev1client.NodeInterface MasterNodeTaints map[string]struct{} Log logr.Logger }
func NewClientFromKubecfg ¶
func (Client) Get ¶
Get returns the node named `nodeName`. In case of error, it returns the error and an empty v1.Node struct.
func (Client) ListAll ¶
ListAll returns a slice with all the nodes in the K8s cluster. ListAll returns an empty slice and an error if a failure occurs.
func (Client) ListWorkers ¶
ListWorkers returns a slice with all the worker nodes in the K8s cluster. Worker nodes are nodes that DO NOT have the taints with the keys contained in `c.MasterNodeTaints`. ListWorkers returns an empty slice and an error if a failure occurs.
func (Client) TaintWorkers ¶
TaintWorkers adds the taints `t` to all the worker nodes in the K8s cluster. Worker nodes are nodes that DO NOT have the taints with the keys contained in `c.MasterNodeTaints`. TaintWorkers is idempotent:
- if a worker already has a subset of the taints in `t`, only the missing ones are added.
- if a worker already has all the taints in `t`, it's left unchanged.
If a worker has one (or more) taint(s) with the same key as one of the taints in `t` but different value or effect, TaintWorkers panics. TaintWorkers returns an error if a failure occurs.
func (Client) UnlabelAll ¶
UnlabelAll removes the labels with the keys in `labelsKeys` from all the nodes (worker and master ones) in the K8s cluster, regardless of the labels values. UnlabelAll is idempotent and safe to retry:
- if a node has only a subset of the labels in `labelsKeys`, only that subset is removed.
- if a node doesn't have any of the labels in `labelsKeys`, it's left unchanged.
UnlabelAll returns an error if a failure occurs.
func (Client) UntaintAll ¶
UntaintAll removes the taints `t` from all the nodes (worker and master ones) in the K8s cluster. UntaintAll is idempotent and safe to retry:
- if a node has only a subset of the taints in `t`, only that subset is removed.
- if a node doesn't have any of the taints in `t`, it's left unchanged.
If a node has one (or more) taint(s) with the same key as one of the taints in `t` but different value or effect, UntaintAll panics. UntaintAll returns an error if a failure occurs.
type ErrNodeGet ¶
ErrNodeGet is the error type returned when a node GET call fails. Unless you really really really really know what you're doing, avoid calling errors.Is on variables of type `ErrNodeGet`, because it behaves in crazy ways: errors.Is(e1, e2) can panic if both e1 and e2 are variables of type ErrNodeGet, in the case where e1.Err and e2.Err are of two incomparable concrete types. More details here: https://github.com/golang/go/issues/54709
func (ErrNodeGet) Error ¶
func (e ErrNodeGet) Error() string
func (ErrNodeGet) Unwrap ¶
func (e ErrNodeGet) Unwrap() error
type ErrNodeUpdate ¶
ErrNodeUpdate is the error type returned when a node UPDATE call fails. Unless you really really really really know what you're doing, avoid calling errors.Is on variables of type `ErrNodeUpdate`, because it behaves in crazy ways. First, ErrNodeUpdate is not reflexive with respect to errors.Is. This means that given a variable `e` of type ErrNodeUpdate errors.Is(e, e) evaluates to `false`. Second, errors.Is(e1, e2) can panic if both e1 and e2 are variables of type ErrNodeUpdate, in the case where e1.Err and e2.Err are of two incomparable concrete types. More details here: https://github.com/golang/go/issues/54709
func (ErrNodeUpdate) Error ¶
func (e ErrNodeUpdate) Error() string
func (ErrNodeUpdate) Unwrap ¶
func (e ErrNodeUpdate) Unwrap() error