kubernetesruntime

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package kubernetesruntime stores kubernetes cluster providers which implement a common interface for interaction with them.

Index

Constants

View Source
const (
	KindVersion     = "v0.12.0-outreach.1"
	KindDownloadURL = "https://github.com/getoutreach/kind/releases/download/" + KindVersion + "/kind-" + runtime.GOOS + "-" + runtime.GOARCH
	KindClusterName = "dev-environment"
)

Variables

View Source
var (
	ErrNotFound   = errors.New("runtime not found")
	ErrNotRunning = errors.New("no runtime is running")
)
View Source
var EnsureKind = (&KindRuntime{}).ensureKind

Deprecated: This will be removed when there's a new way of doing this. EnsureKind downloads kind

Functions

This section is empty.

Types

type KindRuntime added in v1.15.0

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

func NewKindRuntime added in v1.15.0

func NewKindRuntime() *KindRuntime

NewKindRuntime creates a new kind runtime

func (*KindRuntime) Configure added in v1.15.0

func (kr *KindRuntime) Configure(log logrus.FieldLogger, _ *box.Config)

func (*KindRuntime) Create added in v1.15.0

func (kr *KindRuntime) Create(ctx context.Context) error

Create creates a new Kind cluster

func (*KindRuntime) Destroy added in v1.15.0

func (kr *KindRuntime) Destroy(ctx context.Context) error

Destroy destroys a kind cluster

func (*KindRuntime) GetClusters added in v1.15.0

func (kr *KindRuntime) GetClusters(ctx context.Context) ([]*RuntimeCluster, error)

func (*KindRuntime) GetConfig added in v1.15.0

func (*KindRuntime) GetConfig() RuntimeConfig

func (*KindRuntime) GetKubeConfig added in v1.15.0

func (kr *KindRuntime) GetKubeConfig(ctx context.Context) (*api.Config, error)

GetKubeConfig reads a kubeconfig from Kind and returns it This is based on the original shell hack, but a lot safer: "$kindPath" get kubeconfig --name "$(yq -r ".name" <"$LIBDIR/kind.yaml")"

| sed 's/kind-dev-environment/dev-environment/' >"$KUBECONFIG"

func (*KindRuntime) PreCreate added in v1.15.0

func (*KindRuntime) PreCreate(ctx context.Context) error

func (*KindRuntime) Start added in v1.22.0

func (kr *KindRuntime) Start(ctx context.Context) error

Start starts a kind cluster

func (*KindRuntime) Status added in v1.15.0

func (kr *KindRuntime) Status(ctx context.Context) RuntimeStatus

Status gets the status of a runtime

func (*KindRuntime) Stop added in v1.22.0

func (kr *KindRuntime) Stop(ctx context.Context) error

Stop stops a kind cluster

type LoftRuntime added in v1.15.0

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

func NewLoftRuntime added in v1.15.0

func NewLoftRuntime() *LoftRuntime

func (*LoftRuntime) Configure added in v1.15.0

func (lr *LoftRuntime) Configure(log logrus.FieldLogger, conf *box.Config)

func (*LoftRuntime) Create added in v1.15.0

func (lr *LoftRuntime) Create(ctx context.Context) error

TODO(jaredallard): Move to use loftctlcmdcreate

func (*LoftRuntime) Destroy added in v1.15.0

func (lr *LoftRuntime) Destroy(ctx context.Context) error

func (*LoftRuntime) GetClusters added in v1.15.0

func (lr *LoftRuntime) GetClusters(ctx context.Context) ([]*RuntimeCluster, error)

GetClusters gets a list of current devenv clusters that are available to the current user.

func (*LoftRuntime) GetConfig added in v1.15.0

func (lr *LoftRuntime) GetConfig() RuntimeConfig

func (*LoftRuntime) GetKubeConfig added in v1.15.0

func (lr *LoftRuntime) GetKubeConfig(ctx context.Context) (*api.Config, error)

