k8s

package
v0.13.14 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package k8s provides common functionalities for interacting with a Kubernetes cluster in the context of infrastructure testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreAllNodesReady

func AreAllNodesReady(t *testing.T) bool

AreAllNodesReady checks if all nodes are ready in the Kubernetes cluster targeted by the current config context

func AreAllNodesReadyE

func AreAllNodesReadyE(t *testing.T) (bool, error)

AreAllNodesReadyE checks if all nodes are ready in the Kubernetes cluster targeted by the current config context. If false, returns an error indicating the reason.

func DeleteConfigContextE

func DeleteConfigContextE(t *testing.T, contextName string) error

DeleteConfigContextE will remove the context specified at the provided name, and remove any clusters and authinfos that are orphaned as a result of it. The config path is either specified in the environment variable KUBECONFIG or at the user's home directory under `.kube/config`.

func DeleteConfigContextWithPathE

func DeleteConfigContextWithPathE(t *testing.T, kubeConfigPath string, contextName string) error

DeleteConfigContextWithPathE will remove the context specified at the provided name, and remove any clusters and authinfos that are orphaned as a result of it.

func GetKubeConfigPathE

func GetKubeConfigPathE(t *testing.T) (string, error)

GetKubeConfigPathE determines which file path to use as the kubectl config path

func GetKubernetesClientE

func GetKubernetesClientE(t *testing.T) (*kubernetes.Clientset, error)

GetKubernetesClientE returns a Kubernetes API client that can be used to make requests.

func GetNodes

func GetNodes(t *testing.T) []corev1.Node

GetNodes queries Kubernetes for information about the worker nodes registered to the cluster. If anything goes wrong, the function will automatically fail the test.

func GetNodesE

func GetNodesE(t *testing.T) ([]corev1.Node, error)

GetNodesE queries Kubernetes for information about the worker nodes registered to the cluster.

func GetReadyNodes

func GetReadyNodes(t *testing.T) []corev1.Node

GetReadyNodes queries Kubernetes for information about the worker nodes registered to the cluster and only returns those that are in the ready state. If anything goes wrong, the function will automatically fail the test.

func GetReadyNodesE

func GetReadyNodesE(t *testing.T) ([]corev1.Node, error)

GetReadyNodesE queries Kubernetes for information about the worker nodes registered to the cluster and only returns those that are in the ready state.

func IsNodeReady

func IsNodeReady(node corev1.Node) bool

IsNodeReady takes a Kubernetes Node information object and checks if the Node is in the ready state.

func KubeConfigPathFromHomeDirE added in v0.13.14

func KubeConfigPathFromHomeDirE() (string, error)

KubeConfigPathFromHomeDirE returns a string to the default Kubernetes config path in the home directory. This will error if the home directory can not be determined.

func LoadConfigFromPath

func LoadConfigFromPath(path string) clientcmd.ClientConfig

LoadConfigFromPath will load a ClientConfig object from a file path that points to a location on disk containing a kubectl config.

func RemoveOrphanedClusterAndAuthInfoConfig

func RemoveOrphanedClusterAndAuthInfoConfig(config *api.Config)

RemoveOrphanedClusterAndAuthInfoConfig will remove all configurations related to clusters and users that have no contexts associated with it

func WaitUntilAllNodesReady

func WaitUntilAllNodesReady(t *testing.T, retries int, sleepBetweenRetries time.Duration)

WaitUntilAllNodesReady continuously polls the Kubernetes cluster until all nodes in the cluster reach the ready state, or runs out of retries. Will fail the test immediately if it times out.

func WaitUntilAllNodesReadyE

func WaitUntilAllNodesReadyE(t *testing.T, retries int, sleepBetweenRetries time.Duration) error

WaitUntilAllNodesReadyE continuously polls the Kubernetes cluster until all nodes in the cluster reach the ready state, or runs out of retries.

Types

This section is empty.

Jump to

Keyboard shortcuts

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