k8s

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Kind = "kind"
	Test = "test"
)

Variables

View Source
var (
	// DefaultProvider represents the kind (https://kind.sigs.k8s.io/) provider.
	DefaultProvider = Provider{
		Name:        Kind,
		ClusterName: "airbyte-abctl",
		Context:     "kind-airbyte-abctl",
		Kubeconfig:  paths.Kubeconfig,
	}

	// TestProvider represents a test provider, for testing purposes
	TestProvider = Provider{
		Name:        Test,
		ClusterName: "test-airbyte-abctl",
		Context:     "test-airbyte-abctl",
		Kubeconfig:  filepath.Join(os.TempDir(), "abctl", paths.FileKubeconfig),
	}
)
View Source
var DefaultPersistentVolumeSize = resource.MustParse("500Mi")

DefaultPersistentVolumeSize is the size of the disks created by the persistent-volumes and requested by the persistent-volume-claims.

Functions

This section is empty.

Types

type Client

type Client interface {
	// DeploymentList returns a list of all the services within the namespace
	DeploymentList(ctx context.Context, namespace string) (*appsv1.DeploymentList, error)
	// DeploymentRestart will force a restart of the deployment name in the provided namespace.
	// This is a blocking call, it should only return once the deployment has completed.
	DeploymentRestart(ctx context.Context, namespace, name string) error

	EventsWatch(ctx context.Context, namespace string) (watch.Interface, error)

	IngressCreate(ctx context.Context, namespace string, ingress *networkingv1.Ingress) error
	IngressExists(ctx context.Context, namespace string, ingress string) bool
	IngressUpdate(ctx context.Context, namespace string, ingress *networkingv1.Ingress) error

	LogsGet(ctx context.Context, namespace string, name string) (string, error)

	NamespaceCreate(ctx context.Context, namespace string) error
	NamespaceExists(ctx context.Context, namespace string) bool
	NamespaceDelete(ctx context.Context, namespace string) error

	PersistentVolumeCreate(ctx context.Context, namespace, name string) error
	PersistentVolumeExists(ctx context.Context, namespace, name string) bool
	PersistentVolumeDelete(ctx context.Context, namespace, name string) error

	PersistentVolumeClaimCreate(ctx context.Context, namespace, name, volumeName string) error
	PersistentVolumeClaimExists(ctx context.Context, namespace, name, volumeName string) bool
	PersistentVolumeClaimDelete(ctx context.Context, namespace, name, volumeName string) error

	PodList(ctx context.Context, namespace string) (*corev1.PodList, error)

	SecretCreateOrUpdate(ctx context.Context, secret corev1.Secret) error
	// SecretDeleteCollection deletes multiple secrets.
	// Note this takes a `type` and not a `name`.  All secrets matching this type will be removed.
	SecretDeleteCollection(ctx context.Context, namespace, _type string) error
	SecretGet(ctx context.Context, namespace, name string) (*corev1.Secret, error)

	ServiceGet(ctx context.Context, namespace, name string) (*corev1.Service, error)

	StreamPodLogs(ctx context.Context, namespace string, podName string, since time.Time) (io.ReadCloser, error)

	// ServerVersionGet returns the kubernetes version.
	ServerVersionGet() (string, error)
}

Client primarily for testing purposes

type Cluster

type Cluster interface {
	// Create a cluster with the provided name.
	Create(ctx context.Context, portHTTP int, extraMounts []ExtraVolumeMount) error
	// Delete a cluster with the provided name.
	Delete(ctx context.Context) error
	// Exists returns true if the cluster exists, false otherwise.
	Exists(ctx context.Context) bool
	LoadImages(ctx context.Context, dockerClient docker.Client, images []string)
}

Cluster is an interface representing all the actions taken at the cluster level.

type DefaultK8sClient

type DefaultK8sClient struct {
	ClientSet kubernetes.Interface
}

DefaultK8sClient converts the official kubernetes client to our more manageable (and testable) interface

func (*DefaultK8sClient) DeploymentList added in v0.14.1

func (d *DefaultK8sClient) DeploymentList(ctx context.Context, namespace string) (*appsv1.DeploymentList, error)

func (*DefaultK8sClient) DeploymentRestart added in v0.13.0

func (d *DefaultK8sClient) DeploymentRestart(ctx context.Context, namespace, name string) error

func (*DefaultK8sClient) EventsWatch added in v0.5.0

func (d *DefaultK8sClient) EventsWatch(ctx context.Context, namespace string) (watch.Interface, error)

