common

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// FlagNameForce force install
	FlagNameForce = "force"

	// FlagNameKubeEdgeVersion sets the version of KubeEdge to be used
	FlagNameKubeEdgeVersion = "kubeedge-version"
)

Common flag names

View Source
const (
	// FlagNameKubeConfig sets the path of kubeconfig
	FlagNameKubeConfig = "kube-config"

	// FlagNameAdvertiseAddress ...
	FlagNameAdvertiseAddress = "advertise-address"

	// FlagNameProfile flag name for install and upgrade in cloud
	FlagNameProfile = "profile"

	// FlagNameExternalHelmRoot external Helm Root
	FlagNameExternalHelmRoot = "external-helm-root"

	// FlagNameSet ...
	FlagNameSet = "set"

	// FlagNameValueFiles ...
	FlagNameValueFiles = "values"

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

	// FlagNamePrintFinalValues ...
	FlagNamePrintFinalValues = "print-final-values"
)

Cloud init and upgrade common flag names

View Source
const (
	// FlagNameSkipCRDs skip CRDs
	FlagNameSkipCRDs = "skip-crds"

	// FlagNameMaster sets the address of K8s master
	// Deprecated: only used in deprecated/init.go
	FlagNameMaster = "master"

	// FlagNameManifests allow appending manifests paths of manifests to keadm, separated by commas
	FlagNameManifests = "manifests"

	// FlagNameFiles allow appending manifests paths of manifests to keadm, separated by commas, another supported flag
	FlagNameFiles = "files"
)

Cloud init flag names

View Source
const (
	// FlagNameImageRepository sets the image repository to pull images
	FlagNameImageRepository = "image-repository"

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

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

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

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

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

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

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

	// FlagNameDomainName ...
	// Deprecated: only used in deprecated/init.go
	FlagNameDomainName = "domainname"

	// FlagNameLabels ...
	FlagNameLabels = "labels"

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

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

Edge join flag names

View Source
const (
	// DefaultK8SMinimumVersion is the minimum version of K8S
	DefaultK8SMinimumVersion = 11

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

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

	// Token secret
	TokenSecretName = "tokensecret"
	TokenDataName   = "tokendata"

	StrCheck    = "check"
	StrDiagnose = "diagnose"

	HubProtocol = "hub-protocol"

	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
)
View Source
const (
	FlagNameNamespace     = "namespace"
	FlagNameAllNamespaces = "all-namespaces"
	FlagNameOutput        = "output"
	FlagNameLabelSelector = "selector"
)
View Source
const (
	// DefaultCertPath is the default certificate path in edge node
	DefaultCertPath = "/etc/kubeedge/certs"
)
View Source
const (
	// FlagNameReuseValues ...
	FlagNameReuseValues = "reuse-values"
)

Cloud upgrade flag names

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,
		},
	}

	// DefaultKubeConfig is the default path of kubeconfig
	// make it an var so it can be changed to adapt to windows(In rare cases, user name is Administrator)
	DefaultKubeConfig = "/root/.kube/config"
)

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
	Timeout        int
	CloudHubServer string
	EdgecoreServer string
	Config         string
}

type CloudInitUpdateBase added in v1.16.0

type CloudInitUpdateBase struct {
	KubeConfig       string
	KubeEdgeVersion  string
	AdvertiseAddress string
	Profile          string
	ExternalHelmRoot string
	Sets             []string
	ValueFiles       []string
	Force            bool
	DryRun           bool
	PrintFinalValues bool
	ImageRepository  string
}

CloudInitUpdateBase defines common flags for init and upgrade in the cloud.

func (CloudInitUpdateBase) GetValidSets added in v1.16.0

func (b CloudInitUpdateBase) GetValidSets() []string

GetValidSets returns a valid sets, if the item is an invalid key-value, it is removed from the sets and print the error message.

func (CloudInitUpdateBase) HasSets added in v1.16.0

func (b CloudInitUpdateBase) HasSets(key string) bool

HasSets returns the key is in the sets

type CloudUpgradeOptions added in v1.16.0

type CloudUpgradeOptions struct {
	ReuseValues bool
	CloudInitUpdateBase
}

CloudUpgradeOptions defines cloud upgrade flags

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 InitOptions

type InitOptions struct {
	Manifests string
	SkipCRDs  bool
	CloudInitUpdateBase
}

InitOptions defines cloud init flags

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 {
	KubeEdgeVersion       string
	CertPath              string
	CloudCoreIPPort       string
	EdgeNodeName          string
	RemoteRuntimeEndpoint string
	Token                 string
	CertPort              string
	CGroupDriver          string
	Labels                []string

	// WithMQTT ...
	// Deprecated: the mqtt broker is alreay managed by the DaemonSet in the cloud
	WithMQTT bool

	ImageRepository string
	HubProtocol     string
	TarballPath     string
}

JoinOptions defines edge join flags

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
	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