Documentation ¶
Overview ¶
Package k8sutil provides various wrappers over Kubernetes tooling.
Index ¶
- func FilterContainerLinuxNodes(nodes []corev1.Node) []corev1.Node
- func FilterNodesByAnnotation(list []corev1.Node, sel fields.Selector) []corev1.Node
- func FilterNodesByRequirement(nodes []corev1.Node, req *labels.Requirement) []corev1.Node
- func FilterPods(pods []corev1.Pod, filter func(*corev1.Pod) bool) []corev1.Pod
- func GetClient(path string) (*kubernetes.Clientset, error)
- func GetNodeRetry(ctx context.Context, nc NodeGetter, node string) (*corev1.Node, error)
- func NewRequirementOrDie(key string, op selection.Operator, vals []string) *labels.Requirement
- func SetNodeAnnotations(ctx context.Context, nc NodeUpdater, node string, m map[string]string) error
- func SetNodeAnnotationsLabels(ctx context.Context, nc NodeUpdater, nodeName string, ...) error
- func SetNodeLabels(ctx context.Context, nc NodeUpdater, node string, m map[string]string) error
- func Unschedulable(ctx context.Context, nc NodeUpdater, node string, sched bool) error
- func UpdateNodeRetry(ctx context.Context, nodeUpdater NodeUpdater, nodeName string, ...) error
- type NodeGetter
- type NodeUpdater
- type UpdateNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterContainerLinuxNodes ¶
FilterContainerLinuxNodes filters a list of nodes and returns nodes with a Flatcar Container Linux OSImage, as reported by the node's /etc/os-release.
func FilterNodesByAnnotation ¶
FilterNodesByAnnotation takes a node list and a field selector, and returns a node list that matches the field selector.
func FilterNodesByRequirement ¶
FilterNodesByRequirement filters a list of nodes and returns nodes matching the given label requirement.
func FilterPods ¶
FilterPods filters given list of pods using given function.
func GetClient ¶
func GetClient(path string) (*kubernetes.Clientset, error)
GetClient returns a Kubernetes client (clientset) from the kubeconfig path or from the in-cluster service account environment.
func GetNodeRetry ¶
GetNodeRetry gets a node object, retrying up to DefaultBackoff number of times if it fails.
func NewRequirementOrDie ¶
NewRequirementOrDie wraps a call to NewRequirement and panics if the Requirement cannot be created. It is intended for use in variable initializations only.
func SetNodeAnnotations ¶
func SetNodeAnnotations(ctx context.Context, nc NodeUpdater, node string, m map[string]string) error
SetNodeAnnotations sets all keys in m to their respective values in node's annotations.
func SetNodeAnnotationsLabels ¶
func SetNodeAnnotationsLabels( ctx context.Context, nc NodeUpdater, nodeName string, annotations, labels map[string]string, ) error
SetNodeAnnotationsLabels sets all keys in a and l to their values in node's annotations and labels, respectively.
func SetNodeLabels ¶
SetNodeLabels sets all keys in m to their respective values in node's labels.
func Unschedulable ¶
Unschedulable marks node as schedulable or unschedulable according to sched.
func UpdateNodeRetry ¶
func UpdateNodeRetry(ctx context.Context, nodeUpdater NodeUpdater, nodeName string, updateF UpdateNode) error
UpdateNodeRetry calls f to update a node object in Kubernetes. It will attempt to update the node by applying f to it up to DefaultBackoff number of times. Given update function will be called each time since the node object will likely have changed if a retry is necessary.
Types ¶
type NodeGetter ¶ added in v0.9.0
type NodeGetter interface {
Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1.Node, error)
}
NodeGetter is a subset of corev1client.NodeInterface used by this package for getting node objects.
type NodeUpdater ¶ added in v0.9.0
type NodeUpdater interface { NodeGetter Update(ctx context.Context, node *corev1.Node, opts metav1.UpdateOptions) (*corev1.Node, error) }
NodeUpdater is a subset of corev1client.NodeInterface used by this package for updating nodes.
type UpdateNode ¶ added in v0.9.0
UpdateNode is a function updating properties of received node object.