Documentation ¶
Overview ¶
Copyright 2019 The KubeEdge Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func AddToolVals(f *pflag.Flag, flagData map[string]types.FlagData)
- func BuildConfig(kubeConfig, master string) (conf *rest.Config, err error)
- func CheckIfAvailable(val, defval string) string
- func GetLatestVersion() (string, error)
- func GetOSInterface() types.OSTypeInstaller
- func GetOSVersion() string
- func IsCloudCore() (types.ModuleRunning, error)
- func KubeClient(kubeConfigPath string) (*kubernetes.Clientset, error)
- type CentOS
- func (c *CentOS) InstallKubeEdge(componentType types.ComponentType) error
- func (c *CentOS) InstallMQTT() error
- func (c *CentOS) IsK8SComponentInstalled(kubeConfig, master string) error
- func (c *CentOS) IsKubeEdgeProcessRunning(proc string) (bool, error)
- func (c *CentOS) KillKubeEdgeBinary(proc string) error
- func (c *CentOS) RunEdgeCore() error
- func (c *CentOS) SetKubeEdgeVersion(version string)
- type Command
- type Common
- type K8SInstTool
- type KubeCloudInstTool
- type KubeEdgeInstTool
- type MQTTInstTool
- type UbuntuOS
- func (u *UbuntuOS) InstallKubeEdge(componentType types.ComponentType) error
- func (u *UbuntuOS) InstallMQTT() error
- func (u *UbuntuOS) IsK8SComponentInstalled(kubeConfig, master string) error
- func (u *UbuntuOS) IsKubeEdgeProcessRunning(proc string) (bool, error)
- func (u *UbuntuOS) KillKubeEdgeBinary(proc string) error
- func (u *UbuntuOS) RunEdgeCore() error
- func (u *UbuntuOS) SetKubeEdgeVersion(version string)
Constants ¶
const ( UbuntuOSType = "ubuntu" RaspbianOSType = "raspbian" CentOSType = "centos" KubeEdgeDownloadURL = "https://github.com/kubeedge/kubeedge/releases/download" EdgeCoreServiceFileURL = "https://raw.githubusercontent.com/kubeedge/kubeedge/release-%s/build/tools/%s" KubeEdgePath = "/etc/kubeedge/" KubeEdgeUsrBinPath = "/usr/local/bin" KubeEdgeConfPath = KubeEdgePath + "kubeedge/edge/conf" KubeEdgeBinaryName = "edgecore" KubeEdgeBinaryNamePre = "edge_core" KubeEdgeCloudDefaultCertPath = KubeEdgePath + "certs/" KubeEdgeConfigEdgeYaml = KubeEdgeConfPath + "/edge.yaml" KubeEdgeConfigModulesYaml = KubeEdgeConfPath + "/modules.yaml" KubeEdgeCloudCertGenPath = KubeEdgePath + "certgen.sh" KubeEdgeEdgeCertsTarFileName = "certs.tgz" KubeEdgeCloudConfPath = KubeEdgePath + "kubeedge/cloud/conf" KubeEdgeCloudCoreYaml = KubeEdgeCloudConfPath + "/controller.yaml" KubeEdgeCloudCoreModulesYaml = KubeEdgeCloudConfPath + "/modules.yaml" KubeCloudBinaryName = "cloudcore" KubeEdgeNewConfigDir = KubeEdgePath + "config/" KubeEdgeCloudCoreNewYaml = KubeEdgeNewConfigDir + "cloudcore.yaml" KubeEdgeEdgeCoreNewYaml = KubeEdgeNewConfigDir + "edgecore.yaml" KubeEdgeLogPath = "/var/log/kubeedge/" KubeEdgeCrdPath = KubeEdgePath + "crds" KubeEdgeCRDDownloadURL = "https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds" RetryTimes = 5 )
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=$1
genCertAndKey ${name} > /dev/null 2>&1
cat <<EOF
apiVersion: v1
kind: Secret
metadata:
name: cloudcore
namespace: kubeedge
labels:
k8s-app: kubeedge
kubeedge: cloudcore
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
`)
)
Edge controller Configuration files and certificate generator script
Functions ¶
func AddToolVals ¶
AddToolVals gets the value and default values of each flags and collects them in temporary cache
func BuildConfig ¶ added in v1.2.1
build Config from flags
func CheckIfAvailable ¶
CheckIfAvailable checks is val of a flag is empty then return the default value
func GetLatestVersion ¶ added in v1.2.1
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 IsCloudCore ¶
func IsCloudCore() (types.ModuleRunning, error)
IsCloudCore identifies if the node is having cloudcore already running. If so, then return true, else it can used as edge node and initialise it.
func KubeClient ¶ added in v1.4.0
func KubeClient(kubeConfigPath string) (*kubernetes.Clientset, error)
KubeClient from config
Types ¶
type CentOS ¶
CentOS struct objects shall have information of the tools version to be installed on Hosts having CentOS OS. It implements OSTypeInstaller interface
func (*CentOS) InstallKubeEdge ¶
func (c *CentOS) InstallKubeEdge(componentType types.ComponentType) 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 (*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) IsK8SComponentInstalled ¶
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) 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 edgecore with logs being captured
func (*CentOS) SetKubeEdgeVersion ¶
SetKubeEdgeVersion sets the KubeEdge version for the objects instance
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 { types.OSTypeInstaller OSVersion string ToolVersion string KubeConfig string Master string }
Common struct contains OS and Tool version properties and also embeds OS interface
func (*Common) SetOSInterface ¶
func (co *Common) SetOSInterface(intf types.OSTypeInstaller)
SetOSInterface defines a method to set the implemtation of the OS interface
type K8SInstTool ¶
type K8SInstTool struct {
Common
}
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 ¶
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 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 RuntimeType string InterfaceName string RemoteRuntimeEndpoint string Token string CertPort string }
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 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 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 UbuntuOS ¶
UbuntuOS struct objects shall have information of the tools version to be installed on Hosts having Ubuntu OS. It implements OSTypeInstaller interface
func (*UbuntuOS) InstallKubeEdge ¶
func (u *UbuntuOS) InstallKubeEdge(componentType types.ComponentType) 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 (*UbuntuOS) InstallMQTT ¶
InstallMQTT checks if MQTT is already installed and running, if not then install it from OS repo
func (*UbuntuOS) IsK8SComponentInstalled ¶
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) 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 edgecore with logs being captured
func (*UbuntuOS) SetKubeEdgeVersion ¶
SetKubeEdgeVersion sets the KubeEdge version for the objects instance