func (*DefaultK8sClient) IngressCreate

func (d *DefaultK8sClient) IngressCreate(ctx context.Context, namespace string, ingress *networkingv1.Ingress) error

func (*DefaultK8sClient) IngressExists

func (d *DefaultK8sClient) IngressExists(ctx context.Context, namespace string, ingress string) bool

func (*DefaultK8sClient) IngressUpdate

func (d *DefaultK8sClient) IngressUpdate(ctx context.Context, namespace string, ingress *networkingv1.Ingress) error

func (*DefaultK8sClient) LogsGet added in v0.5.0

func (d *DefaultK8sClient) LogsGet(ctx context.Context, namespace string, name string) (string, error)

func (*DefaultK8sClient) NamespaceCreate added in v0.6.0

func (d *DefaultK8sClient) NamespaceCreate(ctx context.Context, namespace string) error

func (*DefaultK8sClient) NamespaceDelete

func (d *DefaultK8sClient) NamespaceDelete(ctx context.Context, namespace string) error

func (*DefaultK8sClient) NamespaceExists

func (d *DefaultK8sClient) NamespaceExists(ctx context.Context, namespace string) bool

func (*DefaultK8sClient) PersistentVolumeClaimCreate added in v0.6.0

func (d *DefaultK8sClient) PersistentVolumeClaimCreate(ctx context.Context, namespace, name, volumeName string) error

func (*DefaultK8sClient) PersistentVolumeClaimDelete added in v0.6.0

func (d *DefaultK8sClient) PersistentVolumeClaimDelete(ctx context.Context, namespace, name, _ string) error

func (*DefaultK8sClient) PersistentVolumeClaimExists added in v0.6.0

func (d *DefaultK8sClient) PersistentVolumeClaimExists(ctx context.Context, namespace, name, _ string) bool

func (*DefaultK8sClient) PersistentVolumeCreate added in v0.6.0

func (d *DefaultK8sClient) PersistentVolumeCreate(ctx context.Context, namespace, name string) error

func (*DefaultK8sClient) PersistentVolumeDelete added in v0.6.0

func (d *DefaultK8sClient) PersistentVolumeDelete(ctx context.Context, _, name string) error

func (*DefaultK8sClient) PersistentVolumeExists added in v0.6.0

func (d *DefaultK8sClient) PersistentVolumeExists(ctx context.Context, _, name string) bool

func (*DefaultK8sClient) PodList added in v0.16.0

func (d *DefaultK8sClient) PodList(ctx context.Context, namespace string) (*corev1.PodList, error)

func (*DefaultK8sClient) SecretCreateOrUpdate

func (d *DefaultK8sClient) SecretCreateOrUpdate(ctx context.Context, secret corev1.Secret) error

func (*DefaultK8sClient) SecretDeleteCollection added in v0.24.0

func (d *DefaultK8sClient) SecretDeleteCollection(ctx context.Context, namespace, _type string) error

func (*DefaultK8sClient) SecretGet added in v0.11.0

func (d *DefaultK8sClient) SecretGet(ctx context.Context, namespace, name string) (*corev1.Secret, error)

func (*DefaultK8sClient) ServerVersionGet

func (d *DefaultK8sClient) ServerVersionGet() (string, error)

func (*DefaultK8sClient) ServiceGet

func (d *DefaultK8sClient) ServiceGet(ctx context.Context, namespace string, name string) (*corev1.Service, error)

func (*DefaultK8sClient) StreamPodLogs added in v0.15.0

func (d *DefaultK8sClient) StreamPodLogs(ctx context.Context, namespace string, podName string, since time.Time) (io.ReadCloser, error)

type ExtraVolumeMount added in v0.12.0

type ExtraVolumeMount struct {
	HostPath      string
	ContainerPath string
}

ExtraVolumeMount defines a host volume mount for the Kind cluster

type Logger added in v0.11.1

type Logger struct {
}

Logger is an implementation of the WarningHandler that converts the k8s warning messages into abctl debug messages.

func (Logger) HandleWarningHeader added in v0.11.1

func (x Logger) HandleWarningHeader(code int, _ string, msg string)

type Provider

type Provider struct {
	// Name of this provider
	Name string
	// ClusterName is the name of the cluster this provider will interact with
	ClusterName string
	// Context this provider should use
	Context string
	// Kubeconfig location
	Kubeconfig string
}

Provider represents a k8s provider.

func (Provider) Cluster

func (p Provider) Cluster(ctx context.Context) (Cluster, error)

Cluster returns a kubernetes cluster for this provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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