utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 通用状态
	StatusPending     = "Pending"
	StatusUnknown     = "Unknown"
	StatusReady       = "Ready"
	StatusTerminating = "Terminating"
	StatusRunning     = "Running"
	StatusUpdating    = "Updating"
	StatusSucceeded   = "Succeeded"
	StatusFailed      = "Failed"
	StatusEvicted     = "Evicted"
)

K8s资源状态常量定义

Variables

View Source
var NormalReasons = map[string]model.EventSeverity{
	"Scheduled":        model.EventSeverityLow,
	"Pulling":          model.EventSeverityLow,
	"Pulled":           model.EventSeverityLow,
	"Created":          model.EventSeverityLow,
	"Started":          model.EventSeverityLow,
	"Killing":          model.EventSeverityLow,
	"Preempting":       model.EventSeverityLow,
	"SuccessfulMount":  model.EventSeverityLow,
	"SuccessfulDelete": model.EventSeverityLow,
	"Sync":             model.EventSeverityLow,
}

NormalReasons 正常级别的事件原因

View Source
var WarningReasons = map[string]model.EventSeverity{
	"Failed":              model.EventSeverityHigh,
	"FailedMount":         model.EventSeverityHigh,
	"FailedScheduling":    model.EventSeverityHigh,
	"FailedSync":          model.EventSeverityMedium,
	"FailedValidation":    model.EventSeverityMedium,
	"Unhealthy":           model.EventSeverityHigh,
	"BackOff":             model.EventSeverityMedium,
	"DeadlineExceeded":    model.EventSeverityCritical,
	"Evicted":             model.EventSeverityHigh,
	"NodeNotReady":        model.EventSeverityCritical,
	"NodeNotSchedulable":  model.EventSeverityMedium,
	"OutOfDisk":           model.EventSeverityCritical,
	"OutOfMemory":         model.EventSeverityCritical,
	"FreeDiskSpaceFailed": model.EventSeverityHigh,
}

WarningReasons 警告级别的事件原因

Functions

func AddClusterResourceLimit

func AddClusterResourceLimit(ctx context.Context, client kubernetes.Interface, cluster *model.K8sCluster) error

AddClusterResourceLimit 添加集群资源限制

func AddOrUpdateTaint

func AddOrUpdateTaint(taints []corev1.Taint, newTaint corev1.Taint) []corev1.Taint

AddOrUpdateTaint 添加或更新污点

func ApplySingleDocument

func ApplySingleDocument(ctx context.Context, document string, restMapper meta.RESTMapper, dynamicClient dynamic.Interface, docIndex int) error

ApplySingleDocument 应用单个YAML文档到集群

func ApplyYamlToCluster

func ApplyYamlToCluster(ctx context.Context, discoveryClient discovery.DiscoveryInterface, dynamicClient dynamic.Interface, yamlContent string) error

ApplyYamlToCluster 应用YAML到集群

func BuildClusterRoleBindingListOptions

func BuildClusterRoleBindingListOptions(req *model.GetClusterRoleBindingListReq) metav1.ListOptions

BuildClusterRoleBindingListOptions 构建ClusterRoleBinding列表选项

func BuildClusterRoleListOptions

func BuildClusterRoleListOptions(req *model.GetClusterRoleListReq) metav1.ListOptions

BuildClusterRoleListOptions 构建ClusterRole列表选项

func BuildClusterRoleListQueryOptions

func BuildClusterRoleListQueryOptions(req *model.GetClusterRoleListReq) metav1.ListOptions

BuildClusterRoleListQueryOptions 构建 ClusterRole 列表查询选项

func BuildConfigMapListOptions

func BuildConfigMapListOptions(labelSelector string) metav1.ListOptions

BuildConfigMapListOptions 构建 ConfigMap 列表查询参数

func BuildDaemonSetFromRequest

func BuildDaemonSetFromRequest(req *model.CreateDaemonSetReq) (*appsv1.DaemonSet, error)

BuildDaemonSetFromRequest 从请求构建DaemonSet对象

func BuildDaemonSetListOptions

func BuildDaemonSetListOptions(req *model.GetDaemonSetListReq) metav1.ListOptions

BuildDaemonSetListOptions 构建DaemonSet列表查询选项

func BuildDeleteOptions

func BuildDeleteOptions(gracePeriodSeconds int) metav1.DeleteOptions

BuildDeleteOptions 构建删除选项

func BuildDeploymentFromRequest

func BuildDeploymentFromRequest(req *model.CreateDeploymentReq) (*appsv1.Deployment, error)

BuildDeploymentFromRequest 从请求构建Deployment对象

func BuildDeploymentFromYaml

func BuildDeploymentFromYaml(req *model.CreateDeploymentByYamlReq) (*appsv1.Deployment, error)

BuildDeploymentFromYaml 从YAML构建Deployment对象

func BuildDeploymentFromYamlForUpdate

func BuildDeploymentFromYamlForUpdate(req *model.UpdateDeploymentByYamlReq) (*appsv1.Deployment, error)

BuildDeploymentFromYamlForUpdate 从YAML构建Deployment对象用于更新

func BuildDeploymentListOptions

func BuildDeploymentListOptions(req *model.GetDeploymentListReq) metav1.ListOptions

BuildDeploymentListOptions 构建部署列表查询选项

func BuildDeploymentListPagination

func BuildDeploymentListPagination(deployments []appsv1.Deployment, page, size int) ([]appsv1.Deployment, int64)

BuildDeploymentListPagination 构建部署列表分页逻辑

func BuildIngressFromSpec

func BuildIngressFromSpec(req *model.CreateIngressReq) (*networkingv1.Ingress, error)

BuildIngressFromSpec 从CreateIngressReq构建Ingress对象

func BuildIngressFromUpdateSpec

func BuildIngressFromUpdateSpec(req *model.UpdateIngressReq) (*networkingv1.Ingress, error)

BuildIngressFromUpdateSpec 从UpdateIngressReq构建Ingress对象

func BuildIngressListOptions

func BuildIngressListOptions(req *model.GetIngressListReq) metav1.ListOptions

BuildIngressListOptions 构建Ingress列表查询选项

func BuildIngressListPagination

func BuildIngressListPagination(ingresses []networkingv1.Ingress, page, size int) ([]networkingv1.Ingress, int64)

BuildIngressListPagination 构建Ingress列表分页逻辑

func BuildK8sClusterRole

func BuildK8sClusterRole(name string, labels, annotations model.KeyValueList, rules []model.PolicyRule) *rbacv1.ClusterRole

BuildK8sClusterRole 构建K8s ClusterRole对象

func BuildK8sClusterRoleBinding

func BuildK8sClusterRoleBinding(name string, labels, annotations model.KeyValueList, roleRef model.RoleRef, subjects []model.Subject) *rbacv1.ClusterRoleBinding

