util

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 55 Imported by: 4

Documentation

Index

Constants

View Source
const (
	KubeEdgeDownloadURL  = "https://github.com/kubeedge/kubeedge/releases/download"
	EdgeServiceFile      = "edgecore.service"
	CloudServiceFile     = "cloudcore.service"
	ServiceFileURLFormat = "https://raw.githubusercontent.com/kubeedge/kubeedge/release-%s/build/tools/%s"
	KubeEdgeBinaryName   = "edgecore"
	KeadmBinaryName      = "keadm"

	KubeCloudBinaryName = "cloudcore"

	KubeEdgeConfigDir        = KubeEdgePath + "config/"
	KubeEdgeCloudCoreNewYaml = KubeEdgeConfigDir + "cloudcore.yaml"
	KubeEdgeEdgeCoreNewYaml  = KubeEdgeConfigDir + "edgecore.yaml"

	KubeEdgeCrdPath = KubeEdgePath + "crds"

	KubeEdgeCRDDownloadURL = "https://raw.githubusercontent.com/kubeedge/kubeedge/release-%s/build/crds"

	RetryTimes = 5

	APT    string = "apt"
	YUM    string = "yum"
	PACMAN string = "pacman"

	EdgeCoreSELinuxLabel = "system_u:object_r:bin_t:s0"
)

Constants used by installers

View Source
const (
	KubeEdgePath        = "/etc/kubeedge/"
	KubeEdgeBackupPath  = "/etc/kubeedge/backup/"
	KubeEdgeUpgradePath = "/etc/kubeedge/upgrade/"
	KubeEdgeUsrBinPath  = "/usr/local/bin"

	KubeEdgeLogPath = "/var/log/kubeedge/"

	KubeEdgeSocketPath = "/var/lib/kubeedge/"

	EdgeRootDir = "/var/lib/edged"

	SystemdBootPath = "/run/systemd/system"
)

Constants used by installers

Variables

This section is empty.

Functions

func AddToolVals

func AddToolVals(f *pflag.Flag, flagData map[string]types.FlagData)

AddToolVals gets the value and default values of each flags and collects them in temporary cache

func BuildConfig added in v1.2.1

func BuildConfig(kubeConfig, master string) (conf *rest.Config, err error)

BuildConfig builds config from flags

func CheckIfAvailable

func CheckIfAvailable(val, defval string) string

CheckIfAvailable checks is val of a flag is empty then return the default value

func Compress added in v1.5.0

func Compress(tarName string, paths []string) error

func DecompressTarGz added in v1.16.0

func DecompressTarGz(gzFilePath, dest string) error

func ExecShellFilter added in v1.5.0

func ExecShellFilter(c string) (string, error)

ExecShellFilter executes shell script and filter

func FileExists added in v1.5.0

func FileExists(path string) bool

func GetCurrentVersion added in v1.11.0

func GetCurrentVersion(version string) (string, error)

func GetHelmVersion added in v1.12.4

func GetHelmVersion(version string, retryTimes int) string

GetHelmVersion returns the verified version of Helm. If the verification fails, obtain the remote version first and then use the default value

func GetLatestVersion added in v1.2.1

func GetLatestVersion() (string, error)

GetLatestVersion return the latest non-prerelease, non-draft version of kubeedge in releases

func GetOSInterface

func GetOSInterface() types.OSTypeInstaller

GetOSInterface helps in returning OS specific object which implements OSTypeInstaller interface.

func GetPackageManager added in v1.6.0

func GetPackageManager() string

GetPackageManager get package manager of OS

func HasSystemd added in v1.10.0

func HasSystemd() bool

HasSystemd checks if systemd exist. if command run failed, then check it by sd_booted.

func InstallNSSM added in v1.16.0

func InstallNSSM() error

func InstallNSSMService added in v1.16.0

func InstallNSSMService(name, path string, args ...string) error

func IsCloudcoreContainerRunning added in v1.10.0

func IsCloudcoreContainerRunning(ns, kubeConfigPath string) (bool, error)

IsCloudcoreContainerRunning judge whether cloudcore pod is running

func IsKubeEdgeProcessRunning added in v1.10.0

func IsKubeEdgeProcessRunning(proc string) (bool, error)

IsKubeEdgeProcessRunning checks if the given process is running or not

func IsNSSMInstalled added in v1.16.0

func IsNSSMInstalled() bool

func IsNSSMServiceExist added in v1.16.0

func IsNSSMServiceExist(service string) bool

