cluster

package
v1.2.2-rc3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KindClusterKind     = "kind"
	ExistingClusterKind = "unknown"
)
View Source
const (
	DefaultControlPlanes = 1
	DefaultWorkers       = 3
)

Variables

This section is empty.

Functions

func GetConfig

func GetConfig() (clientcmd.ClientConfig, error)

GetConfig creates a clientcmd.ClientConfig for talking to a Kubernetes API server, the config precedence is as below: 1. KUBECONFIG environment variable pointing at files 2. $HOME/.kube/config if exists 3. In-cluster config if running in cluster

func Stop

func Stop(output io.Writer) error

Stop stops a test environment and redirects Stdout/Stderr to output if "KEEP_TESTING_CLUSTER" is not "true" and "USE_EXISTING_CLUSTER" is not "true".

Types

type Cluster

type Cluster interface {
	fmt.Stringer

	// GetKind returns the kind of cluster.
	GetKind() string

	// Startup runs a cluster.
	Startup(output io.Writer) error

	// Load images into a cluster.
	LoadImages(output io.Writer) error

	// Cleanup closes the cluster.
	Cleanup(output io.Writer) error
}

Cluster defines the basic actions of a cluster handler.

func GetExistCluster

func GetExistCluster() Cluster

GetExistCluster returns the exist cluster from environment,

func NewLocalCluster

func NewLocalCluster() Cluster

NewLocalCluster returns the local cluster from environment, the default runtime is based on kubernetes-sigs/kind.

func Start

func Start(output io.Writer) (clientcmd.ClientConfig, Cluster, error)

Start starts a test environment and redirects Stdout/Stderr to output if "USE_EXISTING_CLUSTER" is not "true".

type ExistingCluster

type ExistingCluster struct {
}

ExistingCluster is a cluster which provided by kubeConfig, so It's kind is unknown.

func (*ExistingCluster) Cleanup

func (e *ExistingCluster) Cleanup(output io.Writer) error

func (*ExistingCluster) GetKind

func (e *ExistingCluster) GetKind() string

func (*ExistingCluster) LoadImages added in v0.3.0

func (e *ExistingCluster) LoadImages(output io.Writer) error

func (*ExistingCluster) Startup

func (e *ExistingCluster) Startup(output io.Writer) error

func (*ExistingCluster) String

func (e *ExistingCluster) String() string

type LocalKindCluster

type LocalKindCluster struct {
	// Specify the exported ingress http port for running cluster,
	// configure in "KIND_EXPORT_INGRESS_HTTP_PORT" env,
	// default is created randomly.
	ExportIngressHTTPPort int
	// Specify the exported ingress https port for running cluster,
	// configure in "KIND_EXPORT_INGRESS_HTTPS_PORT" env,
	// default is created randomly.
	ExportIngressHTTPSPort int
	// Specify the exported image storage port for running cluster,
	// configure in "KIND_EXPORT_IMAGE_STORAGE_PORT" env,
	// default is created randomly.
	ExportImageStoragePort int
	// Specify the image for running cluster,
	// configure in "KIND_IMAGE" env,
	// default is "kindest/node:v1.18.2".
	Image string
	// Specify the image mirror,
	// configure in "KIND_IMAGE_MIRROR" env,
	// default is "".
	ImageMirror string
	// Specify the name of cluster,
	// configure in "KIND_CLUSTER_NAME" env,
	// default is "harvester".
	ClusterName string
	// Specify the amount of control-plane nodes,
	// configure in "KIND_CONTROL_PLANES" env,
	// default is "1".
	ControlPlanes int
	// Specify the amount of worker nodes,
	// configure in "KIND_WORKERS" env,
	// default is "3".
	Workers int
	// Specify the wait timeout for bringing up cluster,
	// configure in "KIND_WAIT_TIMEOUT" env,
	// default is "10m".
	WaitTimeout time.Duration
	// Specify the path of preset cluster configuration,
	// configure in "KIND_CLUSTER_CONFIG_PATH" env.
	ClusterConfigPath string
}

LocalKindCluster specifies the configurable parameters to launch a local kubernetes-sigs/kind cluster.

func NewLocalKindCluster

func NewLocalKindCluster() *LocalKindCluster

func (LocalKindCluster) Cleanup

func (c LocalKindCluster) Cleanup(output io.Writer) error

func (LocalKindCluster) GetKind

func (c LocalKindCluster) GetKind() string

func (LocalKindCluster) LoadImages added in v0.3.0

func (c LocalKindCluster) LoadImages(output io.Writer) error

func (*LocalKindCluster) Startup

func (c *LocalKindCluster) Startup(output io.Writer) error

func (LocalKindCluster) String

func (c LocalKindCluster) String() string

Jump to

Keyboard shortcuts

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