admin

package
v0.0.0-...-d741a62 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskPending   = "Pending"
	TaskFailed    = "Failed"
	TaskSucceeded = "Succeeded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterService

type ClusterService interface {
	// ListAllClusters 获取所有 Kubernetes 集群
	ListAllClusters(ctx context.Context) ([]*model.K8sCluster, error)
	// CreateCluster 创建一个新的 Kubernetes 集群
	CreateCluster(ctx context.Context, cluster *model.K8sCluster) error
	// UpdateCluster 更新指定 ID 的 Kubernetes 集群
	UpdateCluster(ctx context.Context, cluster *model.K8sCluster) error
	// DeleteCluster 删除指定 ID 的 Kubernetes 集群
	DeleteCluster(ctx context.Context, id int) error
	// BatchDeleteClusters 批量删除 Kubernetes 集群
	BatchDeleteClusters(ctx context.Context, ids []int) error
	// GetClusterByID 根据 ID 获取单个 Kubernetes 集群
	GetClusterByID(ctx context.Context, id int) (*model.K8sCluster, error)
}

func NewClusterService

func NewClusterService(dao admin.ClusterDAO, client client.K8sClient, l *zap.Logger) ClusterService

NewClusterService 创建并返回一个 ClusterService 实例

type ConfigMapService

type ConfigMapService interface {
	GetConfigMapsByNamespace(ctx context.Context, id int, namespace string) ([]*corev1.ConfigMap, error)
	UpdateConfigMap(ctx context.Context, configMap *model.K8sConfigMapRequest) error
	GetConfigMapYaml(ctx context.Context, id int, namespace, configMapName string) (*corev1.ConfigMap, error)
	DeleteConfigMap(ctx context.Context, id int, namespace, configMapName string) error
	BatchDeleteConfigMap(ctx context.Context, id int, namespace string, configMapNames []string) error
}

func NewConfigMapService

func NewConfigMapService(dao admin.ClusterDAO, client client.K8sClient, logger *zap.Logger) ConfigMapService

type DeploymentService

type DeploymentService interface {
	GetDeploymentsByNamespace(ctx context.Context, id int, namespace string) ([]*appsv1.Deployment, error)
	UpdateDeployment(ctx context.Context, deployment *model.K8sDeploymentRequest) error
	BatchDeleteDeployment(ctx context.Context, id int, namespace string, deploymentNames []string) error
	DeleteDeployment(ctx context.Context, id int, namespace, deploymentName string) error
	BatchRestartDeployments(ctx context.Context, req *model.K8sDeploymentRequest) error
	RestartDeployment(ctx context.Context, id int, namespace, deploymentName string) error
	GetDeploymentYaml(ctx context.Context, id int, namespace, deploymentName string) (string, error)
}

func NewDeploymentService

func NewDeploymentService(dao admin.ClusterDAO, client client.K8sClient, logger *zap.Logger) DeploymentService

NewDeploymentService 创建新的 DeploymentService 实例

type NamespaceService

type NamespaceService interface {
	// GetClusterNamespacesList 获取命名空间列表
	GetClusterNamespacesList(ctx context.Context) ([]model.ClusterNamespaces, error)
	// GetClusterNamespacesById 获取指定集群的所有命名空间
	GetClusterNamespacesById(ctx context.Context, id int) ([]model.Namespace, error)
	// CreateNamespace 创建新的命名空间
	CreateNamespace(ctx context.Context, req model.CreateNamespaceRequest) error
	// DeleteNamespace 删除指定的命名空间
	DeleteNamespace(ctx context.Context, name string, id int) error
	// GetNamespaceDetails 获取指定命名空间的详情
	GetNamespaceDetails(ctx context.Context, name string, id int) (model.Namespace, error)
	// UpdateNamespace 更新指定命名空间
	UpdateNamespace(ctx context.Context, req model.UpdateNamespaceRequest) error
	// GetNamespaceResources 获取指定命名空间中的资源
	GetNamespaceResources(ctx context.Context, name string, id int) ([]model.Resource, error)
	// GetNamespaceEvents 获取指定命名空间中的事件
	GetNamespaceEvents(ctx context.Context, name string, id int) ([]model.Event, error)
}

func NewNamespaceService

func NewNamespaceService(dao admin.ClusterDAO, client client.K8sClient, logger *zap.Logger) NamespaceService

type NodeService

type NodeService interface {
	// ListNodeByClusterName 获取指定集群的节点列表
	ListNodeByClusterName(ctx context.Context, id int) ([]*model.K8sNode, error)
	// GetNodeDetail 获取指定节点详情
	GetNodeDetail(ctx context.Context, id int, name string) (*model.K8sNode, error)
	// AddOrUpdateNodeLabel 添加或删除指定节点的 Label
	AddOrUpdateNodeLabel(ctx context.Context, req *model.LabelK8sNodesRequest) error
}

func NewNodeService

