k8s

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 28 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,
		HelmNginx: []string{
			"controller.hostPort.enabled=true",
			"controller.service.httpsPort.enable=false",
			"controller.service.type=NodePort",
		},
	}

	// 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),
		HelmNginx:   []string{},
	}
)
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

	// IngressCreate creates an ingress in the given namespace
	IngressCreate(ctx context.Context, namespace string, ingress *networkingv1.Ingress) error
	// IngressExists returns true if the ingress exists in the namespace, false otherwise.
	IngressExists(ctx context.Context, namespace string, ingress string) bool
	// IngressUpdate updates an existing ingress in the given namespace
	IngressUpdate(ctx context.Context, namespace string, ingress *networkingv1.Ingress) error

	// NamespaceCreate creates a namespace
	NamespaceCreate(ctx context.Context, namespace string) error
	// NamespaceExists returns true if the namespace exists, false otherwise
	NamespaceExists(ctx context.Context, namespace string) bool
	// NamespaceDelete deletes the existing namespace
	NamespaceDelete(ctx context.Context, namespace string) error

	// PersistentVolumeCreate creates a persistent volume
	PersistentVolumeCreate(ctx context.Context, namespace, name string) error
	// PersistentVolumeExists returns true if the persistent volume exists, false otherwise
	PersistentVolumeExists(ctx context.Context, namespace, name string) bool
	// PersistentVolumeDelete deletes the existing persistent volume
	PersistentVolumeDelete(ctx context.Context, namespace, name string) error

	// PersistentVolumeClaimCreate creates a persistent volume claim
	PersistentVolumeClaimCreate(ctx context.Context, namespace, name, volumeName string) error
	// PersistentVolumeClaimExists returns true if the persistent volume claim exists, false otherwise
	PersistentVolumeClaimExists(ctx context.Context, namespace, name, volumeName string) bool
	// PersistentVolumeClaimDelete deletes the existing persistent volume claim
	PersistentVolumeClaimDelete(ctx context.Context, namespace, name, volumeName string) error

	// SecretCreateOrUpdate will update or create the secret name with the payload of data in the specified namespace
	SecretCreateOrUpdate(ctx context.Context, secret corev1.Secret) error
	// SecretGet returns the secrets for the namespace and name
	SecretGet(ctx context.Context, namespace, name string) (*corev1.Secret, error)

	// ServiceGet returns the service for the given namespace and name
	ServiceGet(ctx context.Context, namespace, name string) (*corev1.Service, error)

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

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

	LogsGet(ctx context.Context, namespace string, name string) (string, error)
	StreamPodLogs(ctx context.Context, namespace string, podName string, since time.Time) (io.ReadCloser, error)
	PodList(ctx context.Context, namespace string) (*corev1.PodList, error)
}

Client primarily for testing purposes

type Cluster

type Cluster interface {
	// Create a cluster with the provided name.
	Create(portHTTP int, extraMounts []ExtraVolumeMount) error
	// Delete a cluster with the provided name.
	Delete() error
	// Exists returns true if the cluster exists, false otherwise.
	Exists() bool
}

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) 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
	// HelmNginx additional helm values to pass to the nginx chart
	HelmNginx []string
}

Provider represents a k8s provider.

func (Provider) Cluster

func (p Provider) Cluster() (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