client

package
Version: v3.7.1-release+incompa... Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ComputeNode = "compute"

ComputeNode 计算节点

View Source
var LBNode = "lb"

LBNode 边缘负载均衡节点

View Source
var ManageNode = "manage"

ManageNode 管理节点

View Source
var StorageNode = "storage"

StorageNode 存储节点

Functions

This section is empty.

Types

type APIHostNode

type APIHostNode struct {
	ID         string            `json:"uuid" validate:"uuid"`
	HostName   string            `json:"host_name" validate:"host_name"`
	InternalIP string            `json:"internal_ip" validate:"internal_ip|ip"`
	ExternalIP string            `json:"external_ip" validate:"external_ip|ip"`
	RootPass   string            `json:"root_pass,omitempty"`
	Privatekey string            `json:"private_key,omitempty"`
	Role       string            `json:"role" validate:"role|required"`
	Labels     map[string]string `json:"labels"`
}

APIHostNode api host node

func (APIHostNode) Clone

func (a APIHostNode) Clone() *HostNode

Clone Clone

type AllocatedResources

type AllocatedResources struct {
	CPURequests     int64
	CPULimits       int64
	MemoryRequests  int64
	MemoryLimits    int64
	MemoryRequestsR string
	MemoryLimitsR   string
	CPURequestsR    string
	CPULimitsR      string
}

type ClusterClient

type ClusterClient interface {
	UpdateStatus(*HostNode) error
	DownNode(*HostNode) error
	GetMasters() ([]*HostNode, error)
	GetNode(nodeID string) (*HostNode, error)
	GetDataCenterConfig() (*config.DataCenterConfig, error)
	GetOptions() *option.Conf
	GetEndpoints(key string) []string
	SetEndpoints(key string, value []string)
	WatchJobs() <-chan *job.Event
}

ClusterClient ClusterClient

func NewClusterClient

func NewClusterClient(conf *option.Conf, etcdClient *clientv3.Client) ClusterClient

NewClusterClient new cluster client

type ClusterNode

type ClusterNode struct {
	PID       string    `json:"pid"` // 进程 pid
	Version   string    `json:"version"`
	UpTime    time.Time `json:"up"`        // 启动时间
	DownTime  time.Time `json:"down"`      // 上次关闭时间
	Alived    bool      `json:"alived"`    // 是否可用
	Connected bool      `json:"connected"` // 当 Alived 为 true 时有效,表示心跳是否正常
}

ClusterNode 集群节点实体

type ConditionStatus

type ConditionStatus string

ConditionStatus ConditionStatus

const (
	ConditionTrue    ConditionStatus = "True"
	ConditionFalse   ConditionStatus = "False"
	ConditionUnknown ConditionStatus = "Unknown"
)

These are valid condition statuses. "ConditionTrue" means a resource is in the condition. "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes can't decide if a resource is in the condition or not. In the future, we could add other intermediate conditions, e.g. ConditionDegraded.

type HostNode

type HostNode struct {
	ID              string            `json:"uuid"`
	HostName        string            `json:"host_name"`
	CreateTime      time.Time         `json:"create_time"`
	InternalIP      string            `json:"internal_ip"`
	ExternalIP      string            `json:"external_ip"`
	RootPass        string            `json:"root_pass,omitempty"`
	KeyPath         string            `json:"key_path,omitempty"` //管理节点key文件路径
	AvailableMemory int64             `json:"available_memory"`
	AvailableCPU    int64             `json:"available_cpu"`
	Mode            string            `json:"mode"`
	Role            HostRule          `json:"role"`          //节点属性 compute manage storage
	Status          string            `json:"status"`        //节点状态 create,init,running,stop,delete
	Labels          map[string]string `json:"labels"`        //节点标签 内置标签+用户自定义标签
	Unschedulable   bool              `json:"unschedulable"` //不可调度
	NodeStatus      *NodeStatus       `json:"node_status,omitempty"`
	ClusterNode
}

HostNode rainbond node entity

func GetNodeFromKV

func GetNodeFromKV(kv *mvccpb.KeyValue) *HostNode

GetNodeFromKV 从etcd解析node信息

func GetNodes

func GetNodes() (nodes []*HostNode, err error)

GetNodes 获取节点

func (*HostNode) Decode

func (n *HostNode) Decode(data []byte) error

Decode decode node info

func (*HostNode) Del

func (h *HostNode) Del() (*client.DeleteResponse, error)

Del 删除

func (*HostNode) DeleteCondition

func (n *HostNode) DeleteCondition(types ...NodeConditionType)

DeleteCondition DeleteCondition

func (*HostNode) DeleteNode

func (h *HostNode) DeleteNode() (*client.DeleteResponse, error)

DeleteNode 删除节点

func (*HostNode) Down

func (h *HostNode) Down()

