k3s

package
v0.0.0-...-29e2100 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

k3s provides functions to install and delete a k3s cluster on an existing node as well as joining additional agents to an existing cluster. This package is heavily inspired by github.com/alexellis/k3sup (some code snippets are also copied).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequiredProperty = errors.New("property is required")
	ErrOutputOnly       = errors.New("property is only for output")
)

Functions

func DeleteCluster

func DeleteCluster(cluster *Cluster) error

func MakeOrUpdateCluster

func MakeOrUpdateCluster(name string, cluster *Cluster) error

Types

type CRIConfig

type CRIConfig struct {
	EnableGVisor bool `json:"enableGVisor,omitempty"`
}

type Cluster

type Cluster struct {
	MasterNodes   []Node               `json:"masterNodes,omitempty"`
	Agents        []Node               `json:"agents,omitempty"`
	KubeConfig    string               `json:"kubeconfig,omitempty"`
	VersionConfig VersionConfiguration `json:"versionConfig,omitempty"`
}

func (Cluster) Validate

func (c Cluster) Validate() error

TODO: add version validation (only last 3 versions are supported because of containerd.toml)

type K8sClient

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

func (*K8sClient) CreateOrUpdateFromFile

func (k *K8sClient) CreateOrUpdateFromFile(ctx context.Context, fileBytes []byte) error

func (*K8sClient) DeleteIfExistsFromFile

func (k *K8sClient) DeleteIfExistsFromFile(ctx context.Context, fileBytes []byte) error

type Node

type Node struct {
	Host       string `json:"host,omitempty"`
	User       string `json:"user,omitempty"`
	PrivateKey string `json:"privateKey,omitempty"`
	// Args define CLI arguments for k3s server or k3s agent respectively.
	// The passed args won't be validated and just passed to the installation instructions of the node.
	// An example value for the master node would look like []string{"--disable=traefik"}.
	Args      []string  `json:"args,omitempty"`
	CRIConfig CRIConfig `json:"criConfig,omitempty"`
}

func (Node) Validate

func (n Node) Validate() error

type RemoteExecutor

type RemoteExecutor struct {
	FileHandler *sftp.Client
	CmdHandler  *sshexec.Client
	// contains filtered or unexported fields
}

func NewExecutorForNode

func NewExecutorForNode(node Node, useSudo bool) (*RemoteExecutor, error)

func NewRemoteExecutor

func NewRemoteExecutor(addr, user string, sshkeyPEM []byte, useSudo bool) (*RemoteExecutor, error)

func (*RemoteExecutor) CombinedOutput

func (e *RemoteExecutor) CombinedOutput(cmd string) (string, error)

func (*RemoteExecutor) CopyFile

func (e *RemoteExecutor) CopyFile(fileReader io.Reader, dest string) error

func (*RemoteExecutor) ExecuteScript

func (e *RemoteExecutor) ExecuteScript(script []byte) error

func (*RemoteExecutor) Output

func (e *RemoteExecutor) Output(cmd string) (string, error)

func (*RemoteExecutor) SudoCombinedOutput

func (e *RemoteExecutor) SudoCombinedOutput(cmd string) (string, error)

func (*RemoteExecutor) SudoOutput

func (e *RemoteExecutor) SudoOutput(cmd string) (string, error)

type ResettableRESTMapper

type ResettableRESTMapper interface {
	meta.RESTMapper
	Reset()
}

TODO: replace with meta.ResettableRESTMapper as soon as available (currently only in master)

type VersionConfiguration

type VersionConfiguration struct {
	Channel string `json:"channel,omitempty"`
	Version string `json:"version,omitempty"`
}

VersionConfiguration resembles a K3s version. This can either be a release channel or a static version. If both are set the defined version will be preferred. Available channels can be found at: https://rancher.com/docs/k3s/latest/en/upgrades/basic/#release-channels An autoupdate configuration will automatically be added. For more information look here: https://rancher.com/docs/k3s/latest/en/upgrades/automated/ If none is set stable channel will be used.

func (VersionConfiguration) EnvSetting

func (v VersionConfiguration) EnvSetting() string

func (VersionConfiguration) YAMLValue

func (v VersionConfiguration) YAMLValue() string

Jump to

Keyboard shortcuts

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