common

package
v1.15.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// KubeEdgeVersion sets the version of KubeEdge to be used
	KubeEdgeVersion = "kubeedge-version"

	// ImageRepository sets the image repository to pull images
	ImageRepository = "image-repository"

	// KubeConfig sets the path of kubeconfig
	KubeConfig = "kube-config"

	// Master sets the address of K8s master
	Master = "master"

	// CloudCoreIPPort sets the IP and port of KubeEdge cloud component
	CloudCoreIPPort = "cloudcore-ipport"

	// EdgeNodeName is KubeEdge node unique identification string
	EdgeNodeName = "edgenode-name"

	// RemoteRuntimeEndpoint is KubeEdge remote-runtime-endpoint string
	RemoteRuntimeEndpoint = "remote-runtime-endpoint"

	// CertPath sets the path of the certificates generated by the KubeEdge Cloud component
	CertPath = "certPath"

	// DefaultCertPath is the default certificate path in edge node
	DefaultCertPath = "/etc/kubeedge/certs"

	// DefaultK8SMinimumVersion is the minimum version of K8S
	DefaultK8SMinimumVersion = 11

	// DefaultKubeConfig is the default path of kubeconfig
	DefaultKubeConfig = "/root/.kube/config"

	// RuntimeType is default runtime type
	RuntimeType = "runtimetype"

	// DefaultKubeEdgeVersion is the default KubeEdge version, it must have no prefix 'v'
	DefaultKubeEdgeVersion = "1.14.0"

	// Token sets the token used when edge applying for the certificate
	Token = "token"

	// CertPort is the port where to apply for the edge certificate
	CertPort = "certport"

	AdvertiseAddress = "advertise-address"

	TokenSecretName = "tokensecret"

	TokenDataName = "tokendata"

	DomainName = "domainname"

	Labels = "labels"

	// CGroupDriver is type of edgecore Cgroup
	CGroupDriver = "cgroupdriver"

	// TarballPath sets the temp directory path for KubeEdge tarball, if not exist, download it
	// eg.  "/tmp/kubeedge" or "/etc/kubeedge" by default
	TarballPath = "tarballpath"

	StrCheck    = "check"
	StrDiagnose = "diagnose"

	// Allow appending manifests paths of manifests to keadm, separated by commas
	Manifests = "manifests"

	// Allow appending manifests paths of manifests to keadm, separated by commas, another supported flag
	Files = "files"

	// Dry-run flag
	DryRun = "dry-run"

	// Forced install
	Force = "force"

	// Skip CRDs
	SkipCRDs = "skip-crds"

	// External Helm Root
	ExternalHelmRoot = "external-helm-root"

	// Helm action
	HelmInstallAction  = "install"
	HelmManifestAction = "manifest"

	CmdGetDNSIP         = "cat /etc/resolv.conf | grep nameserver | grep -v -E ':|#' | awk '{print $2}' | head -n1"
	CmdGetStatusDocker  = "systemctl status docker |grep Active | awk '{print $2}'"
	CmdPing             = "ping %s -w %d |grep 'packets transmitted' |awk '{print $6}'"
	CmdGetMaxProcessNum = "sysctl kernel.pid_max|awk '{print $3}'"
	CmdGetProcessNum    = "ps -A|wc -l"

	EdgecoreConfig = "config"

	EdgeCoreServer = "127.0.0.1:10350"

	// EdgecoreConfigPath is default edgecore config path
	EdgecoreConfigPath = "/etc/kubeedge/config/edgecore.yaml"

	// CmdCopyFile is the cmd to copy file
	CmdCopyFile = "cp -r %s %s/"

	/*system info*/
	CmdDiskInfo    = "df -h > %s/disk"
	CmdArchInfo    = "arch > %s/arch"
	CmdProcessInfo = "ps -axu > %s/process"
	CmdDateInfo    = "date > %s/date"
	CmdUptimeInfo  = "uptime > %s/uptime"
	CmdHistorynfo  = "history -a && cat ~/.bash_history  > %s/history"
	CmdNetworkInfo = "netstat -pan > %s/network"

	PathCpuinfo   = "/proc/cpuinfo"
	PathMemory    = "/proc/meminfo"
	PathHosts     = "/etc/hosts"
	PathDNSResolv = "/etc/resolv.conf"

	/*edgecore info*/
	PathEdgecoreService = "/lib/systemd/system/edgecore.service"
	CmdEdgecoreVersion  = "edgecore  --version > %s/version"

	/*runtime info*/
	CmdDockerVersion    = "docker version > %s/version"
	CmdContainerInfo    = "docker ps -a > %s/containerInfo"
	CmdContainerLogInfo = "journalctl -u docker  > %s/log"
	CmdDockerInfo       = "docker info > %s/info"
	CmdDockerImageInfo  = "docker images > %s/images"
	PathDockerService   = "/lib/systemd/system/docker.service"

	DescAll     = "Check all item"
	DescArch    = "Check whether the architecture can work"
	DescCPU     = "Check node CPU requirements"
	DescMemory  = "Check node memory requirements"
	Descdisk    = "Check node disk requirements"
	DescDNS     = "Check whether DNS can work"
	DescRuntime = "Check whether runtime can work"
	DescNetwork = "Check whether the network is normal"
	DescPID     = "Check node PID requirements"

	/**Diagnose**/
	ArgDiagnoseNode  = "node"
	DescDiagnoseNode = "Diagnose edge node"

	ArgDiagnosePod  = "pod"
	DescDiagnosePod = "Diagnose pod"

	ArgDiagnoseInstall  = "install"
	DescDiagnoseInstall = "Diagnose install"

	ArgCheckAll     = "all"
	ArgCheckArch    = "arch"
	ArgCheckCPU     = "cpu"
	ArgCheckMemory  = "mem"
	ArgCheckDisk    = "disk"
	ArgCheckDNS     = "dns"
	ArgCheckRuntime = "runtime"
	ArgCheckNetwork = "network"
	ArgCheckPID     = "pid"

	KB = 1024
	MB = KB * 1024
	GB = MB * 1024

	AllowedValueCPU     = 1
	AllowedValueMemory  = 256 * MB
	AllowedValueDisk    = GB
	AllowedValuePIDRate = 0.05

	AllowedCurrentValueCPURate  = 0.9
	AllowedCurrentValueMemRate  = 0.9
	AllowedCurrentValueDiskRate = 0.9

	AllowedCurrentValueMem  = 128 * MB
	AllowedCurrentValueDisk = 512 * MB
)