Down 节点下线

func (*HostNode) Put

func (h *HostNode) Put(opts ...client.OpOption) (*client.PutResponse, error)

Put 节点上线更新

func (*HostNode) String

func (h *HostNode) String() string

String string

func (*HostNode) UpdataCondition

func (n *HostNode) UpdataCondition(conditions ...NodeCondition)

UpdataCondition 更新状态

func (*HostNode) UpdataK8sCondition

func (n *HostNode) UpdataK8sCondition(conditions []v1.NodeCondition)

UpdataK8sCondition 更新k8s节点的状态到rainbond节点

func (*HostNode) Update

func (h *HostNode) Update() (*client.PutResponse, error)

Update 更新节点信息,由节点启动时调用

func (*HostNode) UpdateK8sNodeStatus

func (n *HostNode) UpdateK8sNodeStatus(k8sNode v1.Node)

UpdateK8sNodeStatus update rainbond node status by k8s node

type HostRule

type HostRule []string

HostRule 节点角色

func (HostRule) HasRule

func (h HostRule) HasRule(rule string) bool

HasRule 是否具有什么角色

func (HostRule) String

func (h HostRule) String() string

type NodeCondition

type NodeCondition struct {
	// Type of node condition.
	Type NodeConditionType `json:"type" `
	// Status of the condition, one of True, False, Unknown.
	Status ConditionStatus `json:"status" `
	// Last time we got an update on a given condition.
	// +optional
	LastHeartbeatTime time.Time `json:"lastHeartbeatTime,omitempty" `
	// Last time the condition transit from one status to another.
	// +optional
	LastTransitionTime time.Time `json:"lastTransitionTime,omitempty" `
	// (brief) reason for the condition's last transition.
	// +optional
	Reason string `json:"reason,omitempty"`
	// Human readable message indicating details about last transition.
	// +optional
	Message string `json:"message,omitempty"`
}

NodeCondition contains condition information for a node.

type NodeConditionType

type NodeConditionType string

NodeConditionType NodeConditionType

const (
	// NodeReady means this node is working
	NodeReady NodeConditionType = "Ready"
	// InstallNotReady means  the installation task was not completed in this node.
	InstallNotReady NodeConditionType = "InstallNotReady"
	// NodeInit means node already install rainbond node and regist
	NodeInit       NodeConditionType = "NodeInit"
	OutOfDisk      NodeConditionType = "OutOfDisk"
	MemoryPressure NodeConditionType = "MemoryPressure"
	DiskPressure   NodeConditionType = "DiskPressure"
)

These are valid conditions of node.

func (NodeConditionType) Compare

func (nt NodeConditionType) Compare(ent NodeConditionType) bool

Compare 比较

type NodeList

type NodeList []*HostNode

func (NodeList) Len

func (list NodeList) Len() int

func (NodeList) Less

func (list NodeList) Less(i, j int) bool

func (NodeList) Swap

func (list NodeList) Swap(i, j int)

type NodePodResource

type NodePodResource struct {
	AllocatedResources `json:"allocatedresources"`
	Resource           `json:"allocatable"`
}

type NodeStatus

type NodeStatus struct {
	Status     string          `json:"status"` //installed running offline unknown
	Conditions []NodeCondition `json:"conditions,omitempty"`
	NodeInfo   NodeSystemInfo  `json:"nodeInfo,omitempty" protobuf:"bytes,7,opt,name=nodeInfo"`
}

NodeStatus node status

type NodeSystemInfo

type NodeSystemInfo struct {
	// MachineID reported by the node. For unique machine identification
	// in the cluster this field is preferred. Learn more from man(5)
	// machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html
	MachineID string `json:"machineID"`
	// SystemUUID reported by the node. For unique machine identification
	// MachineID is preferred. This field is specific to Red Hat hosts
	// https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/getting-system-uuid.html
	SystemUUID string `json:"systemUUID"`
	// Boot ID reported by the node.
	BootID string `json:"bootID" protobuf:"bytes,3,opt,name=bootID"`
	// Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).
	KernelVersion string `json:"kernelVersion" `
	// OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).
	OSImage string `json:"osImage"`
	// ContainerRuntime Version reported by the node through runtime remote API (e.g. docker://1.5.0).
	ContainerRuntimeVersion string `json:"containerRuntimeVersion"`
	// The Operating System reported by the node
	OperatingSystem string `json:"operatingSystem"`
	// The Architecture reported by the node
	Architecture string `json:"architecture"`

	MemorySize uint64 `json:"memorySize"`
}

NodeSystemInfo is a set of ids/uuids to uniquely identify the node.

type Resource

type Resource struct {
	CpuR int `json:"cpu"`
	MemR int `json:"mem"`
}

Resource 资源

Jump to

Keyboard shortcuts

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