kubby

package module
v0.0.0-...-3f42d63 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 31 Imported by: 0

README

kubby

a library for running isolated Kubernetes clusters

Example

examples can be found at kubby-examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContainerId

func GetContainerId(name string) (string, error)

func NewContainerClient

func NewContainerClient() (*client.Client, error)

func NewProvider

func NewProvider() *cluster.Provider

Types

type BadContainerNameError

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

func (*BadContainerNameError) Error

func (err *BadContainerNameError) Error() string

type BadImageBuildError

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

func (*BadImageBuildError) Error

func (err *BadImageBuildError) Error() string

type BadPodNameError

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

func (*BadPodNameError) Error

func (err *BadPodNameError) Error() string

type ChartMap

type ChartMap map[string]*HelmChart

type ClusterRegistry

type ClusterRegistry struct {
	Container
	Url string
}

func NewRegistry

func NewRegistry(ctx context.Context, name string, hostPort string, imagePort string) (*ClusterRegistry, error)

func (*ClusterRegistry) BuildAndPushImage

func (r *ClusterRegistry) BuildAndPushImage(ctx context.Context, dockerPath string, name string) error

func (*ClusterRegistry) PushImage

func (r *ClusterRegistry) PushImage(ctx context.Context, image string) error

type ClusterStatus

type ClusterStatus int
const (
	Alive ClusterStatus = iota
	Dead
)

func (ClusterStatus) String

func (status ClusterStatus) String() string

type Container

type Container struct {
	Client   *client.Client
	Id       string
	Name     string
	Image    string
	Tag      string
	Networks []string
	Ports    map[string]string
}

func NewContainer

func NewContainer(ctx context.Context, options ...ContainerOption) (*Container, error)

func (*Container) Delete

func (c *Container) Delete(ctx context.Context) error

func (*Container) Start

func (c *Container) Start(ctx context.Context) error

func (*Container) Stop

func (c *Container) Stop(ctx context.Context) error

type ContainerOption

type ContainerOption func(c *Container)

func WithClient

func WithClient(cli *client.Client) ContainerOption

func WithContainerName

func WithContainerName(name string) ContainerOption

func WithImage

func WithImage(image string) ContainerOption

func WithNetwork

func WithNetwork(network string) ContainerOption

func WithPort

func WithPort(imagePort string, hostPort string) ContainerOption

func WithTag

func WithTag(tag string) ContainerOption

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
}

type ErrorLine

type ErrorLine struct {
	Error       string      `json:"error"`
	ErrorDetail ErrorDetail `json:"errorDetail"`
}

type ExceededMaxAttemptError

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

func (*ExceededMaxAttemptError) Error

func (err *ExceededMaxAttemptError) Error() string

type ExistingKubeClusterError

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

func (*ExistingKubeClusterError) Error

func (err *ExistingKubeClusterError) Error() string

type ExistingKubeConfigError

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

func (*ExistingKubeConfigError) Error

func (err *ExistingKubeConfigError) Error() string

type FailedJobError

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

func (*FailedJobError) Error

func (err *FailedJobError) Error() string

type HelmChart

type HelmChart struct {
	Path      string
	Namespace string
	Name      string
}

type HelmChartManager

type HelmChartManager struct {
	KubeConfigPath string
	Charts         ChartMap
}

func NewHelmChartManager

func NewHelmChartManager(path string) (*HelmChartManager, error)

func (*HelmChartManager) InstallChart

func (hcm *HelmChartManager) InstallChart(name string, namespace string, path string) error

type HelmResourcer

type HelmResourcer interface {
	InstallChart(string, string, string) error
}

type ImageRegister

type ImageRegister interface {
	BuildAndPushImage(context.Context, string, string) error
	PushImage(context.Context, string) error
	Delete(context.Context) error
}

type KindConfig

type KindConfig struct {
	Name              string
	ControlPlaneNodes int
	WorkerNodes       int
	NodePorts         []*NodePort
	RegistryAddress   string
	RegistryPort      string
}

func NewKindConfig

func NewKindConfig(name string, cnCount int, wnCount int, np []*NodePort, ra string, rp string) *KindConfig

func (*KindConfig) String

func (config *KindConfig) String() string

type KubeCluster

type KubeCluster struct {
	Provider         *cluster.Provider
	Name             string
	KubeConfigPath   string
	WorkerCount      int
	ControlCount     int
	KindConfig       *KindConfig
	MaxStartAttempts int
	Status           ClusterStatus
	RegistryName     string
	KubeClient       *kubernetes.Clientset
	RegistryPort     int
	NodePorts        []*NodePort
	Namespaces       []string
	Charts           []*HelmChart
	Images           []string
	KubeResourcer
	HelmResourcer
	ImageRegister
}

func NewKubeCluster

func NewKubeCluster(options ...KubeClusterOption) (*KubeCluster, error)

func (*KubeCluster) Delete

func (kc *KubeCluster) Delete() error

func (*KubeCluster) Start

func (kc *KubeCluster) Start() error

create creates the kind cluster. It will retry up to maxAttempts times

type KubeClusterOption

type KubeClusterOption func(kc *KubeCluster)

func ShouldStartOnCreation

func ShouldStartOnCreation(start bool) KubeClusterOption

func WithControlNodes

func WithControlNodes(count int) KubeClusterOption

func WithHelmCharts

func WithHelmCharts(charts ...*HelmChart) KubeClusterOption

func WithImages

func WithImages(images ...string) KubeClusterOption

func WithKubeClient

func WithKubeClient(kubeclient *kubernetes.Clientset) KubeClusterOption

func WithKubeConfigPath

func WithKubeConfigPath(path string) KubeClusterOption

func WithMaxAttempts

func WithMaxAttempts(attempts int) KubeClusterOption

func WithName

func WithName(name string) KubeClusterOption

func WithNamespaces

func WithNamespaces(namespaces ...string) KubeClusterOption

func WithNodePorts

func WithNodePorts(ports ...*NodePort) KubeClusterOption

func WithRegistry

func WithRegistry(registry *ClusterRegistry, port int) KubeClusterOption

func WithWorkerNodes

func WithWorkerNodes(count int) KubeClusterOption

type KubeResourceManager

type KubeResourceManager struct {
	Client kubernetes.Clientset
}

func NewKubeResourceManager

func NewKubeResourceManager(kubePath string) (*KubeResourceManager, error)

func (*KubeResourceManager) CreateDeployment

func (manager *KubeResourceManager) CreateDeployment(ctx context.Context, namespace string, deployment *appsv1.Deployment) error

func (*KubeResourceManager) CreateNamespace

func (manager *KubeResourceManager) CreateNamespace(ctx context.Context, name string) error

func (*KubeResourceManager) DeleteDeployment

func (manager *KubeResourceManager) DeleteDeployment(ctx context.Context, namespace string, name string) error

func (*KubeResourceManager) RunJob

func (manager *KubeResourceManager) RunJob(ctx context.Context, namespace string, jobSpec *batchv1.Job, checkInterval time.Duration) error

type KubeResourcer

type KubeResourcer interface {
	RunJob(context.Context, string, *batchv1.Job, time.Duration) error
	CreateDeployment(context.Context, string, *appsv1.Deployment) error
	DeleteDeployment(context.Context, string, string) error
	CreateNamespace(ctx context.Context, name string) error
}

type MissingFieldError

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

func (*MissingFieldError) Error

func (err *MissingFieldError) Error() string

type NodePort

type NodePort struct {
	Host      string
	Container string
}

Jump to

Keyboard shortcuts

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