Documentation
¶
Index ¶
- Constants
- Variables
- func AddToolVals(f *pflag.Flag, flagData map[string]FlagData)
- func CheckIfAvailable(val, defval string) string
- func GetInterfaceIP() (string, error)
- func GetOSVersion() string
- type CentOS
- func (c *CentOS) InstallDocker() error
- func (c *CentOS) InstallK8S() error
- func (c *CentOS) InstallKubeEdge() error
- func (c *CentOS) InstallMQTT() error
- func (c *CentOS) IsDockerInstalled(string) (InstallState, error)
- func (c *CentOS) IsK8SComponentInstalled(component, defVersion string) (InstallState, error)
- func (c *CentOS) IsKubeEdgeProcessRunning(proc string) (bool, error)
- func (c *CentOS) IsToolVerInRepo(toolName, version string) (bool, error)
- func (c *CentOS) KillKubeEdgeBinary(proc string) error
- func (c *CentOS) RunEdgeCore() error
- func (c *CentOS) SetDockerVersion(version string)
- func (c *CentOS) SetK8SVersionAndIsNodeFlag(version string, flag bool)
- func (c *CentOS) SetKubeEdgeVersion(version string)
- func (c *CentOS) StartK8Scluster() error
- type Command
- type Common
- type DockerInstTool
- type FlagData
- type InstallState
- type K8SInstTool
- type KubeCloudInstTool
- type KubeEdgeInstTool
- type MQTTInstTool
- type ModuleRunning
- type NodeDefinition
- type NodeMetaDataLabels
- type NodeMetaDataSt
- type OSTypeInstaller
- type ToolsInstaller
- type UbuntuOS
- func (u *UbuntuOS) InstallDocker() error
- func (u *UbuntuOS) InstallK8S() error
- func (u *UbuntuOS) InstallKubeEdge() error
- func (u *UbuntuOS) InstallMQTT() error
- func (u *UbuntuOS) IsDockerInstalled(defVersion string) (InstallState, error)
- func (u *UbuntuOS) IsK8SComponentInstalled(component, defVersion string) (InstallState, error)
- func (u *UbuntuOS) IsKubeEdgeProcessRunning(proc string) (bool, error)
- func (u *UbuntuOS) IsToolVerInRepo(toolName, version string) (bool, error)
- func (u *UbuntuOS) KillKubeEdgeBinary(proc string) error
- func (u *UbuntuOS) RunEdgeCore() error
- func (u *UbuntuOS) SetDockerVersion(version string)
- func (u *UbuntuOS) SetK8SVersionAndIsNodeFlag(version string, flag bool)
- func (u *UbuntuOS) SetKubeEdgeVersion(version string)
- func (u *UbuntuOS) StartK8Scluster() error
Constants ¶
const ( UbuntuOSType = "ubuntu" CentOSType = "centos" DefaultDownloadURL = "https://download.docker.com" DockerPreqReqList = "apt-transport-https ca-certificates curl gnupg-agent software-properties-common" KubernetesDownloadURL = "https://apt.kubernetes.io/" KubernetesGPGURL = "https://packages.cloud.google.com/apt/doc/apt-key.gpg" KubeEdgeDownloadURL = "https://github.com/kubeedge/kubeedge/releases/download" KubeEdgePath = "/etc/kubeedge/" KubeEdgeConfPath = KubeEdgePath + "kubeedge/edge/conf" KubeEdgeBinaryName = "edge_core" KubeEdgeDefaultCertPath = KubeEdgePath + "certs/" KubeEdgeConfigEdgeYaml = KubeEdgeConfPath + "/edge.yaml" KubeEdgeToReplaceKey1 = "fb4ebb70-2783-42b8-b3ef-63e2fd6d242e" KubeEdgeToReplaceKey2 = "0.0.0.0" KubeEdgeConfigNodeJSON = KubeEdgeConfPath + "/node.json" KubeEdgeConfigLoggingYaml = KubeEdgeConfPath + "/logging.yaml" KubeEdgeConfigModulesYaml = KubeEdgeConfPath + "/modules.yaml" KubeEdgeCloudCertGenPath = KubeEdgePath + "certgen.sh" KubeEdgeEdgeCertsTarFileName = "certs.tgz" KubeEdgeEdgeCertsTarFilePath = KubeEdgePath + "certs.tgz" KubeEdgeCloudConfPath = KubeEdgePath + "kubeedge/cloud/conf" KubeEdgeControllerYaml = KubeEdgeCloudConfPath + "/controller.yaml" KubeEdgeControllerLoggingYaml = KubeEdgeCloudConfPath + "/logging.yaml" KubeEdgeControllerModulesYaml = KubeEdgeCloudConfPath + "/modules.yaml" KubeCloudBinaryName = "edgecontroller" KubeCloudApiserverYamlPath = "/etc/kubernetes/manifests/kube-apiserver.yaml" KubeCloudReplaceIndex = 25 KubeCloudReplaceString = " - --insecure-bind-address=0.0.0.0\n" KubeAPIServerName = "kube-apiserver" )
Constants used by installers
Variables ¶
var ( CertGenSh = []byte(`#!/bin/sh readonly caPath=${CA_PATH:-/etc/kubeedge/ca} readonly caSubject=${CA_SUBJECT:-/C=CN/ST=Zhejiang/L=Hangzhou/O=KubeEdge/CN=kubeedge.io} readonly certPath=${CERT_PATH:-/etc/kubeedge/certs} readonly subject=${SUBJECT:-/C=CN/ST=Zhejiang/L=Hangzhou/O=KubeEdge/CN=kubeedge.io} genCA() { openssl genrsa -des3 -out ${caPath}/rootCA.key -passout pass:kubeedge.io 4096 openssl req -x509 -new -nodes -key ${caPath}/rootCA.key -sha256 -days 3650 \ -subj ${subject} -passin pass:kubeedge.io -out ${caPath}/rootCA.crt } ensureCA() { if [ ! -e ${caPath}/rootCA.key ] || [ ! -e ${caPath}/rootCA.crt ]; then genCA fi } ensureFolder() { if [ ! -d ${caPath} ]; then mkdir -p ${caPath} fi if [ ! -d ${certPath} ]; then mkdir -p ${certPath} fi } genCertAndKey() { ensureFolder ensureCA local name=$1 openssl genrsa -out ${certPath}/${name}.key 2048 openssl req -new -key ${certPath}/${name}.key -subj ${subject} -out ${certPath}/${name}.csr openssl x509 -req -in ${certPath}/${name}.csr -CA ${caPath}/rootCA.crt -CAkey ${caPath}/rootCA.key \ -CAcreateserial -passin pass:kubeedge.io -out ${certPath}/${name}.crt -days 365 -sha256 } buildSecret() { local name="edge" genCertAndKey ${name} > /dev/null 2>&1 cat <<EOF apiVersion: v1 kind: Secret metadata: name: edgecontroller namespace: kubeedge labels: k8s-app: kubeedge kubeedge: edgecontroller stringData: rootCA.crt: | $(pr -T -o 4 ${caPath}/rootCA.crt) edge.crt: | $(pr -T -o 4 ${certPath}/${name}.crt) edge.key: | $(pr -T -o 4 ${certPath}/${name}.key) EOF } $1 $2 `) ControllerYaml = []byte(`controller: kube: master: http://localhost:8080 namespace: "" content_type: "application/vnd.kubernetes.protobuf" qps: 5 burst: 10 node_update_frequency: 10 kubeconfig: "" #Enter path to kubeconfig file to enable https connection to k8s apiserver cloudhub: address: 0.0.0.0 port: 10000 ca: /etc/kubeedge/ca/rootCA.crt cert: /etc/kubeedge/certs/edge.crt key: /etc/kubeedge/certs/edge.key keepalive-interval: 30 write-timeout: 30 node-limit: 10 devicecontroller: kube: master: http://localhost:8080 namespace: "" content_type: "application/vnd.kubernetes.protobuf" qps: 5 burst: 10 kubeconfig: "" `) ControllerLoggingYaml = []byte(`loggerLevel: "INFO" enableRsyslog: false logFormatText: true writers: [file,stdout] loggerFile: "edgecontroller.log" `) ControllerModulesYaml = []byte(`modules: enabled: [devicecontroller, controller, cloudhub] `) )
Edge controller Configuration files and certificate generator script
var ( EdgeYaml = []byte(`mqtt: server: tcp://127.0.0.1:1883 # external mqtt broker url. internal-server: tcp://127.0.0.1:1884 # internal mqtt broker url. mode: 0 # 0: internal mqtt broker enable only. 1: internal and external mqtt broker enable. 2: external mqtt broker enable only. qos: 0 # 0: QOSAtMostOnce, 1: QOSAtLeastOnce, 2: QOSExactlyOnce. retain: false # if the flag set true, server will store the message and can be delivered to future subscribers. session-queue-size: 100 # A size of how many sessions will be handled. default to 100. edgehub: websocket: url: wss://0.0.0.0:10000/e632aba927ea4ac2b575ec1603d56f10/fb4ebb70-2783-42b8-b3ef-63e2fd6d242e/events certfile: /etc/kubeedge/certs/edge.crt keyfile: /etc/kubeedge/certs/edge.key handshake-timeout: 30 #second write-deadline: 15 # second read-deadline: 15 # second controller: placement: false heartbeat: 15 # second refresh-ak-sk-interval: 10 # minute auth-info-files-path: /var/IEF/secret placement-url: https://10.154.193.32:7444/v1/placement_external/message_queue project-id: e632aba927ea4ac2b575ec1603d56f10 node-id: fb4ebb70-2783-42b8-b3ef-63e2fd6d242e edged: register-node-namespace: default hostname-override: fb4ebb70-2783-42b8-b3ef-63e2fd6d242e interface-name: eth0 node-status-update-frequency: 10 # second device-plugin-enabled: false gpu-plugin-enabled: false image-gc-high-threshold: 80 # percent image-gc-low-threshold: 40 # percent maximum-dead-containers-per-container: 1 docker-address: unix:///var/run/docker.sock version: 2.0.0 `) EdgeLoggingYaml = []byte(`loggerLevel: "DEBUG" enableRsyslog: false logFormatText: true writers: [stdout] `) EdgeModulesYaml = []byte(`modules: enabled: [eventbus, servicebus, websocket, metaManager, edged, twin, dbTest] `) EdgeNodeJSONContent = `` /* 173-byte string literal not displayed */ )
Functions ¶
func AddToolVals ¶
AddToolVals gets the value and default values of each flags and collects them in temporary cache
func CheckIfAvailable ¶
CheckIfAvailable checks is val of a flag is empty then return the default value
func GetInterfaceIP ¶
GetInterfaceIP gets the interface ip address, this command helps in getting the edge node ip
Types ¶
type CentOS ¶
type CentOS struct { DockerVersion string KubernetesVersion string KubeEdgeVersion string IsEdgeNode bool //True - Edgenode False - Cloudnode }
CentOS struct objects shall have information of the tools version to be installed on Hosts having Ubuntu OS. It implements OSTypeInstaller interface
func (*CentOS) InstallDocker ¶
InstallDocker will install the specified docker in the host
func (*CentOS) InstallK8S ¶
InstallK8S will install kubeadm, kudectl and kubelet for the cloud node and only kubectl for edge node
func (*CentOS) InstallKubeEdge ¶
InstallKubeEdge downloads the provided version of KubeEdge. Untar's in the specified location /etc/kubeedge/ and then copies the binary to /usr/local/bin path.
func (*CentOS) InstallMQTT ¶
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 (*CentOS) IsDockerInstalled ¶
func (c *CentOS) IsDockerInstalled(string) (InstallState, error)
IsDockerInstalled checks if docker is installed in the host or not
func (*CentOS) IsK8SComponentInstalled ¶
func (c *CentOS) IsK8SComponentInstalled(component, defVersion string) (InstallState, error)
IsK8SComponentInstalled checks if said K8S version is already installed in the host
func (*CentOS) IsKubeEdgeProcessRunning ¶
IsKubeEdgeProcessRunning checks if the given process is running or not
func (*CentOS) IsToolVerInRepo ¶
IsToolVerInRepo checks if the tool mentioned in available in OS repo or not
func (*CentOS) KillKubeEdgeBinary ¶
KillKubeEdgeBinary will search for KubeEdge process and forcefully kill it
func (*CentOS) RunEdgeCore ¶
RunEdgeCore sets the environment variable GOARCHAIUS_CONFIG_PATH for the configuration path and the starts edge_core with logs being captured
func (*CentOS) SetDockerVersion ¶
SetDockerVersion sets the Docker version for the objects instance
func (*CentOS) SetK8SVersionAndIsNodeFlag ¶
SetK8SVersionAndIsNodeFlag sets the K8S version for the objects instance It also sets if this host shall act as edge node or not
func (*CentOS) SetKubeEdgeVersion ¶
SetKubeEdgeVersion sets the KubeEdge version for the objects instance
func (*CentOS) StartK8Scluster ¶
StartK8Scluster will do "kubeadm init" and cluster will be started
type Command ¶
Command defines commands to be executed and captures std out and std error
func (Command) ExecuteCmdShowOutput ¶
ExecuteCmdShowOutput captures both StdOut and StdErr after exec.cmd(). It helps in the commands where it takes some time for execution.
func (*Command) ExecuteCommand ¶
func (cm *Command) ExecuteCommand()
ExecuteCommand executes the command and captures the output in stdOut
func (Command) GetStdOutput ¶
GetStdOutput gets StdOut field
type Common ¶
type Common struct { OSTypeInstaller OSVersion string ToolVersion string }
Common struct contains OS and Tool version properties and also embeds OS interface
func (*Common) SetOSInterface ¶
func (co *Common) SetOSInterface(intf OSTypeInstaller)
SetOSInterface defines a method to set the implemtation of the OS interface
type DockerInstTool ¶
DockerInstTool embedes Common struct and contains the default docker version It implements ToolsInstaller interface
func (*DockerInstTool) InstallTools ¶
func (d *DockerInstTool) InstallTools() error
InstallTools sets the OS interface, checks if docker installation is required or not. If required then install the said version.
func (*DockerInstTool) TearDown ¶
func (d *DockerInstTool) TearDown() error
TearDown shoud uninstall docker, but it is not required either for cloud or edge node. It is defined so that DockerInstTool implements ToolsInstaller interface
type FlagData ¶
type FlagData struct { Val interface{} DefVal interface{} }
FlagData stores value and default value of the flags used in this command
type InstallState ¶
type InstallState uint8
InstallState enum set used for verifying a tool version is installed in host
const ( NewInstallRequired InstallState = iota AlreadySameVersionExist DefVerInstallRequired VersionNAInRepo )
Difference enum values for type InstallState
type K8SInstTool ¶
type K8SInstTool struct { Common IsEdgeNode bool //True - Edgenode False - Cloudnode DefaultToolVer string }
K8SInstTool embedes 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 shoud 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
}
KubeCloudInstTool embedes 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 edgecontroller.
func (*KubeCloudInstTool) RunEdgeController ¶
func (cu *KubeCloudInstTool) RunEdgeController() error
RunEdgeController starts edgecontroller process
func (*KubeCloudInstTool) TearDown ¶
func (cu *KubeCloudInstTool) TearDown() error
TearDown method will remove the edge node from api-server and stop edgecontroller process
type KubeEdgeInstTool ¶
KubeEdgeInstTool embedes 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 verssion and makes the required configuration changes and initiates edge_core.
func (*KubeEdgeInstTool) TearDown ¶
func (ku *KubeEdgeInstTool) TearDown() error
TearDown method will remove the edge node from api-server and stop edge_core process
type MQTTInstTool ¶
type MQTTInstTool struct {
Common
}
MQTTInstTool embedes 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 shoud uninstall MQTT, but it is not required either for cloud or edge node. It is defined so that MQTTInstTool implements ToolsInstaller interface
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
func IsKubeEdgeController ¶
func IsKubeEdgeController() (ModuleRunning, error)
IsKubeEdgeController identifies if the node is having edge controller and k8s api-server already running. If so, then return true, else it can used as edge node and initialise it.
type NodeDefinition ¶
type NodeDefinition struct { Kind string APIVersion string MetaData NodeMetaDataSt }
NodeDefinition defines
type NodeMetaDataSt ¶
type NodeMetaDataSt struct { Name string Labels NodeMetaDataLabels }
NodeMetaDataSt defines
type OSTypeInstaller ¶
type OSTypeInstaller interface { IsToolVerInRepo(string, string) (bool, error) IsDockerInstalled(string) (InstallState, error) InstallDocker() error InstallMQTT() error IsK8SComponentInstalled(string, string) (InstallState, error) InstallK8S() error StartK8Scluster() error InstallKubeEdge() error SetDockerVersion(string) SetK8SVersionAndIsNodeFlag(version string, flag bool) SetKubeEdgeVersion(string) RunEdgeCore() error KillKubeEdgeBinary(string) error IsKubeEdgeProcessRunning(string) (bool, error) }
OSTypeInstaller interface for methods to be executed over a specified OS distribution type
func GetOSInterface ¶
func GetOSInterface() OSTypeInstaller
GetOSInterface helps in returning OS specific object which implements OSTypeInstaller interface.
type ToolsInstaller ¶
ToolsInstaller interface for tools with install and teardown methods.
type UbuntuOS ¶
type UbuntuOS struct { DockerVersion string KubernetesVersion string KubeEdgeVersion string IsEdgeNode bool //True - Edgenode False - Cloudnode }
UbuntuOS struct objects shall have information of the tools version to be installed on Hosts having Ubuntu OS. It implements OSTypeInstaller interface
func (*UbuntuOS) InstallDocker ¶
InstallDocker will install the specified docker in the host
func (*UbuntuOS) InstallK8S ¶
InstallK8S will install kubeadm, kudectl and kubelet for the cloud node and only kubectl for edge node
func (*UbuntuOS) InstallKubeEdge ¶
InstallKubeEdge downloads the provided version of KubeEdge. Untar's in the specified location /etc/kubeedge/ and then copies the binary to /usr/local/bin path.
func (*UbuntuOS) InstallMQTT ¶
InstallMQTT checks if MQTT is already installed and running, if not then install it from OS repo
func (*UbuntuOS) IsDockerInstalled ¶
func (u *UbuntuOS) IsDockerInstalled(defVersion string) (InstallState, error)
IsDockerInstalled checks if docker is installed in the host or not
func (*UbuntuOS) IsK8SComponentInstalled ¶
func (u *UbuntuOS) IsK8SComponentInstalled(component, defVersion string) (InstallState, error)
IsK8SComponentInstalled checks if said K8S version is already installed in the host
func (*UbuntuOS) IsKubeEdgeProcessRunning ¶
IsKubeEdgeProcessRunning checks if the given process is running or not
func (*UbuntuOS) IsToolVerInRepo ¶
IsToolVerInRepo checks if the tool mentioned in available in OS repo or not
func (*UbuntuOS) KillKubeEdgeBinary ¶
KillKubeEdgeBinary will search for KubeEdge process and forcefully kill it
func (*UbuntuOS) RunEdgeCore ¶
RunEdgeCore sets the environment variable GOARCHAIUS_CONFIG_PATH for the configuration path and the starts edge_core with logs being captured
func (*UbuntuOS) SetDockerVersion ¶
SetDockerVersion sets the Docker version for the objects instance
func (*UbuntuOS) SetK8SVersionAndIsNodeFlag ¶
SetK8SVersionAndIsNodeFlag sets the K8S version for the objects instance It also sets if this host shall act as edge node or not
func (*UbuntuOS) SetKubeEdgeVersion ¶
SetKubeEdgeVersion sets the KubeEdge version for the objects instance
func (*UbuntuOS) StartK8Scluster ¶
StartK8Scluster will do "kubeadm init" and cluster will be started