runtime

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 24 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"
)

The following functions are used to get the path of the cluster

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry is the default registry

View Source
var (
	// ErrComponentNotFound is returned when a component is not found
	ErrComponentNotFound = fmt.Errorf("component not found")
)

Functions

func ExpandVolumesHostPaths added in v0.2.0

func ExpandVolumesHostPaths(volumes []internalversion.Volume) ([]internalversion.Volume, error)

ExpandVolumesHostPaths expands relative paths specified in volumes to absolute paths

func GetComponentPatches added in v0.2.0

func GetComponentPatches(conf *internalversion.KwokctlConfiguration, componentName string) internalversion.ComponentPatches

GetComponentPatches returns the patches for a component.

func GetLogVolumes added in v0.2.0

func GetLogVolumes(ctx context.Context) ([]internalversion.Volume, error)

GetLogVolumes returns volumes for Logs and ClusterLogs resource.

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)

BuildRuntime is a function to build a runtime

type Cluster

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

Cluster is the cluster

func NewCluster

func NewCluster(name, workdir string) *Cluster

NewCluster creates a new cluster

func (*Cluster) AuditLogs

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

AuditLogs returns the audit logs of the cluster.

func (*Cluster) AuditLogsFollow

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

AuditLogsFollow follows the audit logs of the cluster.

func (*Cluster) Config

Config returns the cluster config

func (*Cluster) GetBinPath added in v0.1.0

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

GetBinPath returns the path to the given binary name.

func (*Cluster) GetComponent added in v0.1.0

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

GetComponent returns the component by name

func (*Cluster) GetLogPath added in v0.1.0

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

GetLogPath returns the path of the given log name.

func (*Cluster) GetWorkdirPath added in v0.1.0

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

GetWorkdirPath returns the path to the file in the workdir.

func (*Cluster) Install

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

Install installs the cluster

func (*Cluster) Kubectl

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

Kubectl runs kubectl.

func (*Cluster) KubectlInCluster

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

KubectlInCluster runs kubectl in the cluster.

func (*Cluster) Load

Load loads the cluster config

func (*Cluster) Name added in v0.1.0

func (c *Cluster) Name() string

Name returns the cluster name

func (*Cluster) Ready

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

Ready returns true if the cluster is ready

func (*Cluster) Save added in v0.1.0

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

Save saves the cluster config

func (*Cluster) SetConfig added in v0.1.0

SetConfig sets the cluster config

func (*Cluster) SnapshotRestoreWithYAML added in v0.2.0

func (c *Cluster) SnapshotRestoreWithYAML(ctx context.Context, path string, filters []string) error

SnapshotRestoreWithYAML restore the snapshot of cluster

func (*Cluster) SnapshotSaveWithYAML added in v0.2.0

func (c *Cluster) SnapshotSaveWithYAML(ctx context.Context, path string, filters []string) error

SnapshotSaveWithYAML save the snapshot of cluster

func (*Cluster) Uninstall

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

Uninstall uninstalls the cluster.

func (*Cluster) WaitReady

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

WaitReady waits for the cluster to be ready.

func (*Cluster) Workdir added in v0.1.0

func (c *Cluster) Workdir() string

Workdir returns the cluster workdir

type Registry

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

Registry is a registry of runtime

func NewRegistry

func NewRegistry() *Registry

NewRegistry create a new 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 {
	// Available checks whether the runtime is available.
	Available(ctx context.Context) error

	// 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

	// AddContext add the context of cluster to kubeconfig
	AddContext(ctx context.Context, kubeconfigPath string) error

	// RemoveContext remove the context of cluster from kubeconfig
	RemoveContext(ctx context.Context, kubeconfigPath string) error

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

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

	// EtcdctlInCluster command in cluster
	EtcdctlInCluster(ctx context.Context, 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

	// SnapshotSaveWithYAML save the snapshot of cluster
	SnapshotSaveWithYAML(ctx context.Context, path string, filters []string) error

	// SnapshotRestoreWithYAML restore the snapshot of cluster
	SnapshotRestoreWithYAML(ctx context.Context, path string, filters []string) error
}

Runtime is the interface for a runtime.

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.
Package kind implements the runtime.Runtime interface using the kind.
Package kind implements the runtime.Runtime interface using the kind.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