bootstrapper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BootstrapperTypeKubeadm is the kubeadm bootstrapper type
	BootstrapperTypeKubeadm = "kubeadm"
)

Variables

This section is empty.

Functions

func GetCachedImageList added in v0.22.2

func GetCachedImageList(imageRepository string, version string, bootstrapper string) []string

GetCachedImageList returns the list of images for a version

func SetupCerts

func SetupCerts(cmd CommandRunner, k8s config.KubernetesConfig) error

SetupCerts gets the generated credentials required to talk to the APIServer.

Types

type Bootstrapper

type Bootstrapper interface {
	// PullImages pulls images necessary for a cluster. Success should not be required.
	PullImages(config.KubernetesConfig) error
	StartCluster(config.KubernetesConfig) error
	UpdateCluster(config.KubernetesConfig) error
	RestartCluster(config.KubernetesConfig) error
	DeleteCluster(config.KubernetesConfig) error
	// LogCommands returns a map of log type to a command which will display that log.
	LogCommands(LogOptions) map[string]string
	SetupCerts(cfg config.KubernetesConfig) error
	GetKubeletStatus() (string, error)
	GetAPIServerStatus(net.IP) (string, error)
}

Bootstrapper contains all the methods needed to bootstrap a kubernetes cluster

type CommandRunner

type CommandRunner interface {
	// Run starts the specified command and waits for it to complete.
	Run(cmd string) error

	// CombinedOutputTo runs the command and stores both command
	// output and error to out. A typical usage is:
	//
	//          var b bytes.Buffer
	//          CombinedOutput(cmd, &b)
	//          fmt.Println(b.Bytes())
	//
	// Or, you can set out to os.Stdout, the command output and
	// error would show on your terminal immediately before you
	// cmd exit. This is useful for a long run command such as
	// continuously print running logs.
	CombinedOutputTo(cmd string, out io.Writer) error

	// CombinedOutput runs the command and returns its combined standard
	// output and standard error.
	CombinedOutput(cmd string) (string, error)

	// Copy is a convenience method that runs a command to copy a file
	Copy(assets.CopyableFile) error

	// Remove is a convenience method that runs a command to remove a file
	Remove(assets.CopyableFile) error
}

CommandRunner represents an interface to run commands.

type ExecRunner

type ExecRunner struct{}

ExecRunner runs commands using the os/exec package.

It implements the CommandRunner interface.

func (*ExecRunner) CombinedOutput

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

CombinedOutput runs the command in a bash shell and returns its combined standard output and standard error.

func (*ExecRunner) CombinedOutputTo added in v0.26.0

func (*ExecRunner) CombinedOutputTo(cmd string, out io.Writer) error

CombinedOutputTo runs the command and stores both command output and error to out.

func (*ExecRunner) Copy

Copy copies a file and its permissions

func (*ExecRunner) Remove

func (e *ExecRunner) Remove(f assets.CopyableFile) error

Remove removes a file

func (*ExecRunner) Run

func (*ExecRunner) Run(cmd string) error

Run starts the specified command in a bash shell and waits for it to complete.

type FakeCommandRunner

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

FakeCommandRunner mocks command output without running the Commands

It implements the CommandRunner interface and is used for testing.

func NewFakeCommandRunner

func NewFakeCommandRunner() *FakeCommandRunner

NewFakeCommandRunner returns a new FakeCommandRunner

The expected output of commands should be set with SetCommandToOutput

func (*FakeCommandRunner) CombinedOutput

func (f *FakeCommandRunner) CombinedOutput(cmd string) (string, error)

CombinedOutput returns the set output for a given command text.

func (*FakeCommandRunner) CombinedOutputTo added in v0.26.0

func (f *FakeCommandRunner) CombinedOutputTo(cmd string, out io.Writer) error

CombinedOutputTo runs the command and stores both command output and error to out.

func (*FakeCommandRunner) Copy

Copy adds the filename, file contents key value pair to the stored map.

func (*FakeCommandRunner) DumpMaps

func (f *FakeCommandRunner) DumpMaps(w io.Writer)

DumpMaps prints out the list of stored commands and stored filenames.

func (*FakeCommandRunner) GetFileToContents

func (f *FakeCommandRunner) GetFileToContents(filename string) (string, error)

GetFileToContents stores the file to contents map for the FakeCommandRunner

func (*FakeCommandRunner) Remove

func (f *FakeCommandRunner) Remove(file assets.CopyableFile) error

Remove removes the filename, file contents key value pair from the stored map

func (*FakeCommandRunner) Run

func (f *FakeCommandRunner) Run(cmd string) error

Run returns nil if output has been set for the given command text.

func (*FakeCommandRunner) SetCommandToOutput

func (f *FakeCommandRunner) SetCommandToOutput(cmdToOutput map[string]string)

SetCommandToOutput stores the file to contents map for the FakeCommandRunner

func (*FakeCommandRunner) SetFileToContents

func (f *FakeCommandRunner) SetFileToContents(fileToContents map[string]string)

SetFileToContents stores the file to contents map for the FakeCommandRunner

type LogOptions added in v0.34.0

type LogOptions struct {
	// Lines is the number of recent log lines to include, as in tail -n.
	Lines int
	// Follow is whether or not to actively follow the logs, as in tail -f.
	Follow bool
}

LogOptions are options to be passed to LogCommands

type SSHRunner

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

SSHRunner runs commands through SSH.

It implements the CommandRunner interface.

func NewSSHRunner

func NewSSHRunner(c *ssh.Client) *SSHRunner

NewSSHRunner returns a new SSHRunner that will run commands through the ssh.Client provided.

func (*SSHRunner) CombinedOutput

func (s *SSHRunner) CombinedOutput(cmd string) (string, error)

CombinedOutput runs the command on the remote and returns its combined standard output and standard error.

func (*SSHRunner) CombinedOutputTo added in v0.26.0

func (s *SSHRunner) CombinedOutputTo(cmd string, w io.Writer) error

CombinedOutputTo runs the command and stores both command output and error to out.

func (*SSHRunner) Copy

func (s *SSHRunner) Copy(f assets.CopyableFile) error

Copy copies a file to the remote over SSH.

func (*SSHRunner) Remove

func (s *SSHRunner) Remove(f assets.CopyableFile) error

Remove runs a command to delete a file on the remote.

func (*SSHRunner) Run

func (s *SSHRunner) Run(cmd string) error

Run starts a command on the remote and waits for it to return.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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