Documentation
¶
Overview ¶
Description: This file has the package kubernetesruntime.
Package kubernetesruntime stores kubernetes cluster providers which implement a common interface for interaction with them.
Index ¶
- Constants
- Variables
- type KindRuntime
- func (kr *KindRuntime) Configure(log logrus.FieldLogger, _ *box.Config)
- func (kr *KindRuntime) Create(ctx context.Context, kubernetesVersion string) error
- func (kr *KindRuntime) Destroy(ctx context.Context) error
- func (kr *KindRuntime) GetClusters(ctx context.Context) ([]*RuntimeCluster, error)
- func (*KindRuntime) GetConfig() RuntimeConfig
- func (kr *KindRuntime) GetKubeConfig(ctx context.Context, _ string) (*api.Config, error)
- func (*KindRuntime) IsAccessible(ctx context.Context) (bool, error)
- func (*KindRuntime) PreCreate(ctx context.Context) error
- func (kr *KindRuntime) Start(ctx context.Context) error
- func (kr *KindRuntime) Status(ctx context.Context) RuntimeStatus
- func (kr *KindRuntime) Stop(ctx context.Context) error
- type LoftRuntime
- func (lr *LoftRuntime) Configure(log logrus.FieldLogger, conf *box.Config)
- func (lr *LoftRuntime) Create(ctx context.Context, _ string) error
- func (lr *LoftRuntime) Destroy(ctx context.Context) error
- func (lr *LoftRuntime) GetClusters(ctx context.Context) ([]*RuntimeCluster, error)
- func (lr *LoftRuntime) GetConfig() RuntimeConfig
- func (lr *LoftRuntime) GetKubeConfig(ctx context.Context, clusterName string) (*api.Config, error)
- func (lr *LoftRuntime) IsAccessible(ctx context.Context) (bool, error)
- func (lr *LoftRuntime) PreCreate(ctx context.Context) error
- func (lr *LoftRuntime) Start(ctx context.Context) error
- func (lr *LoftRuntime) Status(ctx context.Context) RuntimeStatus
- func (lr *LoftRuntime) Stop(ctx context.Context) error
- type Runtime
- type RuntimeCluster
- type RuntimeConfig
- type RuntimeStatus
- type RuntimeType
Constants ¶
const ( KindVersion = "v0.20.0-outreach.1" KindDownloadURL = "https://github.com/getoutreach/kind/releases/download/" + KindVersion + "/kind-" + runtime.GOOS + "-" + runtime.GOARCH KindClusterName = "dev-environment" )
Variables ¶
var ( ErrNotFound = errors.New("runtime not found") ErrNotRunning = errors.New("no runtime is running") )
var EnsureKind = (&KindRuntime{}).ensureKind
EnsureKind downloads kind
Functions ¶
This section is empty.
Types ¶
type KindRuntime ¶
type KindRuntime struct {
// contains filtered or unexported fields
}
func (*KindRuntime) Configure ¶
func (kr *KindRuntime) Configure(log logrus.FieldLogger, _ *box.Config)
func (*KindRuntime) Create ¶
func (kr *KindRuntime) Create(ctx context.Context, kubernetesVersion string) error
Create creates a new Kind cluster
func (*KindRuntime) Destroy ¶
func (kr *KindRuntime) Destroy(ctx context.Context) error
Destroy destroys a kind cluster
func (*KindRuntime) GetClusters ¶
func (kr *KindRuntime) GetClusters(ctx context.Context) ([]*RuntimeCluster, error)
func (*KindRuntime) GetConfig ¶
func (*KindRuntime) GetConfig() RuntimeConfig
func (*KindRuntime) GetKubeConfig ¶
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"
Note: clusterName (_) is not used because the KinD runtime only supports creating a single cluster today. This may change in the future.
func (*KindRuntime) IsAccessible ¶
func (*KindRuntime) IsAccessible(ctx context.Context) (bool, error)
IsAccessible validates whether the runtime IsAccessible
func (*KindRuntime) Start ¶
func (kr *KindRuntime) Start(ctx context.Context) error
Start starts a kind cluster
func (*KindRuntime) Status ¶
func (kr *KindRuntime) Status(ctx context.Context) RuntimeStatus
Status gets the status of a runtime
type LoftRuntime ¶ added in v1.57.0
type LoftRuntime struct {
// contains filtered or unexported fields
}
func NewLoftRuntime ¶ added in v1.57.0
func NewLoftRuntime() *LoftRuntime
func (*LoftRuntime) Configure ¶ added in v1.57.0
func (lr *LoftRuntime) Configure(log logrus.FieldLogger, conf *box.Config)
func (*LoftRuntime) Create ¶ added in v1.57.0
func (lr *LoftRuntime) Create(ctx context.Context, _ string) error
Create create a loft cluster
func (*LoftRuntime) Destroy ¶ added in v1.57.0
func (lr *LoftRuntime) Destroy(ctx context.Context) error
func (*LoftRuntime) GetClusters ¶ added in v1.57.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.57.0
func (lr *LoftRuntime) GetConfig() RuntimeConfig
func (*LoftRuntime) GetKubeConfig ¶ added in v1.57.0
GetKubeConfig returns a kubeconfig for the provided clusterName
func (*LoftRuntime) IsAccessible ¶ added in v1.57.0
func (lr *LoftRuntime) IsAccessible(ctx context.Context) (bool, error)
IsAccessible validates whether the runtime IsAccessible
func (*LoftRuntime) PreCreate ¶ added in v1.57.0
func (lr *LoftRuntime) PreCreate(ctx context.Context) error
func (*LoftRuntime) Start ¶ added in v1.57.0
func (lr *LoftRuntime) Start(ctx context.Context) error
Start starts a Loft cluster, waking it up if it's asleep
func (*LoftRuntime) Status ¶ added in v1.57.0
func (lr *LoftRuntime) Status(ctx context.Context) RuntimeStatus
Status returns the status of our cluster
type Runtime ¶
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 with the given version using this runtime Create(context.Context, string) 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 // IsAccessible validates whether the runtime IsAccessible IsAccessible(context.Context) (bool, 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, string) (*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 ¶
GetEnabledRuntimes returns a list of enabled runtimes based on a given box configuration
func GetRuntime ¶
GetRuntime returns a runtime by name, if not found nil is returned
func GetRuntimeFromContext ¶
GetRuntimeFromContext returns the runtime from the current config.Context
func GetRuntimes ¶
func GetRuntimes() []Runtime
GetRuntimes returns all registered runtimes. Generally GetEnabledRuntimes should be used over this.
type RuntimeCluster ¶
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 }
RuntimeCluster is a cluster that is currently provisioned / accessible by a given runtime.
type RuntimeConfig ¶
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 ¶
RuntimeStatus is the status of a given runtime
type RuntimeType ¶
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" // RuntimeTypeRemote is a remote kubernetes cluster that // isn't running on the local machine and is only accessible // through the apiserver. RuntimeTypeRemote RuntimeType = "remote" )