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
- type KindClusterManager
- func (kcm *KindClusterManager) Create(c *config.UnmanagedClusterConfig) (*KubernetesCluster, error)
- func (kcm *KindClusterManager) Delete(c *config.UnmanagedClusterConfig) error
- func (kcm *KindClusterManager) Get(clusterName string) (*KubernetesCluster, error)
- func (kcm *KindClusterManager) PostProviderNotify() []string
- func (kcm *KindClusterManager) PreProviderNotify() []string
- func (kcm *KindClusterManager) PreflightCheck() ([]string, []error)
- func (kcm *KindClusterManager) Prepare(c *config.UnmanagedClusterConfig) error
- func (kcm *KindClusterManager) Start(c *config.UnmanagedClusterConfig) error
- func (kcm *KindClusterManager) Stop(c *config.UnmanagedClusterConfig) error
- type KubernetesCluster
- type Manager
- type MinikubeClusterManager
- func (mkcm *MinikubeClusterManager) Create(c *config.UnmanagedClusterConfig) (*KubernetesCluster, error)
- func (mkcm *MinikubeClusterManager) Delete(c *config.UnmanagedClusterConfig) error
- func (mkcm *MinikubeClusterManager) Get(clusterName string) (*KubernetesCluster, error)
- func (mkcm *MinikubeClusterManager) PostProviderNotify() []string
- func (mkcm *MinikubeClusterManager) PreProviderNotify() []string
- func (mkcm *MinikubeClusterManager) PreflightCheck() ([]string, []error)
- func (mkcm *MinikubeClusterManager) Prepare(c *config.UnmanagedClusterConfig) error
- func (mkcm *MinikubeClusterManager) Start(c *config.UnmanagedClusterConfig) error
- func (mkcm *MinikubeClusterManager) Stop(c *config.UnmanagedClusterConfig) error
- type MinikubeConfig
- type MinikubeProfile
- type MinikubeProfiles
- type NoopClusterManager
- func (ncm NoopClusterManager) Create(c *config.UnmanagedClusterConfig) (*KubernetesCluster, error)
- func (ncm NoopClusterManager) Delete(c *config.UnmanagedClusterConfig) error
- func (ncm NoopClusterManager) Get(clusterName string) (*KubernetesCluster, error)
- func (ncm NoopClusterManager) PostProviderNotify() []string
- func (ncm NoopClusterManager) PreProviderNotify() []string
- func (ncm NoopClusterManager) PreflightCheck() ([]string, []error)
- func (ncm NoopClusterManager) Prepare(c *config.UnmanagedClusterConfig) error
- func (ncm NoopClusterManager) Start(c *config.UnmanagedClusterConfig) error
- func (ncm NoopClusterManager) Stop(c *config.UnmanagedClusterConfig) error
Constants ¶
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" )
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 ¶
func (kcm *KindClusterManager) Create(c *config.UnmanagedClusterConfig) (*KubernetesCluster, error)
Create will create a new kind cluster or return an error.
func (*KindClusterManager) Delete ¶
func (kcm *KindClusterManager) Delete(c *config.UnmanagedClusterConfig) error
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 ¶
func (kcm *KindClusterManager) Prepare(c *config.UnmanagedClusterConfig) error
Prepare will fetch a container image to the cluster host.
func (*KindClusterManager) Start ¶
func (kcm *KindClusterManager) Start(c *config.UnmanagedClusterConfig) error
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 ¶
func (kcm *KindClusterManager) Stop(c *config.UnmanagedClusterConfig) error
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 ¶
func (mkcm *MinikubeClusterManager) Create(c *config.UnmanagedClusterConfig) (*KubernetesCluster, error)
Create creates a minikube cluster with a given profile name
func (*MinikubeClusterManager) Delete ¶
func (mkcm *MinikubeClusterManager) Delete(c *config.UnmanagedClusterConfig) error
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 ¶
func (mkcm *MinikubeClusterManager) Prepare(c *config.UnmanagedClusterConfig) error
Prepare gets the minikube provider ready Nothing to do here for minikube
func (*MinikubeClusterManager) Start ¶
func (mkcm *MinikubeClusterManager) Start(c *config.UnmanagedClusterConfig) error
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 ¶
func (mkcm *MinikubeClusterManager) Stop(c *config.UnmanagedClusterConfig) error
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 ¶
func (ncm NoopClusterManager) Create(c *config.UnmanagedClusterConfig) (*KubernetesCluster, error)
Create will create a new KubernetesCluster that points to the default
func (NoopClusterManager) Delete ¶
func (ncm NoopClusterManager) Delete(c *config.UnmanagedClusterConfig) error
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 ¶
func (ncm NoopClusterManager) Prepare(c *config.UnmanagedClusterConfig) error
Prepare doesn't perform any preparation steps before cluster creation.
func (NoopClusterManager) Start ¶
func (ncm NoopClusterManager) Start(c *config.UnmanagedClusterConfig) error
Start returns an error letting the client know we cannot start a Noop cluster.
func (NoopClusterManager) Stop ¶
func (ncm NoopClusterManager) Stop(c *config.UnmanagedClusterConfig) error
Stop returns an error letting the client know we cannot stop a Noop cluster.