helpers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNode

func AddNode(clusterName, nodeName string, extraArgs ...string)

AddNode adds a node to the cluster

func ApplyDaemonSet

func ApplyDaemonSet(client *kubernetes.Clientset, namespace, manifest string) *appsv1.DaemonSet

ApplyDaemonSet parses a YAML string into a DaemonSet and creates it.

func ApplyDeployment

func ApplyDeployment(client *kubernetes.Clientset, namespace, manifest string) *appsv1.Deployment

ApplyDeployment parses a YAML string into a Deployment and creates it.

func BinkCmd

func BinkCmd(args ...string) *exec.Cmd

BinkCmd creates a bink command with the given arguments

func CleanupAllTestClusters

func CleanupAllTestClusters()

CleanupAllTestClusters removes all test clusters (containers with label bink.cluster-name=test-bink-*)

func CleanupCluster

func CleanupCluster(name string)

CleanupCluster performs full cleanup of a cluster including data

func CleanupKubeconfig

func CleanupKubeconfig(kubeconfigPath string)

CleanupKubeconfig removes the kubeconfig file.

func CollectFailureLogs

func CollectFailureLogs(clusterNames ...string)

func ContainerExists

func ContainerExists(name string) bool

ContainerExists checks if a container exists

func CreateCluster

func CreateCluster(name string)

CreateCluster creates a cluster with the given name This is a high-level helper that expects success Uses auto-assigned ports (--api-port 0) to avoid port conflicts in tests

func CreatePod

func CreatePod(client *kubernetes.Clientset, namespace string, pod *corev1.Pod, timeout time.Duration)

CreatePod creates a pod from the given spec and waits for it to be Running.

func CreateService

func CreateService(client *kubernetes.Clientset, namespace string, service *corev1.Service) *corev1.Service

CreateService creates a Service from a Go struct.

func DNSContainerName

func DNSContainerName(clusterName string) string

DNSContainerName returns the DNS container name for a cluster.

func DeletePod

func DeletePod(client *kubernetes.Clientset, namespace, name string)

DeletePod deletes a pod. Does not fail if already gone.

func ExposeAPI

func ExposeAPI(clusterName, kubeconfigPath string)

ExposeAPI exposes the API server and generates kubeconfig

func GenerateTestClusterName

func GenerateTestClusterName() string

GenerateTestClusterName creates a unique cluster name for testing

func GetContainerID

func GetContainerID(name string) string

GetContainerID returns the ID of a container by name

func GetNodeCount

func GetNodeCount(client *kubernetes.Clientset) int

GetNodeCount returns the number of Kubernetes nodes in the cluster. Returns -1 on error so callers using Eventually can retry.

func GetPodNodes

func GetPodNodes(client *kubernetes.Clientset, namespace, labelSelector string) []string

GetPodNodes returns a list of node names where pods with the given label are running.

func GetVolume

func GetVolume(name string) bool

GetVolume checks if a volume exists

func ImagePull

func ImagePull(image string)

ImagePull pulls an image from a registry.

func ImagePush

func ImagePush(source, destination string)

ImagePush pushes an image to a registry with TLS verification disabled.

func ImageRemove

func ImageRemove(names ...string)

ImageRemove removes images by name.

func ImageTag

func ImageTag(nameOrID, tag, repo string)

ImageTag tags an image with a new name.

func NewKubeClient

func NewKubeClient(kubeconfigPath string) *kubernetes.Clientset

NewKubeClient creates a Kubernetes clientset from a kubeconfig file.

func NodeContainerName

func NodeContainerName(clusterName, nodeName string) string

NodeContainerName returns the container name for a node in a cluster.

func PodExec

func PodExec(kubeconfigPath, namespace, podName string, command []string) (string, error)

PodExec executes a command inside a running pod and returns the output.

func PodmanCmd

func PodmanCmd(args ...string) string

PodmanCmd executes a podman command and returns output Note: This is deprecated - prefer using podman.Client directly in tests

func PodmanExec

func PodmanExec(container, command string) string

PodmanExec executes a command inside a container

func RemoveControlPlaneTaint

func RemoveControlPlaneTaint(client *kubernetes.Clientset, nodeName string)

RemoveControlPlaneTaint removes the NoSchedule taint from a control-plane node so that workloads can be scheduled on single-node clusters.

func RemoveNode

func RemoveNode(clusterName, nodeName string, extraArgs ...string)

RemoveNode removes a node from the cluster

func RequireBink

func RequireBink()

RequireBink verifies that the bink binary exists in the project root

func RequireCommand

func RequireCommand(cmd string)

RequireCommand verifies that a command exists on the system

func RequireImage

func RequireImage(image string)

RequireImage verifies that a container image exists

func RunCommand

func RunCommand(cmd *exec.Cmd, timeout ...time.Duration) *gexec.Session

RunCommand executes a command and waits for it to complete Returns the gexec session for assertions

func SSHExec

func SSHExec(clusterName, nodeName, command string) string

SSHExec executes a command on a node via SSH through the container

func SSHExecQuiet

func SSHExecQuiet(clusterName, nodeName, command string) (string, error)

SSHExecQuiet executes a command but doesn't fail on errors Returns output and error

func SetupKubeClient

func SetupKubeClient(clusterName string) (*kubernetes.Clientset, string)

SetupKubeClient exposes the API for a cluster and returns a clientset and the kubeconfig path.

func StopCluster

func StopCluster(name string)

StopCluster stops a cluster

func WaitForDaemonSetReady

func WaitForDaemonSetReady(client *kubernetes.Clientset, namespace, name string, expectedReady int32, timeout time.Duration)

WaitForDaemonSetReady polls until the DaemonSet has the expected number of ready pods.

func WaitForNodeReady

func WaitForNodeReady(client *kubernetes.Clientset, targetNodeName string, timeout time.Duration)

WaitForNodeReady polls until the target node shows Ready status.

func WaitForPodReady

func WaitForPodReady(client *kubernetes.Clientset, namespace, labelSelector string, timeout time.Duration)

WaitForPodReady polls until a pod matching the label selector is Running with all containers ready.

func WaitForServiceAccount

func WaitForServiceAccount(client *kubernetes.Clientset, namespace, name string, timeout time.Duration)

WaitForServiceAccount polls until the named service account exists in the namespace.

Types

type ContainerInfo

type ContainerInfo struct {
	ID     string
	Name   string
	State  string
	Ports  []string
	Labels map[string]string
}

ContainerInfo holds basic container information

func GetContainer

func GetContainer(name string) *ContainerInfo

GetContainer returns information about a container Returns nil if container doesn't exist For test usage, name should be the full container name (e.g., "k8s-test-bink-abc123-node1")

Jump to

Keyboard shortcuts

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