BuildK8sClusterRoleBinding 构建K8s ClusterRoleBinding对象

func BuildK8sDaemonSet

func BuildK8sDaemonSet(ctx context.Context, clusterID int, daemonSet appsv1.DaemonSet) (*model.K8sDaemonSet, error)

BuildK8sDaemonSet 构建详细的 K8sDaemonSet 模型

func BuildK8sDaemonSetHistory

func BuildK8sDaemonSetHistory(revision appsv1.ControllerRevision) (*model.K8sDaemonSetHistory, error)

BuildK8sDaemonSetHistory 构建DaemonSet历史版本模型

func BuildK8sDeployment

func BuildK8sDeployment(ctx context.Context, clusterID int, deployment appsv1.Deployment) (*model.K8sDeployment, error)

BuildK8sDeployment 构建K8sDeployment模型

func BuildK8sNode

func BuildK8sNode(ctx context.Context, clusterID int, node corev1.Node, kubeClient *kubernetes.Clientset, metricsClient interface{}) (*model.K8sNode, error)

BuildK8sNode 构建详细的 K8sNode 模型

func BuildK8sRole

func BuildK8sRole(name, namespace string, labels, annotations model.KeyValueList, rules []model.PolicyRule) *rbacv1.Role

BuildK8sRole 构建K8s Role对象

func BuildK8sRoleBinding

func BuildK8sRoleBinding(name, namespace string, labels, annotations model.KeyValueList, roleRef model.RoleRef, subjects []model.Subject) *rbacv1.RoleBinding

BuildK8sRoleBinding 构建K8s RoleBinding对象

func BuildK8sService

func BuildK8sService(ctx context.Context, clusterID int, service corev1.Service, kubeClient *kubernetes.Clientset) (*model.K8sService, error)

BuildK8sService 构建详细的 K8sService 模型

func BuildK8sServiceAccount

func BuildK8sServiceAccount(name, namespace string, labels, annotations model.KeyValueList) *corev1.ServiceAccount

BuildK8sServiceAccount 构建K8s ServiceAccount对象

func BuildK8sStatefulSet

func BuildK8sStatefulSet(ctx context.Context, clusterID int, statefulSet appsv1.StatefulSet) (*model.K8sStatefulSet, error)

BuildK8sStatefulSet 构建详细的 K8sStatefulSet 模型

func BuildK8sStatefulSetHistory

func BuildK8sStatefulSetHistory(revision appsv1.ControllerRevision) (*model.K8sStatefulSetHistory, error)

BuildK8sStatefulSetHistory 构建StatefulSet历史版本模型

func BuildNamespaceListOptions

func BuildNamespaceListOptions(req *model.K8sNamespaceListReq) metav1.ListOptions

BuildNamespaceListOptions 构建Namespace列表选项

func BuildNamespaceListPagination

func BuildNamespaceListPagination(namespaces []corev1.Namespace, page, size int) ([]corev1.Namespace, int64)

BuildNamespaceListPagination 构建命名空间列表分页逻辑

func BuildNodeListOptions

func BuildNodeListOptions(req *model.GetNodeListReq) metav1.ListOptions

BuildNodeListOptions 构建节点列表查询选项

func BuildNodeListPagination

func BuildNodeListPagination(nodes []corev1.Node, page, size int) ([]corev1.Node, int64)

BuildNodeListPagination 构建节点列表分页逻辑

func BuildNodeTaints

func BuildNodeTaints(taints []corev1.Taint) ([]*model.NodeTaint, int64)

BuildNodeTaints 构建节点污点列表

func BuildPVCListOptions

func BuildPVCListOptions(req *model.GetPVCListReq) metav1.ListOptions

BuildPVCListOptions 构建 PVC 列表查询选项

func BuildPVListOptions

func BuildPVListOptions(req *model.GetPVListReq) metav1.ListOptions

BuildPVListOptions 构建 PV 列表查询选项

func BuildPodFromRequest

func BuildPodFromRequest(req *model.CreatePodReq) (*corev1.Pod, error)

BuildPodFromRequest 从请求构建Pod对象

func BuildRoleBindingListOptions

func BuildRoleBindingListOptions(req *model.GetRoleBindingListReq) metav1.ListOptions

BuildRoleBindingListOptions 构建RoleBinding列表选项

func BuildRoleListOptions

func BuildRoleListOptions(req *model.GetRoleListReq) metav1.ListOptions

BuildRoleListOptions 构建Role列表选项

func BuildSecretFromRequest

func BuildSecretFromRequest(req *model.CreateSecretReq) (*corev1.Secret, error)

BuildSecretFromRequest 从请求构建secret

func BuildServiceAccountListOptions

func BuildServiceAccountListOptions(req *model.GetServiceAccountListReq) metav1.ListOptions

BuildServiceAccountListOptions 构建ServiceAccount列表选项

func BuildServiceAccountResponse

func BuildServiceAccountResponse(sa *corev1.ServiceAccount, clusterID int) *model.K8sServiceAccount

BuildServiceAccountResponse 构建ServiceAccount响应结构

func BuildServiceFromRequest

func BuildServiceFromRequest(req *model.CreateServiceReq) (*corev1.Service, error)

BuildServiceFromRequest 从请求构建Service对象

func BuildServiceListOptions

func BuildServiceListOptions(req *model.GetServiceListReq) metav1.ListOptions

BuildServiceListOptions 构建Service列表查询选项

func BuildServiceListPagination

func BuildServiceListPagination(services []corev1.Service, page int, size int) ([]corev1.Service, int64)

BuildServiceListPagination 构建Service列表分页逻辑

func BuildStatefulSetFromRequest

func BuildStatefulSetFromRequest(req *model.CreateStatefulSetReq) (*appsv1.StatefulSet, error)

BuildStatefulSetFromRequest 从请求构建StatefulSet对象

func BuildStatefulSetListOptions

func BuildStatefulSetListOptions(req *model.GetStatefulSetListReq) metav1.ListOptions

BuildStatefulSetListOptions 构建StatefulSet列表查询选项

func BuildTaintYaml

func BuildTaintYaml(taints []model.NodeTaint) (string, error)

BuildTaintYaml 构建污点YAML字符串 (从NodeTaintEntity)

func BuildTaintYamlFromK8sTaints

func BuildTaintYamlFromK8sTaints(taints []corev1.Taint) (string, error)

BuildTaintYamlFromK8sTaints 构建污点YAML字符串 (从corev1.Taint)

func CalculatePVCStorageUsage

func CalculatePVCStorageUsage(pvc corev1.PersistentVolumeClaim) (float64, error)

CalculatePVCStorageUsage 计算PVC存储使用率

func CleanClusterSensitiveInfo

func CleanClusterSensitiveInfo(cluster *model.K8sCluster)

