client

package
v5.2.0-beta1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: LGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Running node running status
	Running = "running"
	//Offline node offline status
	Offline = "offline"
	//Unknown node unknown status
	Unknown = "unknown"
	//Error node error status
	Error = "error"
	//Init node init status
	Init = "init"
	//InstallSuccess node install success status
	InstallSuccess = "install_success"
	//InstallFailed node install failure status
	InstallFailed = "install_failed"
	//Installing node installing status
	Installing = "installing"
	//NotInstalled node not install status
	NotInstalled = "not_installed"
)
View Source
const RainbondEndpointPrefix = "/rainbond/endpoint"

RainbondEndpointPrefix is the prefix of the key of the rainbond endpoints in etcd

Variables

View Source
var ComputeNode = "compute"

ComputeNode 计算节点

View Source
var ErrorNotFound = fmt.Errorf("node not found")

ErrorNotFound node not found.

View Source
var GatewayNode = "gateway"

GatewayNode 边缘负载均衡节点

View Source
var LabelOS = "beta.kubernetes.io/os"

LabelOS node label about os

View Source
var ManageNode = "manage"

ManageNode 管理节点

View Source
var StorageNode = "storage"

StorageNode 存储节点

SupportNodeRule -

Functions

func IsMasterCondition

func IsMasterCondition(con NodeConditionType) bool

IsMasterCondition Whether it is a preset condition of the system

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        HostRule          `json:"role" validate:"role|required"`
	PodCIDR     string            `json:"podCIDR"`
	AutoInstall bool              `json:"auto_install"`
	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
}

AllocatedResources -

type ClusterClient

type ClusterClient interface {
	UpdateStatus(*HostNode, []NodeConditionType) error
	DownNode(*HostNode) error
	GetMasters() ([]*HostNode, error)
	GetNode(nodeID string) (*HostNode, error)
	RegistNode(node *HostNode) error
	GetDataCenterConfig() (*config.DataCenterConfig, error)
	GetOptions() *option.Conf
	GetEndpoints(key string) []string
	SetEndpoints(serviceName, hostIP string, value []string)
	DelEndpoints(key string)
}

ClusterClient ClusterClient

func NewClusterClient

func NewClusterClient(conf *option.Conf) ClusterClient

NewClusterClient new cluster client

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, gateway
	Status          string            `json:"status"`
	Labels          map[string]string `json:"labels"`        // system labels
	CustomLabels    map[string]string `json:"custom_labels"` // custom labels
	Unschedulable   bool              `json:"unschedulable"` // 设置值
	PodCIDR         string            `json:"podCIDR"`
	NodeStatus      NodeStatus        `json:"node_status"`
}

HostNode rainbond node entity

func GetNodeFromKV

func GetNodeFromKV(kv *mvccpb.KeyValue) *HostNode

GetNodeFromKV 从etcd解析node信息

func (*HostNode) Decode

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

Decode decode node info

func (*HostNode) DelEndpoints

func (n *HostNode) DelEndpoints()

DelEndpoints -

func (*HostNode) DeleteCondition

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

DeleteCondition DeleteCondition

func (*HostNode) DeleteNode

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

DeleteNode delete node

func (*HostNode) GetAndUpdateCondition

func (n *HostNode) GetAndUpdateCondition(condType NodeConditionType, status ConditionStatus, reason, message string)

GetAndUpdateCondition get old condition and update it, if old condition is nil and then create it

func (*HostNode) GetCondition

func (n *HostNode) GetCondition(ctype NodeConditionType) *NodeCondition

GetCondition get condition

func (*HostNode) MergeLabels

func (n *HostNode) MergeLabels() map[string]string

MergeLabels merges custom lables into labels.

func (*HostNode) String

func (n *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 (n *HostNode) Update() (*client.PutResponse, error)

Update update node info

func (*HostNode) UpdateK8sNodeStatus

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

UpdateK8sNodeStatus update rainbond node status by k8s node

func (*HostNode) UpdateReadyStatus

func (n *HostNode) UpdateReadyStatus()

UpdateReadyStatus UpdateReadyStatus

type HostRule

type HostRule []string

HostRule 节点角色

func (*HostRule) Add

func (h *HostRule) Add(role ...string)

Add add role

func (HostRule) HasRule

func (h HostRule) HasRule(rule string) bool

HasRule 是否具有什么角色

func (HostRule) String

func (h HostRule) String() string

func (HostRule) Validation

func (h HostRule) Validation() error

Validation host rule validation

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"
	KubeNodeReady NodeConditionType = "KubeNodeReady"
	NodeUp        NodeConditionType = "NodeUp"
	// InstallNotReady means  the installation task was not completed in this node.
	InstallNotReady NodeConditionType = "InstallNotReady"
	OutOfDisk       NodeConditionType = "OutOfDisk"
	MemoryPressure  NodeConditionType = "MemoryPressure"
	DiskPressure    NodeConditionType = "DiskPressure"
	PIDPressure     NodeConditionType = "PIDPressure"
)

These are valid conditions of node.

func (NodeConditionType) Compare

func (nt NodeConditionType) Compare(ent NodeConditionType) bool

Compare 比较

type NodeList

type NodeList []*HostNode

NodeList node list

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"`
}

NodePodResource -

type NodeStatus

type NodeStatus struct {
	//worker maintenance
	Version string `json:"version"`
	//worker maintenance example: unscheduler, offline
	//Initiate a recommendation operation to the master based on the node state
	AdviceAction []string `json:"advice_actions"`
	//worker maintenance
	Status string `json:"status"` //installed running offline unknown
	//master maintenance
	CurrentScheduleStatus bool `json:"current_scheduler"`
	//master maintenance
	NodeHealth bool `json:"node_health"`
	//worker maintenance
	NodeUpdateTime time.Time `json:"node_update_time"`
	//master maintenance
	KubeUpdateTime time.Time `json:"kube_update_time"`
	//worker maintenance node progress down time
	LastDownTime time.Time `json:"down_time"`
	//worker and master maintenance
	Conditions []NodeCondition `json:"conditions,omitempty"`
	//master maintenance
	KubeNode *v1.Node
	//worker and master maintenance
	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"`
	NumCPU     int64  `json:"cpu_num"`
}

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

type Resource

type Resource struct {
	CPU  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