func IsNSSMServiceRunning added in v1.16.0

func IsNSSMServiceRunning(service string) bool

func KillKubeEdgeBinary added in v1.12.0

func KillKubeEdgeBinary(proc string) error

KillKubeEdgeBinary will search for KubeEdge process and forcefully kill it

func KubeClient added in v1.4.0

func KubeClient(kubeConfigPath string) (*kubernetes.Clientset, error)

KubeClient from config

func ParseEdgecoreConfig added in v1.5.0

func ParseEdgecoreConfig(edgecorePath string) (*v1alpha2.EdgeCoreConfig, error)

func PrintFail added in v1.5.0

func PrintFail(cmd string, s string)

PrintFail prints fail

func PrintSucceed added in v1.6.0

func PrintSucceed(cmd string, s string)

PrintSucceed prints success

func ReportTaskResult added in v1.16.0

func ReportTaskResult(config *v1alpha2.EdgeCoreConfig, taskType, taskID string, event fsm.Event) error

func RunningModule added in v1.6.0

func RunningModule() (types.ModuleRunning, error)

RunningModule identifies cloudcore/edgecore running or not.

func RunningModuleV2 added in v1.10.0

func RunningModuleV2(opt *types.ResetOptions) types.ModuleRunning

RunningModuleV2 identifies cloudcore/edgecore running or not. only used for cloudcore container install and edgecore binary install

func SetNSSMServiceStderr added in v1.16.0

func SetNSSMServiceStderr(service string, file string) error

func SetNSSMServiceStdout added in v1.16.0

func SetNSSMServiceStdout(service string, file string) error

func StartNSSMService added in v1.16.0

func StartNSSMService(service string) error

func StopNSSMService added in v1.16.0

func StopNSSMService(service string) error

func UninstallNSSMService added in v1.16.0

func UninstallNSSMService(service string) error

Types

type CRIRuntime added in v1.11.0

type CRIRuntime struct {
	ImageManagerService internalapi.ImageManagerService
	RuntimeService      internalapi.RuntimeService
	// contains filtered or unexported fields
}

func (*CRIRuntime) CopyResources added in v1.11.0

func (runtime *CRIRuntime) CopyResources(edgeImage string, files map[string]string) error

CopyResources copies binary and configuration file from the image to the host. The same way as func (runtime *DockerRuntime) CopyResources

func (*CRIRuntime) PullImage added in v1.16.0

func (runtime *CRIRuntime) PullImage(image string, authConfig *runtimeapi.AuthConfig, sandboxConfig *runtimeapi.PodSandboxConfig) error

func (*CRIRuntime) PullImages added in v1.11.0

func (runtime *CRIRuntime) PullImages(images []string) error

func (*CRIRuntime) RemoveMQTT added in v1.11.3

func (runtime *CRIRuntime) RemoveMQTT() error

func (*CRIRuntime) RunMQTT added in v1.11.0

func (runtime *CRIRuntime) RunMQTT(mqttImage string) error

type Command

type Command struct {
	Cmd      *exec.Cmd
	StdOut   []byte
	StdErr   []byte
	ExitCode int
}

Command defines commands to be executed and captures std out and std error

func NewCommand added in v1.6.0

func NewCommand(command string) *Command

func (*Command) Exec added in v1.6.0

func (cmd *Command) Exec() error

Exec run command and exit formatted error, callers can print err directly Any running error or non-zero exitcode is consider as error

func (Command) GetCommand added in v1.6.0

func (cmd Command) GetCommand() string

func (Command) GetStdErr

func (cmd Command) GetStdErr() string

func (Command) GetStdOut added in v1.6.0

func (cmd Command) GetStdOut() string

type Common

type Common struct {
	types.OSTypeInstaller
	OSVersion   string
	ToolVersion semver.Version
	KubeConfig  string
	Master      string
}

Common struct contains OS and Tool version properties and also embeds OS interface

func (*Common) CleanNameSpace added in v1.11.0

func (co *Common) CleanNameSpace(ns, kubeConfigPath string) error

func (*Common) SetOSInterface

func (co *Common) SetOSInterface(intf types.OSTypeInstaller)

SetOSInterface defines a method to set the implemtation of the OS interface

type ContainerRuntime added in v1.11.0

type ContainerRuntime interface {
	PullImages(images []string) error
	PullImage(image string, authConfig *runtimeapi.AuthConfig, sandboxConfig *runtimeapi.PodSandboxConfig) error
	CopyResources(edgeImage string, files map[string]string) error
	RunMQTT(mqttImage string) error
	RemoveMQTT() error
}