CleanClusterSensitiveInfo 清理集群敏感信息

func CleanClusterSensitiveInfoList

func CleanClusterSensitiveInfoList(clusters []*model.K8sCluster)

CleanClusterSensitiveInfoList 清理集群列表中的敏感信息

func CleanConfigMapForYAML

func CleanConfigMapForYAML(cm *corev1.ConfigMap) *corev1.ConfigMap

CleanConfigMapForYAML 清理系统字段,便于导出 YAML

func CleanSecretForYAML

func CleanSecretForYAML(secret *corev1.Secret) *corev1.Secret

CleanSecretForYAML 清理 Secret 对象中的系统字段,用于YAML输出

func ClusterRoleBindingToYAML

func ClusterRoleBindingToYAML(clusterRoleBinding *rbacv1.ClusterRoleBinding) (string, error)

ClusterRoleBindingToYAML 将ClusterRoleBinding转换为YAML

func ClusterRoleToYAML

func ClusterRoleToYAML(clusterRole *rbacv1.ClusterRole) (string, error)

ClusterRoleToYAML 将ClusterRole转换为YAML

func ComparePVCs

func ComparePVCs(pvc1, pvc2 *corev1.PersistentVolumeClaim) bool

ComparePVCs 比较两个PVC是否相同(用于检测更新)

func ConfigMapToYAML

func ConfigMapToYAML(cm *corev1.ConfigMap) (string, error)

ConfigMapToYAML 将 ConfigMap 转换为 YAML 字符串

func ConvertClusterRoleToModel

func ConvertClusterRoleToModel(clusterRole *rbacv1.ClusterRole, clusterID int) *model.K8sClusterRole

ConvertClusterRoleToModel 将 Kubernetes ClusterRole 转换为内部 ClusterRole 模型

func ConvertClusterRoleToYAML

func ConvertClusterRoleToYAML(clusterRole *rbacv1.ClusterRole) (string, error)

ConvertClusterRoleToYAML 将 ClusterRole 转换为 YAML

func ConvertClusterRolesToModel

func ConvertClusterRolesToModel(clusterRoles []rbacv1.ClusterRole, clusterID int) []*model.K8sClusterRole

ConvertClusterRolesToModel 批量转换 ClusterRole 列表

func ConvertCreatePVCReqToPVC

func ConvertCreatePVCReqToPVC(req *model.CreatePVCReq) *corev1.PersistentVolumeClaim

ConvertCreatePVCReqToPVC 将创建PVC请求转换为Kubernetes PVC对象

func ConvertCreatePVReqToPV

func ConvertCreatePVReqToPV(req *model.CreatePVReq) *corev1.PersistentVolume

ConvertCreatePVReqToPV 将创建PV请求转换为Kubernetes PV对象

func ConvertEventToK8sEvent

func ConvertEventToK8sEvent(event corev1.Event) model.K8sEvent

ConvertEventToK8sEvent 将 corev1.Event 转换为 model.K8sEvent

func ConvertK8sClusterRoleBindingToClusterRoleBindingInfo

func ConvertK8sClusterRoleBindingToClusterRoleBindingInfo(clusterRoleBinding *rbacv1.ClusterRoleBinding, clusterID int) model.K8sClusterRoleBinding

ConvertK8sClusterRoleBindingToClusterRoleBindingInfo 将K8s ClusterRoleBinding转换为K8sClusterRoleBinding

func ConvertK8sClusterRoleToClusterRoleInfo

func ConvertK8sClusterRoleToClusterRoleInfo(clusterRole *rbacv1.ClusterRole, clusterID int) model.K8sClusterRole

ConvertK8sClusterRoleToClusterRoleInfo 将K8s ClusterRole转换为K8sClusterRole

func ConvertK8sPolicyRulesToModel

func ConvertK8sPolicyRulesToModel(rules []rbacv1.PolicyRule) []model.PolicyRule

ConvertK8sPolicyRulesToModel 将K8s PolicyRule转换为模型PolicyRule

func ConvertK8sRoleBindingToRoleBindingInfo

func ConvertK8sRoleBindingToRoleBindingInfo(roleBinding *rbacv1.RoleBinding, clusterID int) *model.K8sRoleBinding

ConvertK8sRoleBindingToRoleBindingInfo 将K8s RoleBinding转换为RoleBindingInfo

func ConvertK8sRoleRefToModel

func ConvertK8sRoleRefToModel(roleRef rbacv1.RoleRef) model.RoleRef

ConvertK8sRoleRefToModel 将K8s RoleRef转换为模型RoleRef

func ConvertK8sRoleToRoleInfo

func ConvertK8sRoleToRoleInfo(role *rbacv1.Role, clusterID int) model.K8sRole

ConvertK8sRoleToRoleInfo 将K8s Role转换为K8sRole

func ConvertK8sSubjectsToModel

func ConvertK8sSubjectsToModel(subjects []rbacv1.Subject) []model.Subject

ConvertK8sSubjectsToModel 将K8s Subject列表转换为模型Subject列表

func ConvertKeyValueListToLabels

func ConvertKeyValueListToLabels(keyValues []model.KeyValue) map[string]string

ConvertKeyValueListToLabels 将KeyValue列表转换为map[string]string

func ConvertLabelsToKeyValueList

func ConvertLabelsToKeyValueList(labels map[string]string) model.KeyValueList

ConvertLabelsToKeyValueList 将Kubernetes标签转换为KeyValueList

func ConvertPodContainers

func ConvertPodContainers(pod *corev1.Pod) []model.PodContainer

ConvertPodContainers 将Pod的容器状态转换为PodContainer列表

func ConvertPolicyRulesToK8s

func ConvertPolicyRulesToK8s(rules []model.PolicyRule) []rbacv1.PolicyRule

ConvertPolicyRulesToK8s 将模型PolicyRule转换为K8s PolicyRule

func ConvertRoleRefToK8s

func ConvertRoleRefToK8s(roleRef model.RoleRef) rbacv1.RoleRef

ConvertRoleRefToK8s 将模型RoleRef转换为K8s RoleRef

func ConvertSubjectsToK8s

func ConvertSubjectsToK8s(subjects []model.Subject) []rbacv1.Subject

ConvertSubjectsToK8s 将模型Subject列表转换为K8s Subject列表

func ConvertToCorePorts

func ConvertToCorePorts(ports []model.ServicePort) []corev1.ServicePort

ConvertToCorePorts 将模型端口转换为Kubernetes端口

func ConvertToK8sClusterRole

func ConvertToK8sClusterRole(req *model.CreateClusterRoleReq) *rbacv1.ClusterRole

ConvertToK8sClusterRole 将内部模型转换为Kubernetes ClusterRole对象

func ConvertToK8sClusterRoleBinding

func ConvertToK8sClusterRoleBinding(crb *rbacv1.ClusterRoleBinding) *model.K8sClusterRoleBinding

