runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Overview

Package runtime defines the interface of a cluster operation and providers a register method.

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigName              = consts.ConfigName
	InHostKubeconfigName    = "kubeconfig.yaml"
	InClusterKubeconfigName = "kubeconfig"
	EtcdDataDirName         = "etcd"
	PkiName                 = "pki"
	ComposeName             = "docker-compose.yaml"
	Prometheus              = "prometheus.yaml"
	KindName                = "kind.yaml"
	KwokPod                 = "kwok-controller-pod.yaml"
	PrometheusDeploy        = "prometheus-deployment.yaml"
	AuditPolicyName         = "audit.yaml"
	AuditLogName            = "audit.log"
	SchedulerConfigName     = "scheduler.yaml"
)
View Source
var DefaultRegistry = NewRegistry()
View Source
var (
	ErrComponentNotFound = fmt.Errorf("component not found")
)

Functions

func ListClusters

func ListClusters(workdir string) ([]string, error)

ListClusters returns the list of clusters in the directory

Types

type BuildRuntime

type BuildRuntime func(name, workdir string) (Runtime, error)

type Cluster

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

func NewCluster

func NewCluster(name, workdir string) *Cluster

func (*Cluster) AuditLogs

func (c *Cluster) AuditLogs(ctx context.Context, out io.Writer) error

func (*Cluster) AuditLogsFollow

func (c *Cluster) AuditLogsFollow(ctx context.Context, out io.Writer) error

func (*Cluster) Config

func (*Cluster) GetBinPath added in v0.1.0

func (c *Cluster) GetBinPath(name string) string

func (*Cluster) GetComponent added in v0.1.0

func (c *Cluster) GetComponent(ctx context.Context, name string) (internalversion.Component, error)

func (*Cluster) GetLogPath added in v0.1.0

func (c *Cluster) GetLogPath(name string) string

func (*Cluster) GetWorkdirPath added in v0.1.0

func (c *Cluster) GetWorkdirPath(name string) string

func (*Cluster) InHostKubeconfig

func (c *Cluster) InHostKubeconfig() (string, error)

func (*Cluster) Install

func (c *Cluster) Install(ctx context.Context) error

func (*Cluster) Kubectl

func (c *Cluster) Kubectl(ctx context.Context, stm exec.IOStreams, args ...string) error

func (*Cluster) KubectlInCluster

func (c *Cluster) KubectlInCluster(ctx context.Context, stm exec.IOStreams, args ...string) error

func (*Cluster) Load

func (*Cluster) Name added in v0.1.0

func (c *Cluster) Name() string

func (*Cluster) Ready

func (c *Cluster) Ready(ctx context.Context) (bool, error)

func (*Cluster) Save added in v0.1.0

func (c *Cluster) Save(ctx context.Context) error

func (*Cluster) SetConfig added in v0.1.0

func (*Cluster) Uninstall

func (c *Cluster) Uninstall(ctx context.Context) error

func (*Cluster) WaitReady

func (c *Cluster) WaitReady(ctx context.Context, timeout time.Duration) error

func (*Cluster) Workdir added in v0.1.0

func (c *Cluster) Workdir() string

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Get

func (r *Registry) Get(name string) (BuildRuntime, bool)

Get a runtime

func (*Registry) List

func (r *Registry) List() []string

List all registered runtime

func (*Registry) Load

func (r *Registry) Load(ctx context.Context, name, workdir string) (Runtime, error)

Load a runtime

func (*Registry) Register

func (r *Registry) Register(name string, buildRuntime BuildRuntime)

Register a runtime

type Runtime

type Runtime interface {
	// SetConfig sets the config of cluster
	SetConfig(ctx context.Context, conf *internalversion.KwokctlConfiguration) error

	// Save the config of cluster
	Save(ctx context.Context) error

	// Config return the config of cluster
	Config(ctx context.Context) (*internalversion.KwokctlConfiguration, error)

	// Install the cluster
	Install(ctx context.Context) error

	// Uninstall the cluster
	Uninstall(ctx context.Context) error

	// Up start the cluster
	Up(ctx context.Context) error

	// Down stop the cluster
	Down(ctx context.Context) error

	// Start a cluster
	Start(ctx context.Context) error

	// Stop a cluster
	Stop(ctx context.Context) error

	// StartComponent start cluster component
	StartComponent(ctx context.Context, name string) error

	// StopComponent stop cluster component
	StopComponent(ctx context.Context, name string) error

	// GetComponent return the component if it exists
	GetComponent(ctx context.Context, name string) (internalversion.Component, error)

	// Ready check the cluster is ready
	Ready(ctx context.Context) (bool, error)

	// WaitReady wait the cluster is ready
	WaitReady(ctx context.Context, timeout time.Duration) error

	// InHostKubeconfig return the kubeconfig in host
	InHostKubeconfig() (string, error)

	// Kubectl command
	Kubectl(ctx context.Context, stm exec.IOStreams, args ...string) error

	// KubectlInCluster command in cluster
	KubectlInCluster(ctx context.Context, stm exec.IOStreams, args ...string) error

	// EtcdctlInCluster command in cluster
	EtcdctlInCluster(ctx context.Context, stm exec.IOStreams, args ...string) error

	// Logs logs of a component
	Logs(ctx context.Context, name string, out io.Writer) error

	// LogsFollow follow logs of a component with follow
	LogsFollow(ctx context.Context, name string, out io.Writer) error

	// AuditLogs audit logs of apiserver
	AuditLogs(ctx context.Context, out io.Writer) error

	// AuditLogsFollow follow audit logs of apiserver
	AuditLogsFollow(ctx context.Context, out io.Writer) error

	// ListBinaries list binaries in the cluster
	ListBinaries(ctx context.Context) ([]string, error)

	// ListImages list images in the cluster
	ListImages(ctx context.Context) ([]string, error)

	// SnapshotSave save the snapshot of cluster
	SnapshotSave(ctx context.Context, path string) error

	// SnapshotRestore restore the snapshot of cluster
	SnapshotRestore(ctx context.Context, path string) error
}

Directories

Path Synopsis
Package binary implements the runtime.Runtime interface using the binaries.
Package binary implements the runtime.Runtime interface using the binaries.
Package compose implements the runtime.Runtime interface using the image with compose file.
Package compose implements the runtime.Runtime interface using the image with compose file.

Jump to

Keyboard shortcuts

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