func NewNodeService(clusterDao admin.ClusterDAO, client client.K8sClient, l *zap.Logger) NodeService

type PodService

type PodService interface {
	GetPodsByNamespace(ctx context.Context, clusterID int, namespace string) ([]*model.K8sPod, error)
	GetContainersByPod(ctx context.Context, clusterID int, namespace string, podName string) ([]*model.K8sPodContainer, error)
	GetContainerLogs(ctx context.Context, clusterID int, namespace, podName, containerName string) (string, error)
	GetPodYaml(ctx context.Context, clusterID int, namespace, podName string) (*corev1.Pod, error)
	GetPodsByNodeName(ctx context.Context, id int, name string) ([]*model.K8sPod, error)
	DeletePod(ctx context.Context, clusterId int, namespace, podName string) error
}

func NewPodService

func NewPodService(dao admin.ClusterDAO, client client.K8sClient, logger *zap.Logger) PodService

type SvcService

type SvcService interface {
	// GetServicesByNamespace 获取指定命名空间的 Service 列表
	GetServicesByNamespace(ctx context.Context, id int, namespace string) ([]*corev1.Service, error)
	// GetServiceYaml 获取指定 Service 的 YAML 配置
	GetServiceYaml(ctx context.Context, id int, namespace, serviceName string) (*corev1.Service, error)
	// DeleteService 删除 Service
	DeleteService(ctx context.Context, id int, namespace string, serviceNames string) error
	// BatchDeleteService 批量删除 Service
	BatchDeleteService(ctx context.Context, id int, namespace string, serviceNames []string) error
	// UpdateService 更新 Service
	UpdateService(ctx context.Context, serviceResource *model.K8sServiceRequest) error
}

func NewSvcService

func NewSvcService(dao admin.ClusterDAO, client client.K8sClient, l *zap.Logger) SvcService

type TaintService

type TaintService interface {
	// CheckTaintYaml 检查 Taint YAML 配置是否合法
	CheckTaintYaml(ctx context.Context, taint *model.TaintK8sNodesRequest) error
	// BatchEnableSwitchNodes 批量启用或禁用节点
	BatchEnableSwitchNodes(ctx context.Context, req *model.ScheduleK8sNodesRequest) error
	// AddOrUpdateNodeTaint 添加或更新节点的 Taint
	AddOrUpdateNodeTaint(ctx context.Context, taint *model.TaintK8sNodesRequest) error
	// DrainPods 驱逐 Pod
	DrainPods(ctx context.Context, req *model.K8sClusterNodesRequest) error
}

func NewTaintService

func NewTaintService(dao admin.ClusterDAO, client client.K8sClient, l *zap.Logger) TaintService

type YamlTaskService

type YamlTaskService interface {
	// GetYamlTaskList 获取 YAML 任务列表
	GetYamlTaskList(ctx context.Context) ([]*model.K8sYamlTask, error)
	// CreateYamlTask 创建 YAML 任务
	CreateYamlTask(ctx context.Context, task *model.K8sYamlTask) error
	// UpdateYamlTask 更新 YAML 任务
	UpdateYamlTask(ctx context.Context, task *model.K8sYamlTask) error
	// DeleteYamlTask 删除 YAML 任务
	DeleteYamlTask(ctx context.Context, id int) error
	// ApplyYamlTask 应用 YAML 任务
	ApplyYamlTask(ctx context.Context, id int) error
}

func NewYamlTaskService

func NewYamlTaskService(yamlTaskDao admin.YamlTaskDAO, clusterDao admin.ClusterDAO, yamlTemplateDao admin.YamlTemplateDAO, client client.K8sClient, l *zap.Logger) YamlTaskService

type YamlTemplateService

type YamlTemplateService interface {
	// GetYamlTemplateList 获取 YAML 模板列表
	GetYamlTemplateList(ctx context.Context, clusterId int) ([]*model.K8sYamlTemplate, error)
	// CreateYamlTemplate 创建 YAML 模板
	CreateYamlTemplate(ctx context.Context, template *model.K8sYamlTemplate) error
	// CheckYamlTemplate 检查 YAML 模板是否正确
	CheckYamlTemplate(ctx context.Context, template *model.K8sYamlTemplate) error
	// UpdateYamlTemplate 更新 YAML 模板
	UpdateYamlTemplate(ctx context.Context, template *model.K8sYamlTemplate) error
	// DeleteYamlTemplate 删除 YAML 模板
	DeleteYamlTemplate(ctx context.Context, id int, clusterId int) error
	// GetYamlTemplateDetail 获取 YAML 模板详情
	GetYamlTemplateDetail(ctx context.Context, id int, clusterId int) (string, error)
}

func NewYamlTemplateService

func NewYamlTemplateService(yamlTemplateDao admin.YamlTemplateDAO, yamlTaskDao admin.YamlTaskDAO, client client.K8sClient, l *zap.Logger) YamlTemplateService

Jump to

Keyboard shortcuts

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