ConvertToK8sClusterRoleBinding 将 K8s 对象构建为模型对象

func ConvertToK8sDeployment

func ConvertToK8sDeployment(deployment *appsv1.Deployment) *model.K8sDeployment

ConvertToK8sDeployment 将 appsv1.Deployment 转换为 model.K8sDeployment

func ConvertToK8sIngress

func ConvertToK8sIngress(ingress *networkingv1.Ingress, clusterID int) *model.K8sIngress

ConvertToK8sIngress 将 Kubernetes Ingress 转换为内部 Ingress 模型

func ConvertToK8sNamespace

func ConvertToK8sNamespace(name string, labels, annotations model.KeyValueList) *corev1.Namespace

ConvertToK8sNamespace 将名称和标签转换为Kubernetes Namespace对象

func ConvertToK8sPod

func ConvertToK8sPod(pod *corev1.Pod) *model.K8sPod

ConvertToK8sPod 将单个 Kubernetes Pod 转换为内部 Pod 模型

func ConvertToK8sPods

func ConvertToK8sPods(pods []corev1.Pod) []*model.K8sPod

ConvertToK8sPods 将 Kubernetes Pod 列表转换为内部 Pod 模型列表

func ConvertToK8sRole

func ConvertToK8sRole(req *model.CreateRoleReq) *rbacv1.Role

ConvertToK8sRole 将内部模型转换为Kubernetes Role对象

func ConvertToK8sRoleBinding

func ConvertToK8sRoleBinding(req *model.CreateRoleBindingReq) *rbacv1.RoleBinding

ConvertToK8sRoleBinding 将内部模型转换为Kubernetes RoleBinding对象

func ConvertToK8sServiceAccount

func ConvertToK8sServiceAccount(req *model.CreateServiceAccountReq) *corev1.ServiceAccount

ConvertToK8sServiceAccount 将内部模型转换为Kubernetes ServiceAccount对象

func ConvertToPVCEntities

func ConvertToPVCEntities(pvcs []corev1.PersistentVolumeClaim, clusterID int) []*model.K8sPVC

ConvertToPVCEntities 批量转换 PVC 列表

func ConvertToPVCEntity

func ConvertToPVCEntity(pvc *corev1.PersistentVolumeClaim, clusterID int) *model.K8sPVC

ConvertToPVCEntity 将 Kubernetes PVC 转换为内部 PVC 模型

func ConvertToPVEntities

func ConvertToPVEntities(pvs []corev1.PersistentVolume, clusterID int) []*model.K8sPV

ConvertToPVEntities 批量转换 PV 列表

func ConvertToPVEntity

func ConvertToPVEntity(pv *corev1.PersistentVolume, clusterID int) *model.K8sPV

ConvertToPVEntity 将 Kubernetes PV 转换为内部 PV 模型

func ConvertUnstructuredToYAML

func ConvertUnstructuredToYAML(obj *unstructured.Unstructured) (string, error)

ConvertUnstructuredToYAML 将Unstructured对象转换为YAML字符串

func ConvertUpdatePVCReqToPVC

func ConvertUpdatePVCReqToPVC(req *model.UpdatePVCReq) *corev1.PersistentVolumeClaim

ConvertUpdatePVCReqToPVC 将更新PVC请求转换为Kubernetes PVC对象

func ConvertUpdatePVReqToPV

func ConvertUpdatePVReqToPV(req *model.UpdatePVReq, existingPV *corev1.PersistentVolume) *corev1.PersistentVolume

ConvertUpdatePVReqToPV 将更新PV请求转换为Kubernetes PV对象 基于现有PV对象更新可变字段,保留不可变字段

func CreateServiceAccountToken

func CreateServiceAccountToken(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string, expiryTime *int64) (*model.ServiceAccountTokenInfo, error)

CreateServiceAccountToken 为 ServiceAccount 创建指定过期时间的令牌

func DaemonSetToYAML

func DaemonSetToYAML(daemonSet *appsv1.DaemonSet) (string, error)

DaemonSetToYAML 将DaemonSet对象转换为YAML

func DeploymentToYAML

func DeploymentToYAML(deployment *appsv1.Deployment) (string, error)

DeploymentToYAML 将Deployment转换为YAML

func ExtractDaemonSetFromRevision

func ExtractDaemonSetFromRevision(revision *appsv1.ControllerRevision, daemonSet *appsv1.DaemonSet) error

ExtractDaemonSetFromRevision 从ControllerRevision中提取DaemonSet模板 注意:DaemonSet回滚相比Deployment更复杂,因为Kubernetes没有内置的DaemonSet回滚API 这个函数提供基础框架,在实际使用中需要根据具体需求实现反序列化逻辑

func ExtractStatefulSetFromRevision

func ExtractStatefulSetFromRevision(revision *appsv1.ControllerRevision, statefulSet *appsv1.StatefulSet) error

ExtractStatefulSetFromRevision 从ControllerRevision中提取StatefulSet模板

func FilterClusterRolesByName

func FilterClusterRolesByName(clusterRoles []rbacv1.ClusterRole, nameFilter string) []rbacv1.ClusterRole

FilterClusterRolesByName 根据名称过滤 ClusterRole 列表

func FilterDaemonSetsByStatus

func FilterDaemonSetsByStatus(daemonSets []*model.K8sDaemonSet, status string) []*model.K8sDaemonSet

FilterDaemonSetsByStatus 按状态过滤DaemonSet列表

func FilterDeploymentsByStatus

func FilterDeploymentsByStatus(deployments []appsv1.Deployment, status string) []appsv1.Deployment

FilterDeploymentsByStatus 根据部署状态过滤

func FilterEventsByObject

func FilterEventsByObject(events []corev1.Event, objectKind, objectName string) []corev1.Event

FilterEventsByObject 根据涉及对象过滤事件

func FilterEventsByReason

func FilterEventsByReason(events []corev1.Event, reason string) []corev1.Event

FilterEventsByReason 根据事件原因过滤事件

func FilterEventsByTimeRange

func FilterEventsByTimeRange(events []corev1.Event, startTime, endTime time.Time) []corev1.Event

FilterEventsByTimeRange 根据时间范围过滤事件

func FilterEventsByType

func FilterEventsByType(events []corev1.Event, eventType string) []corev1.Event

FilterEventsByType 根据事件类型过滤事件

func FilterIngressesByStatus

func FilterIngressesByStatus(ingresses []networkingv1.Ingress, status string) []networkingv1.Ingress

FilterIngressesByStatus 根据Ingress状态过滤

func FilterNamespacesByLabels

func FilterNamespacesByLabels(namespaces []corev1.Namespace, labels map[string]string) []corev1.Namespace

FilterNamespacesByLabels 根据标签过滤命名空间

func FilterNamespacesByName

