Documentation ¶
Overview ¶
Package helpers implement helper functions for managing Kubernetes resources such as services and pods
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachOptions ¶ added in v0.3.2
type AttachOptions struct { // timeout for waiting until container is ready. Timeout time.Duration // IgnoreIfExists causes AttachEphemeralContainer to return successfully if the ephemeral container already exists // when set to true. If set to false, it will exit with an error if the container already exists. IgnoreIfExists bool }
AttachOptions defines options for attaching a container
type FakePodCommandExecutor ¶
type FakePodCommandExecutor struct {
// contains filtered or unexported fields
}
FakePodCommandExecutor mocks the execution of a command in a pod recording the command history and returning a predefined stdout, stderr, and error
func NewFakePodCommandExecutor ¶
func NewFakePodCommandExecutor() *FakePodCommandExecutor
NewFakePodCommandExecutor creates a new instance of FakePodCommandExecutor with default attributes
func (*FakePodCommandExecutor) Exec ¶
func (f *FakePodCommandExecutor) Exec( _ context.Context, pod string, namespace string, container string, cmd []string, stdin []byte, ) ([]byte, []byte, error)
Exec records the execution of a command and returns the pre-defined
func (*FakePodCommandExecutor) GetHistory ¶
func (f *FakePodCommandExecutor) GetHistory() []Command
GetHistory returns the history of commands executed by the FakePodCommandExecutor
type PodCommandExecutor ¶ added in v0.3.7
type PodCommandExecutor interface { // Exec executes a non-interactive command described in options and returns the stdout and stderr outputs Exec( ctx context.Context, pod string, namespace string, container string, command []string, stdin []byte, ) ([]byte, []byte, error) }
PodCommandExecutor defines a method for executing commands in a target Pod
func NewRestExecutor ¶ added in v0.3.7
func NewRestExecutor(client rest.Interface, config *rest.Config) PodCommandExecutor
NewRestExecutor returns a PodCommandExecutor that executes command using rest client with the given rest configuration
type PodFilter ¶ added in v0.3.2
type PodFilter struct { // Select Pods that match these labels Select map[string]string // Select Pods that match these labels Exclude map[string]string }
PodFilter defines the criteria for selecting a pod for disruption
type PodHelper ¶
type PodHelper interface { // WaitPodRunning waits for the Pod to be running for up to given timeout and returns a boolean indicating // if the status was reached. If the pod is Failed returns error. WaitPodRunning(ctx context.Context, name string, timeout time.Duration) (bool, error) // WaitPodDeleted waits for the Pod to be deleted for up to given timeout WaitPodDeleted(ctx context.Context, name string, timeout time.Duration) error // Exec executes a non-interactive command described in options and returns the stdout and stderr outputs Exec(ctx context.Context, pod string, container string, command []string, stdin []byte) ([]byte, []byte, error) // AttachEphemeralContainer adds an ephemeral container to a running pod AttachEphemeralContainer( ctx context.Context, podName string, container corev1.EphemeralContainer, options AttachOptions, ) error // List returns a list of pods that match the given PodFilter List(ctx context.Context, filter PodFilter) ([]corev1.Pod, error) // Terminate terminates the execution of a running Pod Terminate(ctx context.Context, name string, timeout time.Duration) error }
PodHelper defines helper methods for handling Pods
func NewPodHelper ¶ added in v0.3.2
func NewPodHelper(client kubernetes.Interface, executor PodCommandExecutor, namespace string) PodHelper
NewPodHelper returns a PodHelper
type ServiceHelper ¶
type ServiceHelper interface { // WaitServiceReady waits for the given service to have at least one endpoint available WaitServiceReady(ctx context.Context, service string, timeout time.Duration) error // WaitIngressReady waits for the given service to have a load balancer address assigned WaitIngressReady(ctx context.Context, ingress string, timeout time.Duration) error // GetTargets returns the list of pods that match the service selector criteria GetTargets(ctx context.Context, service string) ([]corev1.Pod, error) }
ServiceHelper implements functions for dealing with services
func NewServiceHelper ¶ added in v0.3.2
func NewServiceHelper(client kubernetes.Interface, namespace string) ServiceHelper
NewServiceHelper returns a ServiceHelper