Documentation
¶
Overview ¶
The kubeclient package provides a simple wrapper around Kubernetes interactions commonly used in the e2e tests.
Index ¶
- 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) 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) RestartDeployment(ctx context.Context, namespace, name string) error
- func (c *Kubeclient) WaitForDaemonset(ctx context.Context, namespace, name string) error
- func (c *Kubeclient) WaitForDeployment(ctx context.Context, 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
- func (c *Kubeclient) WaitForStatefulSet(ctx context.Context, namespace, name string) error
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) 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) RestartDeployment ¶ added in v0.7.0
func (c *Kubeclient) RestartDeployment(ctx context.Context, namespace, name string) error
RestartDeployment restarts a deployment by deleting all of its pods.
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).
func (*Kubeclient) WaitForStatefulSet ¶ added in v0.7.0
func (c *Kubeclient) WaitForStatefulSet(ctx context.Context, namespace, name string) error
WaitForStatefulSet watches the given StatefulSet and blocks until the desired number of pods are ready or the context expires (is cancelled or times out).