func FilterNamespacesByName(namespaces []corev1.Namespace, nameFilter string) []corev1.Namespace

FilterNamespacesByName 根据命名空间名称过滤

func FilterNamespacesBySearch

func FilterNamespacesBySearch(namespaces []corev1.Namespace, search string) []corev1.Namespace

FilterNamespacesBySearch 根据搜索关键字过滤命名空间

func FilterNamespacesByStatus

func FilterNamespacesByStatus(namespaces []corev1.Namespace, status string) []corev1.Namespace

FilterNamespacesByStatus 根据状态过滤命名空间

func FilterNodesByNames

func FilterNodesByNames(nodes []corev1.Node, nodeNames []string) []corev1.Node

FilterNodesByNames 根据节点名称过滤

func FilterNodesByRoles

func FilterNodesByRoles(nodes []corev1.Node, roles []string) []corev1.Node

FilterNodesByRoles 根据节点角色过滤

func FilterNodesByStatus

func FilterNodesByStatus(nodes []corev1.Node, statuses []model.NodeStatus) []corev1.Node

FilterNodesByStatus 根据节点状态过滤

func FilterPVCsByAccessMode

func FilterPVCsByAccessMode(pvcs []corev1.PersistentVolumeClaim, accessMode string) []corev1.PersistentVolumeClaim

FilterPVCsByAccessMode 根据访问模式过滤PVC列表

func FilterPVCsByStatus

func FilterPVCsByStatus(pvcs []corev1.PersistentVolumeClaim, status string) []corev1.PersistentVolumeClaim

FilterPVCsByStatus 根据状态过滤 PVC 列表

func FilterPVCsByStorageClass

func FilterPVCsByStorageClass(pvcs []corev1.PersistentVolumeClaim, storageClass string) []corev1.PersistentVolumeClaim

FilterPVCsByStorageClass 根据存储类过滤PVC列表

func FilterPVsByAccessMode

func FilterPVsByAccessMode(pvs []corev1.PersistentVolume, accessMode string) []corev1.PersistentVolume

FilterPVsByAccessMode 根据访问模式过滤PV列表

func FilterPVsByStatus

func FilterPVsByStatus(pvs []corev1.PersistentVolume, status string) []corev1.PersistentVolume

FilterPVsByStatus 根据状态过滤 PV 列表

func FilterPVsByStorageClass

func FilterPVsByStorageClass(pvs []corev1.PersistentVolume, storageClass string) []corev1.PersistentVolume

FilterPVsByStorageClass 根据存储类过滤PV列表

func FilterServicesByType

func FilterServicesByType(services []corev1.Service, serviceType string) []corev1.Service

FilterServicesByType 根据Service类型过滤

func FilterStatefulSetsByStatus

func FilterStatefulSetsByStatus(statefulSets []*model.K8sStatefulSet, status string) []*model.K8sStatefulSet

FilterStatefulSetsByStatus 按状态过滤StatefulSet列表

func FindTaintByKey

func FindTaintByKey(taints []corev1.Taint, key string) (*corev1.Taint, bool)

FindTaintByKey 根据键查找污点

func FormatEventAge

func FormatEventAge(timestamp time.Time) string

FormatEventAge 格式化事件年龄显示

func GetClusterRoleAge

func GetClusterRoleAge(clusterRole rbacv1.ClusterRole) string

GetClusterRoleAge 获取 ClusterRole 年龄

func GetClusterRolePermissions

func GetClusterRolePermissions(clusterRole rbacv1.ClusterRole) map[string][]string

GetClusterRolePermissions 获取 ClusterRole 权限摘要

func GetDeploymentAge

func GetDeploymentAge(deployment appsv1.Deployment) string

GetDeploymentAge 获取Deployment年龄

func GetDeploymentHistory

func GetDeploymentHistory(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, deploymentName string) ([]*model.K8sDeploymentHistory, int64, error)

GetDeploymentHistory 获取部署历史版本

func GetDeploymentPods

func GetDeploymentPods(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, deploymentName string) ([]*model.K8sPod, int64, error)

GetDeploymentPods 获取部署关联的Pod列表

func GetEventSeverity

func GetEventSeverity(eventType, reason string) model.EventSeverity

GetEventSeverity 根据事件类型和原因判断事件严重程度

func GetEventSummary

func GetEventSummary(events []corev1.Event) map[string]interface{}

GetEventSummary 获取事件摘要信息

func GetIngressAge

func GetIngressAge(ingress networkingv1.Ingress) string

GetIngressAge 获取Ingress年龄

func GetInt32Value

func GetInt32Value(ptr *int32) int32

GetInt32Value 安全获取int32指针的值

func GetNamespaceResourceQuota

func GetNamespaceResourceQuota(namespace *corev1.Namespace) map[string]string

GetNamespaceResourceQuota 获取命名空间资源配额信息

func GetNamespaceStatus

func GetNamespaceStatus(phase corev1.NamespacePhase) string

GetNamespaceStatus 获取命名空间状态的中文描述

func GetNodeStatusMessage

func GetNodeStatusMessage(node corev1.Node) string

GetNodeStatusMessage 获取节点状态描述信息

func GetNodeTaintsByEffect

func GetNodeTaintsByEffect(taints []corev1.Taint, effect corev1.TaintEffect) []corev1.Taint

GetNodeTaintsByEffect 根据污点效果获取节点污点

func GetPVAge

func GetPVAge(pv corev1.PersistentVolume) string

GetPVAge 获取 PV 年龄

func GetPVCAccessModes

func GetPVCAccessModes(pvc corev1.PersistentVolumeClaim) []string

GetPVCAccessModes 获取PVC访问模式的字符串列表

func GetPVCActualStorageSize

func GetPVCActualStorageSize(pvc corev1.PersistentVolumeClaim) string

GetPVCActualStorageSize 获取 PVC 实际存储大小

func GetPVCAge

func GetPVCAge(pvc corev1.PersistentVolumeClaim) string

GetPVCAge 获取 PVC 年龄

func GetPVCCapacity

func GetPVCCapacity(pvc corev1.PersistentVolumeClaim) (string, int64)

GetPVCCapacity 获取PVC容量信息

func GetPVCStorageSize

func GetPVCStorageSize(pvc corev1.PersistentVolumeClaim) string

GetPVCStorageSize 获取 PVC 存储大小(请求大小)

func GetPVCapacity

func GetPVCapacity(pv corev1.PersistentVolume) (string, int64)

GetPVCapacity 获取PV容量信息

func GetPodAge

func GetPodAge(pod corev1.Pod) string

GetPodAge 获取Pod年龄

func GetServiceAccountToken

func GetServiceAccountToken(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string) (*model.ServiceAccountTokenInfo, error)

GetServiceAccountToken 使用 TokenRequest API 获取 ServiceAccount 的短期令牌

