infradriver

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DelSymbol   = "-"
	EqualSymbol = "="
	ColonSymbol = ":"
)

Variables

This section is empty.

Functions

func DeleteTaint added in v0.10.0

func DeleteTaint(taints []k8sv1.Taint, taintToDelete *k8sv1.Taint) ([]k8sv1.Taint, bool)

DeleteTaint removes all the taints that have the same key and effect to given taintToDelete.

func DeleteTaintsByKey added in v0.10.0

func DeleteTaintsByKey(taints []k8sv1.Taint, taintKey string) ([]k8sv1.Taint, bool)

DeleteTaintsByKey removes all the taints that have the same key to given taintKey

Types

type InfraDriver

type InfraDriver interface {
	// GetHostTaints GetHostTaint return host taint
	GetHostTaints(host net.IP) []k8sv1.Taint

	GetHostIPList() []net.IP

	GetHostIPListByRole(role string) []net.IP

	GetRoleListByHostIP(ip string) []string

	GetHostsPlatform(hosts []net.IP) (map[v1.Platform][]net.IP, error)

	//GetHostEnv return merged env with host env and cluster env.
	GetHostEnv(host net.IP) map[string]string

	//GetHostLabels return host labels.
	GetHostLabels(host net.IP) map[string]string

	//GetClusterEnv return cluster.spec.env as map[string]interface{}
	GetClusterEnv() map[string]string

	AddClusterEnv(envs []string)

	//GetClusterName ${clusterName}
	GetClusterName() string

	//GetClusterImageName ${cluster image Name}
	GetClusterImageName() string

	//GetClusterLaunchCmds ${user-defined launch command}
	GetClusterLaunchCmds() []string

	//GetClusterLaunchApps ${user-defined launch apps}
	GetClusterLaunchApps() []string

	//GetClusterRootfsPath /var/lib/sealer/data/${clusterName}/rootfs
	GetClusterRootfsPath() string

	// GetClusterBasePath /var/lib/sealer/data/${clusterName}
	GetClusterBasePath() string

	// Execute use eg.Go to execute shell cmd concurrently
	Execute(hosts []net.IP, f func(host net.IP) error) error

	// Copy local files to remote host
	// scp -r /tmp root@192.168.0.2:/root/tmp => Copy("192.168.0.2","tmp","/root/tmp")
	// need check md5sum
	Copy(host net.IP, localFilePath, remoteFilePath string) error
	// CopyR copy remote host files to localhost
	CopyR(host net.IP, remoteFilePath, localFilePath string) error
	// CmdAsync exec command on remote host, and asynchronous return logs
	CmdAsync(host net.IP, env map[string]string, cmd ...string) error
	// Cmd exec command on remote host, and return combined standard output and standard error
	Cmd(host net.IP, env map[string]string, cmd string) ([]byte, error)
	// CmdToString exec command on remote host, and return spilt standard output and standard error
	CmdToString(host net.IP, env map[string]string, cmd, spilt string) (string, error)

	// IsFileExist check remote file exist or not
	IsFileExist(host net.IP, remoteFilePath string) (bool, error)
	// IsDirExist Remote file existence returns true, nil
	IsDirExist(host net.IP, remoteDirPath string) (bool, error)

	// GetPlatform Get remote platform
	GetPlatform(host net.IP) (v1.Platform, error)

	GetHostName(host net.IP) (string, error)
	// Ping Ping remote host
	Ping(host net.IP) error
	// SetHostName add or update host name on host
	SetHostName(host net.IP, hostName string) error

	//SetClusterHostAliases set additional HostAliases
	SetClusterHostAliases(hosts []net.IP) error

	//DeleteClusterHostAliases delete additional HostAliases
	DeleteClusterHostAliases(hosts []net.IP) error

	GetClusterRegistry() v2.Registry
}

InfraDriver treat the entire cluster as an operating system kernel, interface function here is the target system call.

func NewInfraDriver

func NewInfraDriver(cluster *v2.Cluster) (InfraDriver, error)

NewInfraDriver will create a new Infra driver, and if extraEnv specified, it will set env not exist in Cluster

type SSHInfraDriver

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

func (*SSHInfraDriver) AddClusterEnv