func (*LoftRuntime) PreCreate added in v1.15.0

func (lr *LoftRuntime) PreCreate(ctx context.Context) error

func (*LoftRuntime) Start added in v1.22.0

func (lr *LoftRuntime) Start(ctx context.Context) error

func (*LoftRuntime) Status added in v1.15.0

func (lr *LoftRuntime) Status(ctx context.Context) RuntimeStatus

Status returns the status of our cluster

func (*LoftRuntime) Stop added in v1.22.0

func (lr *LoftRuntime) Stop(ctx context.Context) error

type Runtime added in v1.15.0

type Runtime interface {
	// GetConfig returns the configuration of a runtime
	GetConfig() RuntimeConfig

	// Status returns the status of a given runtime.
	Status(context.Context) RuntimeStatus

	// Create creates a new Kubernetes cluster using this runtime
	Create(context.Context) error

	// Destroy destroys a kubernetes cluster from this runtime
	Destroy(context.Context) error

	// Stop stops (sleeps) a kubernetes cluster from this runtime
	Stop(context.Context) error

	// Start starts (awakens) a kubernetes cluster from this runtime
	Start(context.Context) error

	// PreCreate is ran before creating a kubernetes cluster, useful
	// for implementing pre-requirements.
	PreCreate(context.Context) error

	// Configure is ran first to configure the runtime with it's
	// dependencies.
	Configure(logrus.FieldLogger, *box.Config)

	// GetKubeConfig returns the kube conf for the active cluster
	// created by this runtime.
	GetKubeConfig(context.Context) (*api.Config, error)

	// GetClusters returns all clusters currently accessible by this runtime
	GetClusters(context.Context) ([]*RuntimeCluster, error)
}

Runtime is the Kubernetes Runtime interface that all runtimes should implement.

func GetEnabledRuntimes added in v1.15.0

func GetEnabledRuntimes(b *box.Config) []Runtime

GetEnabledRuntimes returns a list of enabled runtimes based on a given box configuration

func GetRuntime added in v1.15.0

func GetRuntime(name string) (Runtime, error)

GetRuntime returns a runtime by name, if not found nil is returned

func GetRuntimeFromContext added in v1.15.0

func GetRuntimeFromContext(conf *config.Config, b *box.Config) (Runtime, error)

GetRuntimeFromContext returns the runtime from the current config.Context

func GetRuntimes added in v1.15.0

func GetRuntimes() []Runtime

GetRuntimes returns all registered runtimes. Generally GetEnabledRuntimes should be used over this.

type RuntimeCluster added in v1.15.0

type RuntimeCluster struct {
	// RuntimeName is the name of the runtime that created this cluster
	RuntimeName string

	// Name is the name of this cluster.
	Name string

	// KubeConfig is the kubeconfig that allows access to this cluster.
	KubeConfig *api.Config
}

RuntimeCluster is a cluster that is currently provisioned / accessible by a given runtime.

type RuntimeConfig added in v1.15.0

type RuntimeConfig struct {
	// Name is the name of this runtime
	Name string

	// Type is the type of runtime this is
	Type RuntimeType

	// ClusterName is the name of the cluster this runtime creates
	ClusterName string
}

RuntimeConfig is a config returned by a runtim

type RuntimeStatus added in v1.15.0

type RuntimeStatus struct {
	status.Status
}

RuntimeStatus is the status of a given runtime

type RuntimeType added in v1.15.0

type RuntimeType string

RuntimeType dictates what type of runtime this kubernetes runtime implements.

const (
	// RuntimeTypeLocal is a local kubernetes cluster that
	// runs directly on this computer, e.g. in a Docker for X
	// compatible VM or directly on the host via Docker.
	RuntimeTypeLocal RuntimeType = "local"

	// RunetimeTypeRemote is a remote kubernetes cluster
	// that has no connection other than APIServer with
	// this PC.
	RuntimeTypeRemote RuntimeType = "remote"
)

Jump to

Keyboard shortcuts

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