func GetTaintsByKeys

func GetTaintsByKeys(taints []corev1.Taint, keys []string) []corev1.Taint

GetTaintsByKeys 根据键列表获取污点

func GroupEventsByObject

func GroupEventsByObject(events []corev1.Event) map[string][]corev1.Event

GroupEventsByObject 按涉及对象分组

func GroupEventsByReason

func GroupEventsByReason(events []corev1.Event) map[string][]corev1.Event

GroupEventsByReason 按事件原因分组

func GroupEventsByType

func GroupEventsByType(events []corev1.Event) map[string][]corev1.Event

GroupEventsByType 按事件类型分组

func HandleK8sError

func HandleK8sError(err error, operation, resource, name, namespace string, clusterID int) error

HandleK8sError 处理Kubernetes API错误

func HasMultipleDocuments

func HasMultipleDocuments(yamlContent string) bool

HasMultipleDocuments 检查是否为多文档YAML

func IngressStatus

func IngressStatus(item *networkingv1.Ingress) string

IngressStatus 获取Ingress状态

func IngressToYAML

func IngressToYAML(ingress *networkingv1.Ingress) (string, error)

IngressToYAML 将Ingress转换为YAML

func IsActivePod

func IsActivePod(pod corev1.Pod) bool

IsActivePod 判断Pod是否为活跃状态

func IsAlreadyExistsError

func IsAlreadyExistsError(err error) bool

IsAlreadyExistsError 检查是否为资源已存在错误

func IsConflictError

func IsConflictError(err error) bool

IsConflictError 检查是否为冲突错误

func IsDaemonSetPod

func IsDaemonSetPod(pod corev1.Pod) bool

IsDaemonSetPod 判断是否为DaemonSet Pod

func IsDeploymentReady

func IsDeploymentReady(deployment appsv1.Deployment) bool

IsDeploymentReady 判断Deployment是否就绪

func IsEventCritical

func IsEventCritical(eventType, reason string) bool

IsEventCritical 判断事件是否为关键事件

func IsForbiddenError

func IsForbiddenError(err error) bool

IsForbiddenError 检查是否为权限不足错误

func IsIngressReady

func IsIngressReady(ingress networkingv1.Ingress) bool

IsIngressReady 判断Ingress是否就绪

func IsNamespaceActive

func IsNamespaceActive(namespace *corev1.Namespace) bool

IsNamespaceActive 检查命名空间是否处于活跃状态

func IsNamespaceTerminating

func IsNamespaceTerminating(namespace *corev1.Namespace) bool

IsNamespaceTerminating 检查命名空间是否正在终止

func IsNodeReady

func IsNodeReady(node corev1.Node) bool

IsNodeReady 判断节点是否就绪

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError 检查是否为资源不存在错误

func IsPVAvailable

func IsPVAvailable(pv corev1.PersistentVolume) bool

IsPVAvailable 判断 PV 是否可用

func IsPVBound

func IsPVBound(pv corev1.PersistentVolume) bool

IsPVBound 判断 PV 是否已绑定

func IsPVCBound

func IsPVCBound(pvc corev1.PersistentVolumeClaim) bool

IsPVCBound 判断 PVC 是否已绑定

func IsPVCExpandable

func IsPVCExpandable(pvc corev1.PersistentVolumeClaim) bool

IsPVCExpandable 判断PVC是否支持扩容

func IsPVCPending

func IsPVCPending(pvc corev1.PersistentVolumeClaim) bool

IsPVCPending 判断 PVC 是否处于等待状态

func IsPodReady

func IsPodReady(pod corev1.Pod) bool

IsPodReady 判断Pod是否就绪

func IsSystemClusterRole

func IsSystemClusterRole(clusterRole rbacv1.ClusterRole) bool

IsSystemClusterRole 判断是否为系统 ClusterRole

func IsSystemNamespace

func IsSystemNamespace(namespace string) bool

IsSystemNamespace 判断是否为系统命名空间

func LogAndWrapError

func LogAndWrapError(logger *zap.Logger, err error, operation string, fields ...zap.Field) error

LogAndWrapError 记录错误并包装

func PVCToYAML

func PVCToYAML(pvc *corev1.PersistentVolumeClaim) (string, error)

PVCToYAML 将 PVC 转换为 YAML

func PVToYAML

func PVToYAML(pv *corev1.PersistentVolume) (string, error)

PVToYAML 将 PV 转换为 YAML

func PaginateK8sClusterRoleBindings

func PaginateK8sClusterRoleBindings(clusterRoleBindings []*model.K8sClusterRoleBinding, page, pageSize int) ([]*model.K8sClusterRoleBinding, int64)

PaginateK8sClusterRoleBindings 对ClusterRoleBinding列表进行分页

func PaginateK8sClusterRoles

func PaginateK8sClusterRoles(clusterRoles []*model.K8sClusterRole, page, pageSize int) ([]*model.K8sClusterRole, int64)

PaginateK8sClusterRoles 对ClusterRole列表进行分页

func PaginateK8sDaemonSets

func PaginateK8sDaemonSets(daemonSets []*model.K8sDaemonSet, page, size int) ([]*model.K8sDaemonSet, int64)

PaginateK8sDaemonSets 对DaemonSet列表进行分页

func PaginateK8sDeployments

func PaginateK8sDeployments(deployments []*model.K8sDeployment, page, size int) ([]*model.K8sDeployment, int64)

PaginateK8sDeployments 对 K8sDeployment 列表进行分页

func PaginateK8sIngresses

func PaginateK8sIngresses(ingresses []*model.K8sIngress, page, size int) ([]*model.K8sIngress, int64)

PaginateK8sIngresses 对 K8sIngress 列表进行分页

func PaginateK8sRoleBindings

func PaginateK8sRoleBindings(roleBindings []*model.K8sRoleBinding, page, pageSize int) (model.ListResp[*model.K8sRoleBinding], error)

PaginateK8sRoleBindings 对RoleBinding列表进行分页(基于内部模型)

func PaginateK8sRoles

func PaginateK8sRoles(roles []*model.K8sRole, page, pageSize int) ([]*model.K8sRole, int64)

PaginateK8sRoles 对Role列表进行分页(基于内部模型)

func PaginateK8sServiceAccounts

func PaginateK8sServiceAccounts(serviceAccounts []corev1.ServiceAccount, page, pageSize int) []corev1.ServiceAccount

PaginateK8sServiceAccounts 对ServiceAccount列表进行分页

func PaginateK8sStatefulSets

func PaginateK8sStatefulSets(statefulSets []*model.K8sStatefulSet, page, size int) ([]*model.K8sStatefulSet, int64)

PaginateK8sStatefulSets 对StatefulSet列表进行分页

func PaginatePVCList

func PaginatePVCList(pvcs []*model.K8sPVC, page, size int) ([]*model.K8sPVC, int64)