Variables

View Source
var (
	CheckObjectMap = []CheckObject{
		{
			Use:  ArgCheckAll,
			Desc: DescAll,
		},
		{
			Use:  ArgCheckCPU,
			Desc: DescCPU,
		},
		{
			Use:  ArgCheckMemory,
			Desc: DescMemory,
		},
		{
			Use:  ArgCheckDisk,
			Desc: Descdisk,
		},
		{
			Use:  ArgCheckDNS,
			Desc: DescDNS,
		},
		{
			Use:  ArgCheckRuntime,
			Desc: DescRuntime,
		},
		{
			Use:  ArgCheckNetwork,
			Desc: DescNetwork,
		},
		{
			Use:  ArgCheckPID,
			Desc: DescPID,
		},
	}

	DiagnoseObjectMap = []DiagnoseObject{
		{
			Use:  ArgDiagnoseNode,
			Desc: DescDiagnoseNode,
		},
		{
			Use:  ArgDiagnosePod,
			Desc: DescDiagnosePod,
		},
		{
			Use:  ArgDiagnoseInstall,
			Desc: DescDiagnoseInstall,
		},
	}
)

Functions

func GenerateServiceFile added in v1.10.0

func GenerateServiceFile(process string, execStartCmd string, withMqtt bool) error

func RemoveServiceFile added in v1.10.0

func RemoveServiceFile(process string) error

func Write2File

func Write2File(path string, data interface{}) error

Write2File writes data into a file in path

