 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- type ActiveDeployConfigRequest
- type AutoDelete
- type AutoDeploy
- type Cluster
- type ClusterCreateSpec
- type ClusterServiceClient
- type ClusterSpec
- type ClusterUpdateSpec
- type DEPLOY_STATUS
- type DESCRIBE_BY
- type DeleteClusterRequest
- type DeployConfigStatus
- type DeployStatus
- func (d *DeployStatus) SetMessage(m string) *DeployStatus
- func (d *DeployStatus) SetReplicas(r int32) *DeployStatus
- func (d *DeployStatus) SetStatus(s DEPLOY_STATUS) *DeployStatus
- func (d *DeployStatus) SetSyncAt(t time.Time) *DeployStatus
- func (d *DeployStatus) SetUpdateAt(t time.Time) *DeployStatus
- func (d *DeployStatus) TableName() string
 
- type DescribeClusterRequest
- type K8sDeployConfig
- type PURPOSE
- type QueryClusterRequest
- type QueryClusterSpec
- type RPC
- type Service
- type TYPE
- type UpdateClusterRequest
- type UpdateDeployConfigRequest
- type UpdateDeployStatusRequest
- type VmDeployConfig
Constants ¶
      View Source
      
  
    const (
	APP_NAME = "cluster"
)
    
      View Source
      
  
const (
	RESOURCE_PREFIX = "dep"
)
    Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveDeployConfigRequest ¶
type ActiveDeployConfigRequest struct {
	DescribeClusterRequest
}
    func NewActiveDeployConfigRequest ¶
func NewActiveDeployConfigRequest(clusterId string) *ActiveDeployConfigRequest
type AutoDelete ¶
type AutoDeploy ¶
type Cluster ¶
type Cluster struct {
	// 集群Id
	Id string `json:"id" bson:"_id" gorm:"column:id;primaryKey"`
	// 更新时间
	UpdateAt *time.Time `json:"update_at" bson:"update_at" gorm:"column:update_at"`
	// 删除时间
	DeleteAt *time.Time `json:"delete_at" bson:"delete_at" gorm:"column:delete_at"`
	// 删除人
	DeleteBy string `json:"delete_by" bson:"delete_by" gorm:"column:delete_by"`
	// 集群属性
	ClusterSpec
}
    func NewCluster ¶
func NewCluster(spec ClusterSpec) (*Cluster, error)
type ClusterCreateSpec ¶
type ClusterCreateSpec struct {
	// 创建时间
	CreateAt time.Time `json:"create_at" bson:"create_at" gorm:"column:create_at"`
	// 应用Id
	AppServiceId string `json:"app_service_id" bson:"app_service_id" gorm:"column:app_service_id;varchar(64);"`
	// 集群类型, 承载应用运行的资源是什么, 例如: k8s, vm, baremetal, lambda, ...
	Type TYPE `json:"type" bson:"type" gorm:"column:type;type:varchar(60)"`
	// 用途
	Purpose PURPOSE `json:"purpose" bson:"purpose" gorm:"column:purpose;type:varchar(60)"`
	// 允许更新的属性
	ClusterUpdateSpec
	// 集群部署状态
	DeployStatus
}
    type ClusterServiceClient ¶
type ClusterServiceClient struct {
	// contains filtered or unexported fields
}
    要封装原始的 不友好的rpc call
func NewClusterServiceClient ¶
func NewClusterServiceClient() *ClusterServiceClient
func (*ClusterServiceClient) RPCUpdateDeployStatus ¶
func (c *ClusterServiceClient) RPCUpdateDeployStatus(ctx context.Context, in *UpdateDeployStatusRequest) (*Cluster, error)
type ClusterSpec ¶
type ClusterSpec struct {
	// 集群所属域
	Domain string `json:"domain" form:"domain" bson:"domain" gorm:"column:domain;type:varchar(120)"`
	// 集群所属空间
	Namespace string `json:"namespace" form:"namespace" bson:"namespace" gorm:"column:namespace;type:varchar(120)"`
	// 创建人
	Creator string `json:"creator" bson:"creator" gorm:"column:creator;type:varchar(60)"`
	// 创建信息
	ClusterCreateSpec
}
    类似于Docker Compose,或者Stack,应用集群可以关联应用的各种部署资源