PaginatePVCList 对PVC列表进行分页处理

func PaginatePVList

func PaginatePVList(pvs []*model.K8sPV, page, size int) ([]*model.K8sPV, int64)

PaginatePVList 对PV列表进行分页处理

func ParseEventMessage

func ParseEventMessage(message string) map[string]string

ParseEventMessage 解析事件消息,提取关键信息

func ParseTaintYaml

func ParseTaintYaml(taintYaml string) (taintsResult []corev1.Taint, returnErr error)

ParseTaintYaml 解析污点YAML字符串为 corev1.Taint 切片

func ParseYAMLToClusterRole

func ParseYAMLToClusterRole(yamlContent string) (*rbacv1.ClusterRole, error)

ParseYAMLToClusterRole 将 YAML 转换为 ClusterRole

func ParseYamlTemplate

func ParseYamlTemplate(templateContent string, variables []string) (string, error)

ParseYamlTemplate 解析模板变量

func PodStatus

func PodStatus(pod *corev1.Pod) string

PodStatus 获取Pod状态

func PodToYAML

func PodToYAML(pod *corev1.Pod) (string, error)

PodToYAML 将Pod转换为YAML

func RemoveTaintByKey

func RemoveTaintByKey(taints []corev1.Taint, key string) []corev1.Taint

RemoveTaintByKey 根据键移除污点

func RoleBindingToYAML

func RoleBindingToYAML(roleBinding *rbacv1.RoleBinding) (string, error)

RoleBindingToYAML 将RoleBinding转换为YAML

func RoleToYAML

func RoleToYAML(role *rbacv1.Role) (string, error)

RoleToYAML 将Role转换为YAML

func SecretToYAML

func SecretToYAML(sec *corev1.Secret) (string, error)

SecretToYAML 将 Secret 转换为 YAML 字符串

func ServiceAccountToYAML

func ServiceAccountToYAML(serviceAccount *corev1.ServiceAccount) (string, error)

ServiceAccountToYAML 将ServiceAccount转换为YAML

func ServiceToYAML

func ServiceToYAML(service *corev1.Service) (string, error)

ServiceToYAML 将Service对象转换为YAML

func ShouldSkipPodDrain

func ShouldSkipPodDrain(pod corev1.Pod, options *DrainOptions) bool

ShouldSkipPodDrain 判断是否应该跳过Pod驱逐

func SortDaemonSetsByCreationTime

func SortDaemonSetsByCreationTime(daemonSets []*model.K8sDaemonSet, desc bool)

SortDaemonSetsByCreationTime 按创建时间排序DaemonSet列表

func SortEventsByTime

func SortEventsByTime(events []corev1.Event) []corev1.Event

SortEventsByTime 按时间排序事件(最新的在前)

func SortStatefulSetsByCreationTime

func SortStatefulSetsByCreationTime(statefulSets []*model.K8sStatefulSet, desc bool)

SortStatefulSetsByCreationTime 按创建时间排序StatefulSet列表

func SplitYamlDocuments

func SplitYamlDocuments(yamlContent string) []string

SplitYamlDocuments 分割多文档YAML

func StatefulSetToYAML

func StatefulSetToYAML(statefulSet *appsv1.StatefulSet) (string, error)

StatefulSetToYAML 将StatefulSet对象转换为YAML

func TaintExists

func TaintExists(taints []corev1.Taint, targetTaint corev1.Taint) bool

TaintExists 检查污点是否存在

func UpdateSecretFromRequest

func UpdateSecretFromRequest(existing *corev1.Secret, req *model.UpdateSecretReq) (*corev1.Secret, error)

UpdateSecretFromRequest 从更新请求更新 Kubernetes Secret

func ValidateAnnotationKey

func ValidateAnnotationKey(key string) error

ValidateAnnotationKey 验证注解键

func ValidateAnnotationValue

func ValidateAnnotationValue(value string) error

ValidateAnnotationValue 验证注解值

func ValidateAnnotations

func ValidateAnnotations(annotations []model.KeyValue) error

ValidateAnnotations 验证注解

func ValidateBasicParams

func ValidateBasicParams(clusterID int, nodeName string) error

ValidateBasicParams 验证基础参数

func ValidateClusterCreateParams

func ValidateClusterCreateParams(name, apiServerAddr, kubeConfigContent string) error

ValidateClusterCreateParams 验证创建集群的参数

func ValidateClusterExists

func ValidateClusterExists(cluster *model.K8sCluster, clusterID int) error

ValidateClusterExists 验证集群是否存在

func ValidateClusterID

func ValidateClusterID(clusterID int) error

ValidateClusterID 验证集群ID

func ValidateClusterRole

func ValidateClusterRole(clusterRole *rbacv1.ClusterRole) error

ValidateClusterRole 验证 ClusterRole 配置

func ValidateClusterUpdateParams

func ValidateClusterUpdateParams(id int) error

ValidateClusterUpdateParams 验证更新集群的参数

func ValidateContainerName

func ValidateContainerName(name string) error

ValidateContainerName 验证容器名称

func ValidateDaemonSet

func ValidateDaemonSet(daemonSet *appsv1.DaemonSet) error

ValidateDaemonSet 验证DaemonSet配置

func ValidateDeployment

func ValidateDeployment(deployment *appsv1.Deployment) error

ValidateDeployment 验证Deployment配置

func ValidateImageName

func ValidateImageName(image string) error

ValidateImageName 验证镜像名称

func ValidateIngress

func ValidateIngress(ingress *networkingv1.Ingress) error

ValidateIngress 验证Ingress配置

func ValidateKubernetesName

func ValidateKubernetesName(name string) error

ValidateKubernetesName 验证Kubernetes资源名称

func ValidateLabelKey

func ValidateLabelKey(key string) error

ValidateLabelKey 验证标签键

func ValidateLabelKeys

func ValidateLabelKeys(labelKeys []string) error

ValidateLabelKeys 验证标签键

func ValidateLabelPrefix

func ValidateLabelPrefix(prefix string) error

ValidateLabelPrefix 验证标签前缀

func ValidateLabelValue

func ValidateLabelValue(value string) error

ValidateLabelValue 验证标签值

func ValidateLabels

func ValidateLabels(labels []model.KeyValue) error

ValidateLabels 验证标签

func ValidateName

func ValidateName(name string, resource string) error

ValidateName 验证资源名称

func ValidateNamespace

func ValidateNamespace(namespace string) error

ValidateNamespace 验证命名空间

func ValidateNamespaceFilters

func ValidateNamespaceFilters(req *model.K8sNamespaceListReq) error

ValidateNamespaceFilters 验证命名空间过滤参数

func ValidateNamespaceName

func ValidateNamespaceName(name string) error

ValidateNamespaceName 验证命名空间名称