Types

type CheckObject added in v1.5.0

type CheckObject struct {
	Use  string
	Desc string
	Cmd  string
}

type CheckOptions added in v1.5.0

type CheckOptions struct {
	Domain         string
	DNSIP          string
	IP             string
	Runtime        string
	Timeout        int
	CloudHubServer string
	EdgecoreServer string
	Config         string
}

type CollectOptions added in v1.6.0

type CollectOptions struct {
	Config     string
	OutputPath string
	Detail     bool
	LogPath    string
}

CollectOptions has the kubeedge debug collect information filled by CLI

type ComponentType added in v1.2.1

type ComponentType string

ComponentType is the type of KubeEdge components, cloudcore or edgecore

const (
	CloudCore ComponentType = "cloudcore"
	EdgeCore  ComponentType = "edgecore"
)

All Component type

type DiagnoseObject added in v1.5.0

type DiagnoseObject struct {
	Desc string
	Use  string
}

type DiagnoseOptions added in v1.5.0

type DiagnoseOptions struct {
	Pod          string
	Namespace    string
	Config       string
	CheckOptions *CheckOptions
	DBPath       string
}

type FlagData

type FlagData struct {
	Val    interface{}
	DefVal interface{}
}

FlagData stores value and default value of the flags used in this command

type GettokenOptions added in v1.3.1

type GettokenOptions struct {
	Kubeconfig string
}

type InitBaseOptions added in v1.11.0

type InitBaseOptions struct {
	KubeEdgeVersion  string
	KubeConfig       string
	Master           string
	AdvertiseAddress string
	DNS              string
	TarballPath      string
}

InitBaseOptions has the kubeedge cloud deprecated init base information filled by CLI

type InitOptions

type InitOptions struct {
	KubeConfig       string
	KubeEdgeVersion  string
	AdvertiseAddress string
	Manifests        string
	Namespace        string
	Sets             []string
	Profile          string
	ExternalHelmRoot string
	Force            bool
	SkipCRDs         bool
	DryRun           bool
}

InitOptions has the kubeedge cloud init information filled by CLI

type InstallOptions added in v1.5.0

type InstallOptions struct {
	ComponentType ComponentType
	TarballPath   string
}

InstallOptions is defined to know the options for installing kubeedge

type JoinOptions

type JoinOptions struct {
	InitBaseOptions
	CertPath              string
	CloudCoreIPPort       string
	EdgeNodeName          string
	RuntimeType           string
	RemoteRuntimeEndpoint string
	Token                 string
	CertPort              string
	CGroupDriver          string
	Labels                []string
	WithMQTT              bool
	ImageRepository       string
}

JoinOptions has the kubeedge cloud init information filled by CLI

type ModuleRunning

type ModuleRunning uint8

ModuleRunning is defined to know the running status of KubeEdge components

const (
	NoneRunning ModuleRunning = iota
	KubeEdgeCloudRunning
	KubeEdgeEdgeRunning
)

Different possible values for ModuleRunning type

type OSTypeInstaller

type OSTypeInstaller interface {
	InstallMQTT() error
	IsK8SComponentInstalled(string, string) error
	SetKubeEdgeVersion(version semver.Version)
	InstallKubeEdge(InstallOptions) error
	RunEdgeCore() error
	KillKubeEdgeBinary(string) error
	IsKubeEdgeProcessRunning(string) (bool, error)
}

OSTypeInstaller interface for methods to be executed over a specified OS distribution type

type ResetOptions added in v1.4.0

type ResetOptions struct {
	Kubeconfig  string
	Force       bool
	RuntimeType string
	Endpoint    string
}

type Step added in v1.10.0

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

func NewStep added in v1.10.0

func NewStep() *Step

func (*Step) Printf added in v1.10.0

func (s *Step) Printf(format string, args ...interface{})

type ToolsInstaller

type ToolsInstaller interface {
	InstallTools() error
	TearDown() error
}

ToolsInstaller interface for tools with install and teardown methods.

Jump to

Keyboard shortcuts

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