Documentation
¶
Overview ¶
The kubeclient package provides a simple wrapper around Kubernetes interactions commonly used in the e2e tests.
Index ¶
- type DaemonSet
- type Deployment
- type Kubeclient
- func (c *Kubeclient) Apply(ctx context.Context, objects ...*unstructured.Unstructured) error
- func (c *Kubeclient) Delete(ctx context.Context, objects ...*unstructured.Unstructured) error
- func (c *Kubeclient) Exec(ctx context.Context, namespace, pod string, argv []string) (stdout string, stderr string, err error)
- func (c *Kubeclient) ExecDeployment(ctx context.Context, namespace, deployment string, argv []string) (stdout string, stderr string, err error)
- func (c *Kubeclient) LogDebugInfo(ctx context.Context)
- func (c *Kubeclient) PodsFromDeployment(ctx context.Context, namespace, deployment string) ([]v1.Pod, error)
- func (c *Kubeclient) PodsFromOwner(ctx context.Context, namespace, kind, name string) ([]v1.Pod, error)
- func (k *Kubeclient) PortForwardPod(ctx context.Context, namespace, podName, remotePort string) (string, func(), error)
- func (c *Kubeclient) Restart(ctx context.Context, resource ResourceWaiter, namespace, name string) error
- func (c *Kubeclient) WaitFor(ctx context.Context, resource ResourceWaiter, namespace, name string) error
- func (c *Kubeclient) WaitForLoadBalancer(ctx context.Context, namespace, name string) (string, error)
- func (c *Kubeclient) WaitForPod(ctx context.Context, namespace, name string) error
- type ResourceWaiter
- type StatefulSet
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 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) ExecDeployment ¶ added in v0.7.0
func (c *Kubeclient) ExecDeployment(ctx context.Context, namespace, deployment string, argv []string) (stdout string, stderr string, err error)
ExecDeployment executes a process in one of the deployment's pods.
func (*Kubeclient) LogDebugInfo ¶ added in v0.8.0
func (c *Kubeclient) LogDebugInfo(ctx context.Context)
LogDebugInfo collects pod information from the cluster and writes it to the logger.
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) PodsFromOwner ¶ added in v0.7.0
func (c *Kubeclient) PodsFromOwner(ctx context.Context, namespace, kind, name string) ([]v1.Pod, error)
PodsFromOwner returns the pods owned by an object in the namespace of the given kind.
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) Restart ¶ added in v0.8.0
func (c *Kubeclient) Restart(ctx context.Context, resource ResourceWaiter, namespace, name string) error
Restart a resource by deleting all of its dependent pods.
func (*Kubeclient) WaitFor ¶ added in v0.8.0
func (c *Kubeclient) WaitFor(ctx context.Context, resource ResourceWaiter, namespace, name string) error
WaitFor watches the given resource kind and blocks until the desired number of pods are ready 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).
type ResourceWaiter ¶ added in v0.8.0
type ResourceWaiter interface {
// contains filtered or unexported methods
}
ResourceWaiter is implemented by resources that can be waited for with WaitFor.