k8s

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName    = "k8s"
	SECRET_KEY = "23gs6gxHrz1kNEvshRmunkXbwIiaEcYfh+EMu+e9ewA="
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Id string `json:"id" bson:"_id"`
	// 录入时间
	CreateAt int64 `json:"create_at" bson:"create_at"`
	// 更新时间
	UpdateAt int64 `json:"update_at" bson:"update_at"`
	// 更新人
	UpdateBy string `json:"update_by" bson:"update_by"`
	// 集群相关信息
	ServerInfo ServerInfo `json:"server_info" bson:",inline"`

	// 集群定义信息
	CreateClusterRequest `bson:",inline"`

	// 集群状态
	Status Status `json:"status" bson:",inline"`
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(req *CreateClusterRequest) (*Cluster, error)

func (*Cluster) DecryptedKubeConf

func (r *Cluster) DecryptedKubeConf() error

func (*Cluster) EncryptedKubeConf

func (r *Cluster) EncryptedKubeConf() error

func (*Cluster) GetK8sClient

func (c *Cluster) GetK8sClient() (*k8s_client.Client, error)

func (*Cluster) IsAlive

func (i *Cluster) IsAlive() error

func (*Cluster) SetIsEncrypted

func (r *Cluster) SetIsEncrypted(v bool)

func (*Cluster) String

func (r *Cluster) String() string

type CreateClusterRequest

type CreateClusterRequest struct {
	// 集群所属域
	Domain string `json:"domain" form:"domain" bson:"domain"`
	// 集群所属空间
	Namespace string `json:"namespace" form:"namespace" bson:"namespace"`
	// 创建人
	CreateBy string `json:"create_by" form:"create_by" bson:"create_by"`
	// 集群提供商
	Provider string `json:"provider" bson:"provider" form:"provider" validate:"required"`
	// 集群所处地域
	Region string `json:"region" bson:"region" form:"region" validate:"required"`
	// 名称
	Name string `json:"name" bson:"name" form:"name" validate:"required"`
	// 集群客户端访问凭证
	KubeConfig string `json:"kube_config" bson:"kube_config" form:"kube_config" validate:"required" mask:",10,10"`
	// 集群描述
	Description string `json:"description" form:"description" bson:"description"`
	// 集群标签, env=prod
	Lables map[string]string `json:"lables" form:"lables" bson:"lables"`
}

func (CreateClusterRequest) Validate

func (req CreateClusterRequest) Validate() error

type DeleteClusterRequest

type DeleteClusterRequest struct {
	// Cluster id
	Id string `json:"id"`
}

type DescribeClusterRequest

type DescribeClusterRequest struct {
	// Cluster id
	Id string `json:"id"`
}

type QueryClusterRequest

type QueryClusterRequest struct {
	// 资源范围
	Scope *resource.Scope `json:"scope"`
	// 资源标签过滤
	Filters []*resource.LabelRequirement `json:"filters"`
	// 分页参数
	Page *request.PageRequest `json:"page"`
	// 关键字参数
	Keywords string `json:"keywords"`
	// 集群所属厂商
	Vendor string `json:"vendor"`
	// 集群所属地域
	Region string `json:"region"`
	// 集群Id列表
	ClusterIds []string `json:"cluster_ids"`
}

type ServerInfo

type ServerInfo struct {
	// k8s的地址
	Server string `json:"server" bson:"server"`
	// k8s版本
	Version string `json:"version" bson:"version"`
	// 连接用户
	AuthUser string `json:"auth_user" bson:"auth_user"`
}

type Service

type Service interface {
	QueryCluster(context.Context, *QueryClusterRequest) (types.Set[*Cluster], error)
	DescribeCluster(context.Context, *DescribeClusterRequest) (*Cluster, error)
	CreateCluster(context.Context, *CreateClusterRequest) (*Cluster, error)
	UpdateCluster(context.Context, *UpdateClusterRequest) (*Cluster, error)
	DeleteCluster(context.Context, *DeleteClusterRequest) (*Cluster, error)
}

func GetService

func GetService() Service

type Status

type Status struct {
	// 检查时间
	CheckAt int64 `json:"check_at" bson:"check_at"`
	// API Server是否正常
	IsAlive bool `json:"is_alive" bson:"is_alive"`
	// 异常消息
	Message string `json:"message" bson:"message"`
}

type UpdateClusterRequest

type UpdateClusterRequest struct {
	// Cluster id
	Id string `json:"id"`
	// 更新模式
	UpdateMode request1.UpdateMode `json:"update_mode"`
	// 更新人
	UpdateBy string `json:"update_by"`
	// 更新时间
	UpdateAt int64 `json:"update_at"`
	// 更新的书本信息
	Spec *CreateClusterRequest `json:"spec"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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