cluster

package
v0.0.0-...-fe3d3e7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cluster handles the resource creation to run Kubernetes clusters and bootstrap of the Kubernetes cluster. Additional provides can be introduced by implementing the ClusterManager interface.

Index

Constants

View Source
const (
	// represents a provider believes the cluster is running.
	StatusRunning = "Running"
	// represents a provider believes the cluster is stopped.
	StatusStopped = "Stopped"
	// represents a provider does not know the state of a cluster.
	StatusUnknown = "Unknown"
)
View Source
const (
	KindTypedataCluster    = "Cluster"
	KindTypedataAPIVersion = "kind.x-k8s.io/v1alpha4"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KindClusterManager

type KindClusterManager struct {
}

KindClusterManager is a ClusterManager implementation for working with Kind clusters.

func NewKindClusterManager

func NewKindClusterManager() *KindClusterManager

NewKindClusterManager gets a ClusterManager implementation for the kind provider.

func (*KindClusterManager) Create

Create will create a new kind cluster or return an error.

func (*KindClusterManager) Delete

Delete removes a kind cluster.

func (*KindClusterManager) Get

func (kcm *KindClusterManager) Get(clusterName string) (*KubernetesCluster, error)

Get retrieves cluster information. An error is returned if no cluster is found or if there is a failure communicating with kind/docker.

func (*KindClusterManager) PostProviderNotify

func (kcm *KindClusterManager) PostProviderNotify() []string

PostProviderNotify returns the kind provider logs/notifications after bootstrapping Noop - nothing to return after bootstrapping

func (*KindClusterManager) PreProviderNotify

func (kcm *KindClusterManager) PreProviderNotify() []string

PreProviderNotify returns the kind provider notification used during cluster bootstrapping

func (*KindClusterManager) PreflightCheck

func (kcm *KindClusterManager) PreflightCheck() ([]string, []error)

PreflightCheck performs any pre-checks that can find issues up front that would cause problems for cluster creation.

func (*KindClusterManager) Prepare

Prepare will fetch a container image to the cluster host.

func (*KindClusterManager) Start

Start attempts to start a kind cluster. It returns an error when: 1. The cluster is already running. 2. There are issues communicating with kind/docker. 3. The cluster fails to start.

func (*KindClusterManager) Stop

Stop takes a running kind cluster and stops the host.

type KubernetesCluster

type KubernetesCluster struct {
	// Name is the name of the cluster.
	Name string
	// KubeConfig contains the Kubeconfig data for the cluster.
	Kubeconfig []byte
	// The state of the cluster as defined by the provider. Examples may be
	// "Running", "Stopped", or "Unknown".
	Status string
	// Specifies the underlying host driver used by the cluster provider. For example,
	// minikube supports drivers like docker and kvm.
	Driver string
}

KubernetesCluster represents a defines k8s cluster.

type Manager

type Manager interface {
	// Create will create a new cluster or return an error indicating a problem
	// during creation.
	Create(c *config.UnmanagedClusterConfig) (*KubernetesCluster, error)
	// Get retrieves cluster information or return an error indicating a problem.
	Get(clusterName string) (*KubernetesCluster, error)
	// Delete will destroy a cluster or return an error indicating a problem.
	Delete(c *config.UnmanagedClusterConfig) error
	// Prepare will fetch an image or perform any pre-steps that can be done
	// prior to actually creating the cluster.
	Prepare(c *config.UnmanagedClusterConfig) error
	// PreflightCheck performs any pre-checks that can find issues up front that
	// would cause problems for cluster creation. Returns nil if there are no
	// errors found, otherwise a list of the errors that need to be resolved.
	// A list of warning messages can be returned that are not blocking errors.
	PreflightCheck() ([]string, []error)
	// PreProviderNotify returns any provider specific notifications or messages
	// to log before bootstrapping starts.
	// Each string will be displayed on its own line.
	PreProviderNotify() []string
	// PostProviderNotify returns any provider specific notifications or messages
	// to log after bootstrapping has finished.
	// Each string will be displayed on its own line.
	PostProviderNotify() []string
	/// Stop attempts to stop a running cluster.
	Stop(c *config.UnmanagedClusterConfig) error
	// Start attempts to start a stopped cluster.
	Start(c *config.UnmanagedClusterConfig) error
}

Manager provides methods for creating and managing Kubernetes clusters.

func NewClusterManager

func NewClusterManager(c *config.UnmanagedClusterConfig) Manager

NewClusterManager provides a way to dynamically get a cluster manager based on the unmanaged cluster config provider

type MinikubeClusterManager

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

func NewMinikubeClusterManager

func NewMinikubeClusterManager() *MinikubeClusterManager

NewMinikubeClusterManager

func (*MinikubeClusterManager) Create

Create creates a minikube cluster with a given profile name

func (*MinikubeClusterManager) Delete

Delete will delete the minikube cluster given a named profile

func (*MinikubeClusterManager) Get

func (mkcm *MinikubeClusterManager) Get(clusterName string) (*KubernetesCluster, error)

Get retrieves cluster information. An error is returned if no cluster is found or if there is a failure communicating with minikube.

func (*MinikubeClusterManager) PostProviderNotify

func (mkcm *MinikubeClusterManager) PostProviderNotify() []string

PostProviderNotify returns the aggregate logs from the minikube bootstrapping

func (*MinikubeClusterManager) PreProviderNotify

func (mkcm *MinikubeClusterManager) PreProviderNotify() []string

PreProviderNotify returns a usage notification about minikube

func (*MinikubeClusterManager) PreflightCheck

func (mkcm *MinikubeClusterManager) PreflightCheck() ([]string, []error)

PreflightCheck ensures minikube is on the system and runable

func (*MinikubeClusterManager) Prepare

Prepare gets the minikube provider ready Nothing to do here for minikube

func (*MinikubeClusterManager) Start

Start attempts to start a stopped minikube cluster. An error is returned when: 1. The cluster is already running. 2. There are issues communicating with minikube. 3. The cluster fails to start.

func (*MinikubeClusterManager) Stop

Stop takes a running minikube cluster and stops the host(s).

type MinikubeConfig

type MinikubeConfig struct {
	Driver string `json:"Driver"`
}

type MinikubeProfile

type MinikubeProfile struct {
	Name   string         `json:"Name"`
	Status string         `json:"Status"`
	Config MinikubeConfig `json:"Config"`
}

type MinikubeProfiles

type MinikubeProfiles struct {
	Invalid []MinikubeProfile `json:"invalid"`
	Valid   []MinikubeProfile `json:"valid"`
}

type NoopClusterManager

type NoopClusterManager struct{}

func NewNoopClusterManager

func NewNoopClusterManager() *NoopClusterManager

NewNoopClusterManager creates a new noop cluster manager - intended for use with "none" provider

func (NoopClusterManager) Create

Create will create a new KubernetesCluster that points to the default

func (NoopClusterManager) Delete

Delete for noop does nothing since these clusters have no provider and are not lifecycled

func (NoopClusterManager) Get

func (ncm NoopClusterManager) Get(clusterName string) (*KubernetesCluster, error)

Get retrieves cluster information or return an error indicating a problem.

func (NoopClusterManager) PostProviderNotify

func (ncm NoopClusterManager) PostProviderNotify() []string

PostProviderNotify is a noop. Nothing to log about for the noop provider

func (NoopClusterManager) PreProviderNotify

func (ncm NoopClusterManager) PreProviderNotify() []string

PreProviderNotify is a noop. Nothing to notify about for the noop provider

func (NoopClusterManager) PreflightCheck

func (ncm NoopClusterManager) PreflightCheck() ([]string, []error)

PreflightCheck performs any pre-checks that can find issues up front that would cause problems for cluster creation.

func (NoopClusterManager) Prepare

Prepare doesn't perform any preparation steps before cluster creation.

func (NoopClusterManager) Start

Start returns an error letting the client know we cannot start a Noop cluster.

func (NoopClusterManager) Stop

Stop returns an error letting the client know we cannot stop a Noop cluster.

Jump to

Keyboard shortcuts

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