func ValidateNodeLabels

func ValidateNodeLabels(labels map[string]string) error

ValidateNodeLabels 验证节点标签

func ValidateNodeLabelsMap

func ValidateNodeLabelsMap(labels map[string]string) error

ValidateNodeLabelsMap 验证节点标签映射

func ValidateNodeName

func ValidateNodeName(nodeName string) error

ValidateNodeName 验证节点名称

func ValidatePV

func ValidatePV(pv *corev1.PersistentVolume) error

ValidatePV 验证 PV 配置

func ValidatePVC

func ValidatePVC(pvc *corev1.PersistentVolumeClaim) error

ValidatePVC 验证 PVC 配置

func ValidatePVCCreate

func ValidatePVCCreate(req *model.CreatePVCReq) error

ValidatePVCCreate 验证PVC创建请求

func ValidatePVCUpdate

func ValidatePVCUpdate(req *model.UpdatePVCReq) error

ValidatePVCUpdate 验证PVC更新请求

func ValidatePVCreate

func ValidatePVCreate(req *model.CreatePVReq) error

ValidatePVCreate 验证PV创建请求

func ValidatePVUpdate

func ValidatePVUpdate(req *model.UpdatePVReq) error

ValidatePVUpdate 验证PV更新请求

func ValidatePod

func ValidatePod(pod *corev1.Pod) error

ValidatePod 验证Pod配置的有效性

func ValidateRequest

func ValidateRequest(req interface{}) error

ValidateRequest 通用请求验证

func ValidateResourceQuantities

func ValidateResourceQuantities(cluster *model.K8sCluster) error

ValidateResourceQuantities 验证资源配额格式

func ValidateResourceQuota

func ValidateResourceQuota(resources map[string]string) error

ValidateResourceQuota 验证资源配额

func ValidateSecretData

func ValidateSecretData(secretType corev1.SecretType, data map[string][]byte, stringData map[string]string) error

ValidateSecretData 验证 Secret 数据的有效性

func ValidateService

func ValidateService(service *corev1.Service) error

ValidateService 验证Service配置

func ValidateStatefulSet

func ValidateStatefulSet(statefulSet *appsv1.StatefulSet) error

ValidateStatefulSet 验证StatefulSet配置

func ValidateTaint

func ValidateTaint(taint *corev1.Taint) error

ValidateTaint 验证污点的有效性

func ValidateYamlContent

func ValidateYamlContent(content string) error

ValidateYamlContent 验证YAML格式

func ValidateYamlWithCluster

func ValidateYamlWithCluster(ctx context.Context, discoveryClient discovery.DiscoveryInterface, dynamicClient dynamic.Interface, yamlContent string) error

ValidateYamlWithCluster 使用Kubernetes API验证YAML内容

func YAMLToClusterRole

func YAMLToClusterRole(yamlStr string) (*rbacv1.ClusterRole, error)

YAMLToClusterRole 将YAML转换为ClusterRole

func YAMLToClusterRoleBinding

func YAMLToClusterRoleBinding(yamlStr string) (*rbacv1.ClusterRoleBinding, error)

YAMLToClusterRoleBinding 将YAML转换为ClusterRoleBinding

func YAMLToConfigMap

func YAMLToConfigMap(y string) (*corev1.ConfigMap, error)

YAMLToConfigMap 将 YAML 反序列化为 ConfigMap

func YAMLToDaemonSet

func YAMLToDaemonSet(yamlContent string) (*appsv1.DaemonSet, error)

YAMLToDaemonSet 将YAML转换为DaemonSet对象

func YAMLToDeployment

func YAMLToDeployment(yamlContent string) (*appsv1.Deployment, error)

YAMLToDeployment 将YAML转换为Deployment

func YAMLToIngress

func YAMLToIngress(yamlContent string) (*networkingv1.Ingress, error)

YAMLToIngress 将YAML转换为Ingress

func YAMLToPV

func YAMLToPV(yamlContent string) (*corev1.PersistentVolume, error)

YAMLToPV 将 YAML 转换为 PV

func YAMLToPVC

func YAMLToPVC(yamlContent string) (*corev1.PersistentVolumeClaim, error)

YAMLToPVC 将 YAML 转换为 PVC

func YAMLToPod

func YAMLToPod(yamlContent string) (*corev1.Pod, error)

YAMLToPod 将YAML转换为Pod

func YAMLToRole

func YAMLToRole(yamlStr string) (*rbacv1.Role, error)

YAMLToRole 将YAML转换为Role

func YAMLToRoleBinding

func YAMLToRoleBinding(yamlStr string) (*rbacv1.RoleBinding, error)

YAMLToRoleBinding 将YAML转换为RoleBinding

func YAMLToSecret

func YAMLToSecret(y string) (*corev1.Secret, error)

YAMLToSecret 将 YAML 反序列化为 Secret

func YAMLToService

func YAMLToService(yamlContent string) (*corev1.Service, error)

YAMLToService 将YAML转换为Service对象

func YAMLToServiceAccount

func YAMLToServiceAccount(yamlStr string) (*corev1.ServiceAccount, error)

YAMLToServiceAccount 将YAML转换为ServiceAccount

func YAMLToStatefulSet

func YAMLToStatefulSet(yamlContent string) (*appsv1.StatefulSet, error)

YAMLToStatefulSet 将YAML转换为StatefulSet对象

Types

type DrainOptions

type DrainOptions struct {
	Force              int8 // 是否强制驱逐
	IgnoreDaemonSets   int8 // 是否忽略DaemonSet
	DeleteLocalData    int8 // 是否删除本地数据
	GracePeriodSeconds int  // 优雅关闭时间(秒)
	TimeoutSeconds     int  // 超时时间(秒)
}

DrainOptions 驱逐节点选项

type K8sError

type K8sError struct {
	Operation string
	Resource  string
	Name      string
	Namespace string
	ClusterID int
	Err       error
}

K8sError 定义Kubernetes相关错误类型

func NewK8sError

func NewK8sError(operation, resource, name, namespace string, clusterID int, err error) *K8sError

NewK8sError 创建新的Kubernetes错误

func (*K8sError) Error

func (e *K8sError) Error() string

type PodFileStreamPipe

type PodFileStreamPipe struct {
	// contains filtered or unexported fields
}

PodFileStreamPipe pod内文件下载专用,简化实现

func NewPodFileStreamPipe

func NewPodFileStreamPipe(ctx context.Context, config *rest.Config, client kubernetes.Interface,
	namespace, pod, container, filePath string) (*PodFileStreamPipe, error)

func (*PodFileStreamPipe) Close

func (pfs *PodFileStreamPipe) Close() error

Close 关闭管道和资源

func (*PodFileStreamPipe) Read

func (pfs *PodFileStreamPipe) Read(p []byte) (int, error)

Read 实现io.Reader接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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