func NewClusterSpec ¶
func NewClusterSpec() *ClusterSpec
func (*ClusterSpec) SetAutoDeleteEnabled ¶
func (r *ClusterSpec) SetAutoDeleteEnabled(v bool) *ClusterSpec
func (*ClusterSpec) SetAutoDeployEnabled ¶
func (r *ClusterSpec) SetAutoDeployEnabled(v bool) *ClusterSpec
func (*ClusterSpec) Validate ¶
func (r *ClusterSpec) Validate() error
type ClusterUpdateSpec ¶
type ClusterUpdateSpec struct {
	// 名称
	Name string `json:"name" bson:"name" validate:"required" gorm:"column:name;type:varchar(120)"`
	// 集群描述
	Description string `json:"description" bson:"description" gorm:"column:description"`
	// K8s部署信息
	K8sDeployConfig K8sDeployConfig `json:"k8s_deploy_config" bson:"k8s_deploy_config" gorm:"embedded"`
	// 虚拟机部署配置
	VmDeployConfig VmDeployConfig `json:"vm_deploy_config" bson:"vm_deploy_config" gorm:"embedded"`
	// 自动部署配置
	AutoDeploy AutoDeploy `json:"auto_deploy" bson:"auto_deploy" gorm:"embedded"`
	// 自动清理配置
	AutoDelete AutoDelete `json:"auto_delete" bson:"auto_delete" gorm:"embedded"`
	// 集群标签, env=prod
	Lables map[string]string `json:"lables" form:"lables" bson:"lables" gorm:"column:lables;serializer:json;"`
	// 额外的其他属性
	Extras map[string]string `json:"extras" form:"extras" bson:"extras" gorm:"column:extras;serializer:json;"`
}
    type DEPLOY_STATUS ¶