func NewContainerRuntime added in v1.11.0

func NewContainerRuntime(endpoint, cgroupDriver string) (ContainerRuntime, error)

type DebOS added in v1.6.0

type DebOS struct {
	KubeEdgeVersion semver.Version
	IsEdgeNode      bool //True - Edgenode False - Cloudnode
}

DebOS struct objects shall have information of the tools version to be installed on Hosts having Ubuntu OS. It implements OSTypeInstaller interface

func (*DebOS) InstallKubeEdge added in v1.6.0

func (d *DebOS) InstallKubeEdge(options types.InstallOptions) error

InstallKubeEdge downloads the provided version of KubeEdge. Untar's in the specified location /etc/kubeedge/ and then copies the binary to excecutables' path (eg: /usr/local/bin)

func (*DebOS) InstallMQTT added in v1.6.0

func (d *DebOS) InstallMQTT() error

InstallMQTT checks if MQTT is already installed and running, if not then install it from OS repo

func (*DebOS) IsK8SComponentInstalled added in v1.6.0

func (d *DebOS) IsK8SComponentInstalled(kubeConfig, master string) error

IsK8SComponentInstalled checks if said K8S version is already installed in the host

func (*DebOS) IsKubeEdgeProcessRunning added in v1.6.0

func (d *DebOS) IsKubeEdgeProcessRunning(proc string) (bool, error)

IsKubeEdgeProcessRunning checks if the given process is running or not

func (*DebOS) KillKubeEdgeBinary added in v1.6.0

func (d *DebOS) KillKubeEdgeBinary(proc string) error

KillKubeEdgeBinary will search for KubeEdge process and forcefully kill it

func (*DebOS) RunEdgeCore added in v1.6.0

func (d *DebOS) RunEdgeCore() error

RunEdgeCore starts edgecore with logs being captured

func (*DebOS) SetKubeEdgeVersion added in v1.6.0

func (d *DebOS) SetKubeEdgeVersion(version semver.Version)

SetKubeEdgeVersion sets the KubeEdge version for the objects instance

type K8SInstTool

type K8SInstTool struct {
	Common
}

K8SInstTool embeds Common struct and contains the default K8S version and a flag depicting if host is an edge or cloud node It implements ToolsInstaller interface

func (*K8SInstTool) InstallTools

func (ks *K8SInstTool) InstallTools() error

InstallTools sets the OS interface, checks if K8S installation is required or not. If required then install the said version.

func (*K8SInstTool) TearDown

func (ks *K8SInstTool) TearDown() error

TearDown should uninstall K8S, but it is not required either for cloud or edge node. It is defined so that K8SInstTool implements ToolsInstaller interface

type KubeCloudInstTool

type KubeCloudInstTool struct {
	Common
	AdvertiseAddress string
	DNSName          string
	TarballPath      string
}

KubeCloudInstTool embeds Common struct It implements ToolsInstaller interface

func (*KubeCloudInstTool) InstallTools

func (cu *KubeCloudInstTool) InstallTools() error

InstallTools downloads KubeEdge for the specified version and makes the required configuration changes and initiates cloudcore.

func (*KubeCloudInstTool) RunCloudCore

func (cu *KubeCloudInstTool) RunCloudCore() error

RunCloudCore starts cloudcore process

func (*KubeCloudInstTool) TearDown

func (cu *KubeCloudInstTool) TearDown() error

TearDown method will remove the edge node from api-server and stop cloudcore process

type KubeEdgeInstTool

type KubeEdgeInstTool struct {
	Common
	CertPath              string
	CloudCoreIP           string
	EdgeNodeName          string
	RemoteRuntimeEndpoint string
	Token                 string
	CertPort              string
	CGroupDriver          string
	TarballPath           string
	Labels                []string
	HubProtocol           string
}

KubeEdgeInstTool embeds Common struct and contains cloud node ip:port information It implements ToolsInstaller interface

func (*KubeEdgeInstTool) InstallTools

func (ku *KubeEdgeInstTool) InstallTools() error

InstallTools downloads KubeEdge for the specified version and makes the required configuration changes and initiates edgecore.

func (*KubeEdgeInstTool) TearDown

func (ku *KubeEdgeInstTool) TearDown() error

TearDown method will remove the edge node from api-server and stop edgecore process

type MQTTInstTool

type MQTTInstTool struct {
	Common
}

