kubeclient

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

The kubeclient package provides a simple wrapper around Kubernetes interactions commonly used in the e2e tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kubeclient

type Kubeclient struct {
	// contains filtered or unexported fields
}

A Kubeclient offers a communication interface to a Kubernetes cluster.

func New

func New(config *rest.Config, log *slog.Logger) (*Kubeclient, error)

New creates a new Kubeclient from a given Kubeconfig.

func NewForTest

func NewForTest(t *testing.T) *Kubeclient

NewForTest creates a Kubeclient with parameters suitable for e2e testing.

func NewFromConfigFile

func NewFromConfigFile(configPath string, log *slog.Logger) (*Kubeclient, error)

NewFromConfigFile creates a new Kubeclient for a given Kubeconfig file.

func (*Kubeclient) Apply

func (c *Kubeclient) Apply(ctx context.Context, objects ...*unstructured.Unstructured) error

Apply a set of namespaced manifests to a namespace.

func (*Kubeclient) Delete

func (c *Kubeclient) Delete(ctx context.Context, objects ...*unstructured.Unstructured) error

Delete a set of manifests.

func (*Kubeclient) Exec

func (c *Kubeclient) Exec(ctx context.Context, namespace, pod string, argv []string) (
	stdout string, stderr string, err error,
)

Exec executes a process in a pod and returns the stdout and stderr.

func (*Kubeclient) PodsFromDaemonSet

func (c *Kubeclient) PodsFromDaemonSet(ctx context.Context, namespace, daemonset string) ([]v1.Pod, error)

PodsFromDaemonSet returns the pods from a daemonset in a namespace.

A pod is considered to belong to a daemonset if it is owned by the DaemonSet in question.

func (*Kubeclient) PodsFromDeployment

func (c *Kubeclient) PodsFromDeployment(ctx context.Context, namespace, deployment string) ([]v1.Pod, error)

PodsFromDeployment returns the pods from a deployment in a namespace.

A pod is considered to belong to a deployment if it is owned by a ReplicaSet which is in turn owned by the Deployment in question.

func (*Kubeclient) PortForwardPod

func (k *Kubeclient) PortForwardPod(ctx context.Context, namespace, podName, remotePort string) (string, func(), error)

PortForwardPod starts a port forward to the selected pod.

On success, the function returns a TCP address that clients can connect to and a function to cancel the port forwarding.

func (*Kubeclient) WaitForDaemonset

func (c *Kubeclient) WaitForDaemonset(ctx context.Context, namespace, name string) error

WaitForDaemonset watches the given daemonset and blocks until the desired number of pods are ready or the context expires (is cancelled or times out).

func (*Kubeclient) WaitForDeployment

func (c *Kubeclient) WaitForDeployment(ctx context.Context, namespace, name string) error

WaitForDeployment watches the given deployment and blocks until it meets the condition Available=True or the context expires (is cancelled or times out).

func (*Kubeclient) WaitForLoadBalancer

func (c *Kubeclient) WaitForLoadBalancer(ctx context.Context, namespace, name string) (string, error)

WaitForLoadBalancer waits until the given service is configured with an external IP and returns it.

func (*Kubeclient) WaitForPod

func (c *Kubeclient) WaitForPod(ctx context.Context, namespace, name string) error

WaitForPod watches the given pod and blocks until it meets the condition Ready=True or the context expires (is cancelled or times out).

Jump to

Keyboard shortcuts

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