k8s

package
v0.0.0-...-56ddf34 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// ListNamespaces retrieves all namespaces in the cluster.
	ListNamespaces(ctx context.Context, opts metav1.ListOptions) ([]corev1.Namespace, error)

	// ListPods retrieves all pods in the namespace.
	ListPods(ctx context.Context, namespace string, opts metav1.ListOptions) ([]corev1.Pod, error)

	// DeletePod deletes a pod.
	DeletePod(ctx context.Context, namespace, name string, opts metav1.DeleteOptions) error

	// ListStatefulSets retrieves all stateful sets in the namespace.
	ListStatefulSets(ctx context.Context, namespace string, opts metav1.ListOptions) ([]appsv1.StatefulSet, error)

	// GetStatefulSet retrieves a single StatefulSet.
	GetStatefulSet(ctx context.Context, namespace, name string, opts metav1.GetOptions) (*appsv1.StatefulSet, error)
}

Client provides an interface for interacting with a Kubernetes cluster. It is a thin wrapper around the Kubernetes API which allows for mocking requests.

type ClientImpl

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

ClientImpl implements Client.

func NewClient

func NewClient(ctx context.Context, clientset *kubernetes.Clientset) (*ClientImpl, error)

NewClient returns a ClientImpl instance. TODO(borenet): Handle more of the setup here.

func NewInClusterClient

func NewInClusterClient(ctx context.Context) (*ClientImpl, error)

NewInClusterClient creates a Client which can be used to interact with the cluster in which this service is running.

func NewLocalClient

func NewLocalClient(ctx context.Context, kubeConfigFile, clusterConfigFile, cluster string) (*ClientImpl, error)

NewLocalClient uses the local kubeconfig file, the clusters config.json file, and a cluster name to create a Client which can be used to interact with that cluster. TODO(borenet): This requires that the user has previously created credentials for the requested cluster.

func (*ClientImpl) DeletePod

func (c *ClientImpl) DeletePod(ctx context.Context, namespace, name string, opts metav1.DeleteOptions) error

DeletePod implements Client.

func (*ClientImpl) GetStatefulSet

func (c *ClientImpl) GetStatefulSet(ctx context.Context, namespace, name string, opts metav1.GetOptions) (*appsv1.StatefulSet, error)

GetStatefulSet implements Client.

func (*ClientImpl) ListNamespaces

func (c *ClientImpl) ListNamespaces(ctx context.Context, opts metav1.ListOptions) ([]corev1.Namespace, error)

GetNamespaces implements Client.

func (*ClientImpl) ListPods

func (c *ClientImpl) ListPods(ctx context.Context, namespace string, opts metav1.ListOptions) ([]corev1.Pod, error)

GetPods implements Client.

func (*ClientImpl) ListStatefulSets

func (c *ClientImpl) ListStatefulSets(ctx context.Context, namespace string, opts metav1.ListOptions) ([]appsv1.StatefulSet, error)

ListStatefulSets implements Client.

Directories

Path Synopsis
watch

Jump to

Keyboard shortcuts

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