MQTTInstTool embeds Common struct and It implements ToolsInstaller interface

func (*MQTTInstTool) InstallTools

func (m *MQTTInstTool) InstallTools() error

InstallTools sets the OS interface, it simply installs the said version

func (*MQTTInstTool) TearDown

func (m *MQTTInstTool) TearDown() error

TearDown should uninstall MQTT, but it is not required either for cloud or edge node. It is defined so that MQTTInstTool implements ToolsInstaller interface

type PacmanOS added in v1.6.0

type PacmanOS struct {
	KubeEdgeVersion semver.Version
	IsEdgeNode      bool
}

PacmanOS struct objects shall have information of the tools version to be installed on Hosts having PacmanOS. It implements OSTypeInstaller interface

func (*PacmanOS) InstallKubeEdge added in v1.6.0

func (o *PacmanOS) InstallKubeEdge(options types.InstallOptions) error

InstallKubeEdge downloads the provided version of KubeEdge. Untar's in the specified location /etc/kubeedge/ and then copies the binary to excecutables' path (eg: /usr/local/bin)

func (*PacmanOS) InstallMQTT added in v1.6.0

func (o *PacmanOS) InstallMQTT() error

InstallMQTT checks if MQTT is already installed and running, if not then install it from OS repo

func (*PacmanOS) IsK8SComponentInstalled added in v1.6.0

func (o *PacmanOS) IsK8SComponentInstalled(kubeConfig, master string) error

IsK8SComponentInstalled checks if said K8S version is already installed in the host

func (*PacmanOS) IsKubeEdgeProcessRunning added in v1.6.0

func (o *PacmanOS) IsKubeEdgeProcessRunning(proc string) (bool, error)

IsKubeEdgeProcessRunning checks if the given process is running or not

func (*PacmanOS) KillKubeEdgeBinary added in v1.6.0

func (o *PacmanOS) KillKubeEdgeBinary(proc string) error

KillKubeEdgeBinary will search for KubeEdge process and forcefully kill it

func (*PacmanOS) RunEdgeCore added in v1.6.0

func (o *PacmanOS) RunEdgeCore() error

RunEdgeCore sets the environment variable GOARCHAIUS_CONFIG_PATH for the configuration path and the starts edgecore with logs being captured

func (*PacmanOS) SetKubeEdgeVersion added in v1.6.0

func (o *PacmanOS) SetKubeEdgeVersion(version semver.Version)

SetKubeEdgeVersion sets the KubeEdge version for the objects instance

type RpmOS added in v1.6.0

type RpmOS struct {
	KubeEdgeVersion semver.Version
	IsEdgeNode      bool //True - Edgenode False - Cloudnode
}

RpmOS struct objects shall have information of the tools version to be installed on Hosts having RpmOS OS. It implements OSTypeInstaller interface

func (*RpmOS) InstallKubeEdge added in v1.6.0

func (r *RpmOS) InstallKubeEdge(options types.InstallOptions) error

InstallKubeEdge downloads the provided version of KubeEdge. Untar's in the specified location /etc/kubeedge/ and then copies the binary to excecutables' path (eg: /usr/local/bin)

func (*RpmOS) InstallMQTT added in v1.6.0

func (r *RpmOS) InstallMQTT() error

InstallMQTT checks if MQTT is already installed and running, if not then install it from OS repo Information is used from https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-centos-7

func (*RpmOS) IsK8SComponentInstalled added in v1.6.0

func (r *RpmOS) IsK8SComponentInstalled(kubeConfig, master string) error

IsK8SComponentInstalled checks if said K8S version is already installed in the host

func (*RpmOS) IsKubeEdgeProcessRunning added in v1.6.0

func (r *RpmOS) IsKubeEdgeProcessRunning(proc string) (bool, error)

IsKubeEdgeProcessRunning checks if the given process is running or not

func (*RpmOS) KillKubeEdgeBinary added in v1.6.0

func (r *RpmOS) KillKubeEdgeBinary(proc string) error

KillKubeEdgeBinary will search for KubeEdge process and forcefully kill it

func (*RpmOS) RunEdgeCore added in v1.6.0

func (r *RpmOS) RunEdgeCore() error

RunEdgeCore starts edgecore with logs being captured

func (*RpmOS) SetKubeEdgeVersion added in v1.6.0

func (r *RpmOS) SetKubeEdgeVersion(version semver.Version)

SetKubeEdgeVersion sets the KubeEdge version for the objects instance

Jump to

Keyboard shortcuts

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