func (d *SSHInfraDriver) AddClusterEnv(envs []string)

func (*SSHInfraDriver) Cmd

func (d *SSHInfraDriver) Cmd(host net.IP, env map[string]string, cmd string) ([]byte, error)

func (*SSHInfraDriver) CmdAsync

func (d *SSHInfraDriver) CmdAsync(host net.IP, env map[string]string, cmd ...string) error

func (*SSHInfraDriver) CmdToString

func (d *SSHInfraDriver) CmdToString(host net.IP, env map[string]string, cmd, spilt string) (string, error)

func (*SSHInfraDriver) Copy

func (d *SSHInfraDriver) Copy(host net.IP, localFilePath, remoteFilePath string) error

func (*SSHInfraDriver) CopyR

func (d *SSHInfraDriver) CopyR(host net.IP, remoteFilePath, localFilePath string) error

func (*SSHInfraDriver) DeleteClusterHostAliases

func (d *SSHInfraDriver) DeleteClusterHostAliases(hosts []net.IP) error

func (*SSHInfraDriver) Execute

func (d *SSHInfraDriver) Execute(hosts []net.IP, f func(host net.IP) error) error

func (*SSHInfraDriver) GetClusterBasePath

func (d *SSHInfraDriver) GetClusterBasePath() string

func (*SSHInfraDriver) GetClusterEnv

func (d *SSHInfraDriver) GetClusterEnv() map[string]string

func (*SSHInfraDriver) GetClusterImageName

func (d *SSHInfraDriver) GetClusterImageName() string

func (*SSHInfraDriver) GetClusterLaunchApps

func (d *SSHInfraDriver) GetClusterLaunchApps() []string

func (*SSHInfraDriver) GetClusterLaunchCmds

func (d *SSHInfraDriver) GetClusterLaunchCmds() []string

func (*SSHInfraDriver) GetClusterName

func (d *SSHInfraDriver) GetClusterName() string

func (*SSHInfraDriver) GetClusterRegistry

func (d *SSHInfraDriver) GetClusterRegistry() v2.Registry

func (*SSHInfraDriver) GetClusterRootfsPath

func (d *SSHInfraDriver) GetClusterRootfsPath() string

func (*SSHInfraDriver) GetHostEnv

func (d *SSHInfraDriver) GetHostEnv(host net.IP) map[string]string

func (*SSHInfraDriver) GetHostIPList

func (d *SSHInfraDriver) GetHostIPList() []net.IP

func (*SSHInfraDriver) GetHostIPListByRole

func (d *SSHInfraDriver) GetHostIPListByRole(role string) []net.IP

func (*SSHInfraDriver) GetHostLabels

func (d *SSHInfraDriver) GetHostLabels(host net.IP) map[string]string

func (*SSHInfraDriver) GetHostName

func (d *SSHInfraDriver) GetHostName(hostIP net.IP) (string, error)

func (*SSHInfraDriver) GetHostTaints

func (d *SSHInfraDriver) GetHostTaints(host net.IP) []k8sv1.Taint

func (*SSHInfraDriver) GetHostsPlatform

func (d *SSHInfraDriver) GetHostsPlatform(hosts []net.IP) (map[v1.Platform][]net.IP, error)

func (*SSHInfraDriver) GetPlatform

func (d *SSHInfraDriver) GetPlatform(host net.IP) (v1.Platform, error)

func (*SSHInfraDriver) GetRoleListByHostIP

func (d *SSHInfraDriver) GetRoleListByHostIP(ip string) []string

func (*SSHInfraDriver) IsDirExist

func (d *SSHInfraDriver) IsDirExist(host net.IP, remoteDirPath string) (bool, error)

func (*SSHInfraDriver) IsFileExist

func (d *SSHInfraDriver) IsFileExist(host net.IP, remoteFilePath string) (bool, error)

func (*SSHInfraDriver) Ping

func (d *SSHInfraDriver) Ping(host net.IP) error

func (*SSHInfraDriver) SetClusterHostAliases

func (d *SSHInfraDriver) SetClusterHostAliases(hosts []net.IP) error

func (*SSHInfraDriver) SetHostName

func (d *SSHInfraDriver) SetHostName(host net.IP, hostName string) error

Jump to

Keyboard shortcuts

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