type DEPLOY_STATUS string
const ( // 未部署 DEPLOY_STATUS_UNDEPLOYED DEPLOY_STATUS = "UNDEPLOYED" // 正在滚动更新(新 ReplicaSet 正在创建 Pod) DEPLOY_STATUS_PROGRESSING DEPLOY_STATUS = "PROGRESSING" // 所有 Pod 已就绪,且最小可用副本数(minReadySeconds)已满足 DEPLOY_STATUS_AVAILABLE DEPLOY_STATUS = "AVAILABLE" // 部分 Pod 不可用(副本未达到预期,或 Pod 崩溃) DEPLOY_STATUS_DEGRADED DEPLOY_STATUS = "DEGRADED" // 更新失败(如镜像拉取错误、资源不足等) DEPLOY_STATUS_FAILED DEPLOY_STATUS = "FAILED" // 人为主动停止服务,无 Pod 运行 DEPLOY_STATUS_STOPPED DEPLOY_STATUS = "STOPPED" // 滚动更新完成(所有 Pod 已更新至最新版本) DEPLOY_STATUS_COMPLETE DEPLOY_STATUS = "COMPLETE" // 无滚动更新,且所有 Pod 正常运行 DEPLOY_STATUS_STABLE DEPLOY_STATUS = "STABLE" )
func ComputeK8sDeploymentStatus ¶
func ComputeK8sDeploymentStatus(deploy *appsv1.Deployment) (DEPLOY_STATUS, string)
type DeleteClusterRequest ¶
type DeleteClusterRequest struct {
	// 应用集群Id
	Id string `json:"id"`
}
    type DeployConfigStatus ¶
type DeployConfigStatus struct {
	// 是否已经生效, 如果未生效需要等到下次部署生效
	IsActive bool `json:"is_active" bson:"is_active" gorm:"column:is_active"`
	// 最近一次生效时间
	LastActive *time.Time `json:"last_active" bson:"last_active" gorm:"column:last_active"`
}
    func (*DeployConfigStatus) SetLastActive ¶
func (d *DeployConfigStatus) SetLastActive(t time.Time) *DeployConfigStatus
func (DeployConfigStatus) TableName ¶
func (d DeployConfigStatus) TableName() string
type DeployStatus ¶
type DeployStatus struct {
	// 同步时间
	SyncAt *time.Time `json:"sync_at" bson:"deploy_sync_at" gorm:"column:deploy_sync_at"`
	// 状态更新时间
	UpdateAt *time.Time `json:"update_at" bson:"deploy_update_at" gorm:"column:deploy_update_at"`
	// 部署状态详情, k8s deployment yaml
	Detail string `json:"detail" bson:"deploy_detail" gorm:"column:deploy_detail"`
	// 副本数量
	Replicas int32 `json:"replicas" bson:"deploy_replicas" gorm:"column:deploy_replicas"`
	// 部署状态
	Status DEPLOY_STATUS `json:"status" bson:"deploy_status" gorm:"column:deploy_status;type:varchar(60)"`
	// 状态解释
	Message string `json:"message" bson:"message" gorm:"column:message"`
}
    同步回来的Deployment信息
func (*DeployStatus) SetMessage ¶
func (d *DeployStatus) SetMessage(m string) *DeployStatus
func (*DeployStatus) SetReplicas ¶
func (d *DeployStatus) SetReplicas(r int32) *DeployStatus
func (*DeployStatus) SetStatus ¶
func (d *DeployStatus) SetStatus(s DEPLOY_STATUS) *DeployStatus
func (*DeployStatus) SetSyncAt ¶
func (d *DeployStatus) SetSyncAt(t time.Time) *DeployStatus
func (*DeployStatus) SetUpdateAt ¶
func (d *DeployStatus) SetUpdateAt(t time.Time) *DeployStatus
func (*DeployStatus) TableName ¶
func (d *DeployStatus) TableName() string
type DescribeClusterRequest ¶
type DescribeClusterRequest struct {
	// 应用集群Id
	Id string `json:"id"`
	// 是否关联查询集群实例信息
	WithInstance bool `json:"with_instance"`
	// 是否关联查询集群服务信息
	WithService bool `json:"with_service"`
}
    func NewDescribeClusterRequest ¶
func NewDescribeClusterRequest(clusterId string) *DescribeClusterRequest
type K8sDeployConfig ¶
type K8sDeployConfig struct {
	// K8s集群Id
	K8sId string `json:"k8s_id" form:"k8s_id" bson:"k8s_id" gorm:"column:k8s_id;type:varchar(120)"`
	// 空间
	Namespace string `json:"k8s_namespace" form:"k8s_namespace" bson:"k8s_namespace" gorm:"column:k8s_namespace;type:varchar(120)"`
	// 工作负载类型
	WorkloadKind workload.WORKLOAD_KIND `json:"k8s_workload_kind" form:"k8s_workload_kind" bson:"k8s_workload_kind" gorm:"column:k8s_workload_kind"`
	// 部署配置
	WorkloadYaml string `json:"k8s_workload_yaml" form:"k8s_workload_yaml" bson:"k8s_workload_yaml" gorm:"column:k8s_workload_yaml"`
	// 部署配置状态
	DeployConfigStatus
}
    type PURPOSE ¶
type PURPOSE string
const ( // 功能开发 PURPOSE_DEV_FEATURE PURPOSE = "dev-featrue" // 集成开发, 开发联合调 PURPOSE_DEV_CI PURPOSE = "dev-ci" // 功能测试 PURPOSE_TEST_FEATURE PURPOSE = "test-feature" // 性能测试 PURPOSE_TEST_PERFORMANCE PURPOSE = "test-performance" // 提测 PURPOSE_TEST_RELEASE PURPOSE = "test-release" // 预发验证(内部测试) PURPOSE_RELEASE_PRE PURPOSE = "release-pre" // 灰度验证(用户流量) PURPOSE_RELEASE_GRAY PURPOSE = "release-gray" // 线上: 蓝绿部署 PURPOSE_ONLINE_BLUE_GREEN PURPOSE = "online-blue-green" // 线上: 滚动部署 PURPOSE_ONLINE_ROLL_UPGRADE PURPOSE = "online-roll-upgrade" )
type QueryClusterRequest ¶
type QueryClusterRequest struct {
	policy.ResourceScope
	QueryClusterSpec
}
    func NewQueryClusterRequest ¶
func NewQueryClusterRequest() *QueryClusterRequest
type QueryClusterSpec ¶
type RPC ¶
type RPC interface {
	// 更新应用集群部署状态
	RPCUpdateDeployStatus(context.Context, *UpdateDeployStatusRequest) (*Cluster, error)
}
    type Service ¶
type Service interface {
	// 创建应用集群
	CreateCluster(context.Context, *ClusterSpec) (*Cluster, error)
	// 查询应用集群
	QueryCluster(context.Context, *QueryClusterRequest) (*types.Set[*Cluster], error)
	// 查询应用集群详情
	DescribeCluster(context.Context, *DescribeClusterRequest) (*Cluster, error)
	// 更新应用集群
	UpdateCluster(context.Context, *UpdateClusterRequest) (*Cluster, error)
	// 删除应用集群
	DeleteCluster(context.Context, *DeleteClusterRequest) (*Cluster, error)
	// 标记部署配置是否已经完成部署
	ActiveDeployConfig(context.Context, *ActiveDeployConfigRequest) (*Cluster, error)
	RPC
}
    func GetService ¶
func GetService() Service
type UpdateClusterRequest ¶
type UpdateClusterRequest struct {
	DescribeClusterRequest
	ClusterUpdateSpec
}
    type UpdateDeployConfigRequest ¶
type UpdateDeployConfigRequest struct {
	DescribeClusterRequest
}
    type UpdateDeployStatusRequest ¶
type UpdateDeployStatusRequest struct {
	DescribeClusterRequest
	DeployStatus
}
    func NewUpdateDeployStatusRequest ¶
func NewUpdateDeployStatusRequest(clusterId string) *UpdateDeployStatusRequest
 Click to show internal directories. 
   Click to hide internal directories.