runtime

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RawClusterConfigName    = "kwok.yaml"
	InHostKubeconfigName    = "kubeconfig.yaml"
	InClusterKubeconfigName = "kubeconfig"
	EtcdDataDirName         = "etcd"
	PkiName                 = "pki"
	ComposeName             = "docker-compose.yaml"
	Prometheus              = "prometheus.yaml"
	KindName                = "kind.yaml"
	KwokDeploy              = "kwok-controller-deployment.yaml"
	PrometheusDeploy        = "prometheus-deployment.yaml"
	AuditPolicyName         = "audit.yaml"
	AuditLogName            = "audit.log"
)
View Source
var DefaultRegistry = NewRegistry()

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, logger logger.Logger) (Runtime, error)

type Cluster

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

func NewCluster

func NewCluster(name, workdir string, logger logger.Logger) *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 (c *Cluster) Config() (Config, error)

func (*Cluster) InHostKubeconfig

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

func (*Cluster) Init

func (c *Cluster) Init(ctx context.Context, conf Config) error

func (*Cluster) Install

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

func (*Cluster) Kubectl

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

func (*Cluster) KubectlInCluster

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

func (*Cluster) Load

func (c *Cluster) Load() (conf Config, err error)

func (*Cluster) Logger

func (c *Cluster) Logger() logger.Logger

func (*Cluster) Ready

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

func (*Cluster) Uninstall

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

func (*Cluster) Update

func (c *Cluster) Update(ctx context.Context, conf Config) error

func (*Cluster) WaitReady

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

type Config

type Config struct {
	Name                      string `json:"name,omitempty"`
	Workdir                   string `json:"workdir,omitempty"`
	Runtime                   string `json:"runtime,omitempty"`
	EtcdPort                  uint32 `json:"etcd_port,omitempty"`
	EtcdPeerPort              uint32 `json:"etcd_peer_port,omitempty"`
	KubeApiserverPort         uint32 `json:"kube_apiserver_port,omitempty"`
	KubeControllerManagerPort uint32 `json:"kube_controller_manager_port,omitempty"`
	KubeSchedulerPort         uint32 `json:"kube_scheduler_port,omitempty"`
	KwokControllerPort        uint32 `json:"kwok_controller_port,omitempty"`
	PrometheusPort            uint32 `json:"prometheus_port,omitempty"`

	// For docker-compose
	EtcdImage                  string `json:"etcd_image,omitempty"`
	KubeApiserverImage         string `json:"kube_apiserver_image,omitempty"`
	KubeControllerManagerImage string `json:"kube_controller_manager_image,omitempty"`
	KubeSchedulerImage         string `json:"kube_scheduler_image,omitempty"`
	KwokControllerImage        string `json:"kwok_controller_image,omitempty"`
	PrometheusImage            string `json:"prometheus_image,omitempty"`

	// For kind
	KindNodeImage string `json:"kind_node_image,omitempty"`

	// For binary
	KubeApiserverBinary         string `json:"kube_apiserver_binary,omitempty"`
	KubeControllerManagerBinary string `json:"kube_controller_manager_binary,omitempty"`
	KubeSchedulerBinary         string `json:"kube_scheduler_binary,omitempty"`
	KwokControllerBinary        string `json:"kwok_controller_binary,omitempty"`
	EtcdBinary                  string `json:"etcd_binary,omitempty"`
	EtcdBinaryTar               string `json:"etcd_binary_tar,omitempty"`
	PrometheusBinary            string `json:"prometheus_binary,omitempty"`
	PrometheusBinaryTar         string `json:"prometheus_binary_tar,omitempty"`

	// Cache directory
	CacheDir string `json:"cache_dir,omitempty"`

	// For docker-compose and binary
	SecretPort bool `json:"secret_port,omitempty"`

	// Pull image
	QuietPull bool `json:"quiet_pull,omitempty"`

	// Feature gates of Kubernetes
	FeatureGates string `json:"kube_feature_gates,omitempty"`

	// For audit log
	AuditPolicy string `json:"audit_policy,omitempty"`

	// Runtime config of Kubernetes
	RuntimeConfig string `json:"kube_runtime_config,omitempty"`
}

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(name, workdir string, logger logger.Logger) (Runtime, error)

Load a runtime

func (*Registry) Register

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

Register a runtime

type Runtime

type Runtime interface {
	// Init the config of cluster
	Init(ctx context.Context, conf Config) error

	// Config return the config of cluster
	Config() (Config, 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 start a container
	Start(ctx context.Context, name string) error

	// Stop stop a container
	Stop(ctx context.Context, name string) 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 utils.IOStreams, args ...string) error

	// KubectlInCluster command in cluster
	KubectlInCluster(ctx context.Context, stm utils.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, actual bool) ([]string, error)

	// ListImages list images in the cluster
	ListImages(ctx context.Context, actual bool) ([]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

Jump to

Keyboard shortcuts

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