Documentation
¶
Index ¶
- Constants
- Variables
- func AddClusterResourceLimit(ctx context.Context, client kubernetes.Interface, cluster *model.K8sCluster) error
- func AddOrUpdateTaint(taints []corev1.Taint, newTaint corev1.Taint) []corev1.Taint
- func ApplySingleDocument(ctx context.Context, document string, restMapper meta.RESTMapper, ...) error
- func ApplyYamlToCluster(ctx context.Context, discoveryClient discovery.DiscoveryInterface, ...) error
- func BuildClusterRoleBindingListOptions(req *model.GetClusterRoleBindingListReq) metav1.ListOptions
- func BuildClusterRoleListOptions(req *model.GetClusterRoleListReq) metav1.ListOptions
- func BuildClusterRoleListQueryOptions(req *model.GetClusterRoleListReq) metav1.ListOptions
- func BuildConfigMapListOptions(labelSelector string) metav1.ListOptions
- func BuildDaemonSetFromRequest(req *model.CreateDaemonSetReq) (*appsv1.DaemonSet, error)
- func BuildDaemonSetFromYaml(req *model.CreateDaemonSetByYamlReq) (*appsv1.DaemonSet, error)
- func BuildDaemonSetFromYamlForUpdate(req *model.UpdateDaemonSetByYamlReq) (*appsv1.DaemonSet, error)
- func BuildDaemonSetListOptions(req *model.GetDaemonSetListReq) metav1.ListOptions
- func BuildDeleteOptions(gracePeriodSeconds int) metav1.DeleteOptions
- func BuildDeploymentFromRequest(req *model.CreateDeploymentReq) (*appsv1.Deployment, error)
- func BuildDeploymentFromYaml(req *model.CreateDeploymentByYamlReq) (*appsv1.Deployment, error)
- func BuildDeploymentFromYamlForUpdate(req *model.UpdateDeploymentByYamlReq) (*appsv1.Deployment, error)
- func BuildDeploymentListOptions(req *model.GetDeploymentListReq) metav1.ListOptions
- func BuildDeploymentListPagination(deployments []appsv1.Deployment, page, size int) ([]appsv1.Deployment, int64)
- func BuildIngressFromSpec(req *model.CreateIngressReq) (*networkingv1.Ingress, error)
- func BuildIngressListOptions(req *model.GetIngressListReq) metav1.ListOptions
- func BuildK8sClusterRole(name string, labels, annotations model.KeyValueList, rules []model.PolicyRule) *rbacv1.ClusterRole
- func BuildK8sClusterRoleBinding(name string, labels, annotations model.KeyValueList, roleRef model.RoleRef, ...) *rbacv1.ClusterRoleBinding
- func BuildK8sDaemonSet(ctx context.Context, clusterID int, daemonSet appsv1.DaemonSet) (*model.K8sDaemonSet, error)
- func BuildK8sDaemonSetHistory(revision appsv1.ControllerRevision) (*model.K8sDaemonSetHistory, error)
- func BuildK8sDeployment(ctx context.Context, clusterID int, deployment appsv1.Deployment) (*model.K8sDeployment, error)
- func BuildK8sNode(ctx context.Context, clusterID int, node corev1.Node, ...) (*model.K8sNode, error)
- func BuildK8sRole(name, namespace string, labels, annotations model.KeyValueList, ...) *rbacv1.Role
- func BuildK8sRoleBinding(name, namespace string, labels, annotations model.KeyValueList, ...) *rbacv1.RoleBinding
- func BuildK8sServiceAccount(name, namespace string, labels, annotations model.KeyValueList) *corev1.ServiceAccount
- func BuildK8sServiceFromCore(clusterID int, service corev1.Service) *model.K8sService
- func BuildK8sStatefulSet(ctx context.Context, clusterID int, statefulSet appsv1.StatefulSet) (*model.K8sStatefulSet, error)
- func BuildK8sStatefulSetHistory(revision appsv1.ControllerRevision) (*model.K8sStatefulSetHistory, error)
- func BuildNamespaceListOptions(req *model.K8sNamespaceListReq) metav1.ListOptions
- func BuildNamespaceListPagination(namespaces []corev1.Namespace, page, size int) ([]corev1.Namespace, int64)
- func BuildNodeListOptions(req *model.GetNodeListReq) metav1.ListOptions
- func BuildNodeListPagination(nodes []corev1.Node, page, size int) ([]corev1.Node, int64)
- func BuildNodeTaints(taints []corev1.Taint) ([]*model.NodeTaint, int64)
- func BuildPVCListOptions(req *model.GetPVCListReq) metav1.ListOptions
- func BuildPVListOptions(req *model.GetPVListReq) metav1.ListOptions
- func BuildPodFromRequest(req *model.CreatePodReq) (*corev1.Pod, error)
- func BuildRoleBindingListOptions(req *model.GetRoleBindingListReq) metav1.ListOptions
- func BuildRoleListOptions(req *model.GetRoleListReq) metav1.ListOptions
- func BuildSecretFromRequest(req *model.CreateSecretReq) (*corev1.Secret, error)
- func BuildServiceAccountListOptions(req *model.GetServiceAccountListReq) metav1.ListOptions
- func BuildServiceAccountResponse(sa *corev1.ServiceAccount, clusterID int) *model.K8sServiceAccount
- func BuildServiceFromRequest(req *model.CreateServiceReq) (*corev1.Service, error)
- func BuildServiceListOptions(req *model.GetServiceListReq) metav1.ListOptions
- func BuildServiceListPagination(services []corev1.Service, page int, size int) ([]corev1.Service, int64)
- func BuildStatefulSetFromRequest(req *model.CreateStatefulSetReq) (*appsv1.StatefulSet, error)
- func BuildStatefulSetFromYaml(req *model.CreateStatefulSetByYamlReq) (*appsv1.StatefulSet, error)
- func BuildStatefulSetFromYamlForUpdate(req *model.UpdateStatefulSetByYamlReq) (*appsv1.StatefulSet, error)
- func BuildStatefulSetListOptions(req *model.GetStatefulSetListReq) metav1.ListOptions
- func BuildStatefulSetListPagination(statefulSets []appsv1.StatefulSet, page, size int) ([]appsv1.StatefulSet, int64)
- func BuildTaintYaml(taints []model.NodeTaint) (string, error)
- func BuildTaintYamlFromK8sTaints(taints []corev1.Taint) (string, error)
- func CalculatePVCStorageUsage(pvc corev1.PersistentVolumeClaim) (float64, error)
- func CleanClusterSensitiveInfo(cluster *model.K8sCluster)
- func CleanClusterSensitiveInfoList(clusters []*model.K8sCluster)
- func CleanConfigMapForYAML(cm *corev1.ConfigMap) *corev1.ConfigMap
- func CleanSecretForYAML(secret *corev1.Secret) *corev1.Secret
- func ClusterRoleBindingToYAML(clusterRoleBinding *rbacv1.ClusterRoleBinding) (string, error)
- func ClusterRoleToYAML(clusterRole *rbacv1.ClusterRole) (string, error)
- func ComparePVCs(pvc1, pvc2 *corev1.PersistentVolumeClaim) bool
- func ConfigMapToYAML(cm *corev1.ConfigMap) (string, error)
- func ConvertClusterRoleToModel(clusterRole *rbacv1.ClusterRole, clusterID int) *model.K8sClusterRole
- func ConvertClusterRoleToYAML(clusterRole *rbacv1.ClusterRole) (string, error)
- func ConvertClusterRolesToModel(clusterRoles []rbacv1.ClusterRole, clusterID int) []*model.K8sClusterRole
- func ConvertCreatePVCReqToPVC(req *model.CreatePVCReq) *corev1.PersistentVolumeClaim
- func ConvertCreatePVReqToPV(req *model.CreatePVReq) *corev1.PersistentVolume
- func ConvertEndpointsToModel(endpoints *corev1.Endpoints) []model.K8sServiceEndpoint
- func ConvertEventToK8sEvent(event corev1.Event) model.K8sEvent
- func ConvertK8sClusterRoleBindingToClusterRoleBindingInfo(clusterRoleBinding *rbacv1.ClusterRoleBinding, clusterID int) model.K8sClusterRoleBinding
- func ConvertK8sClusterRoleToClusterRoleInfo(clusterRole *rbacv1.ClusterRole, clusterID int) model.K8sClusterRole
- func ConvertK8sPolicyRulesToModel(rules []rbacv1.PolicyRule) []model.PolicyRule
- func ConvertK8sRoleBindingToRoleBindingInfo(roleBinding *rbacv1.RoleBinding, clusterID int) *model.K8sRoleBinding
- func ConvertK8sRoleRefToModel(roleRef rbacv1.RoleRef) model.RoleRef
- func ConvertK8sRoleToRoleInfo(role *rbacv1.Role, clusterID int) model.K8sRole
- func ConvertK8sSubjectsToModel(subjects []rbacv1.Subject) []model.Subject
- func ConvertKeyValueListToLabels(keyValues []model.KeyValue) map[string]string
- func ConvertLabelsToKeyValueList(labels map[string]string) model.KeyValueList
- func ConvertPodContainers(pod *corev1.Pod) []model.PodContainer
- func ConvertPolicyRulesToK8s(rules []model.PolicyRule) []rbacv1.PolicyRule
- func ConvertRoleRefToK8s(roleRef model.RoleRef) rbacv1.RoleRef
- func ConvertSubjectsToK8s(subjects []model.Subject) []rbacv1.Subject
- func ConvertToCorePorts(ports []model.ServicePort) []corev1.ServicePort
- func ConvertToK8sClusterRole(req *model.CreateClusterRoleReq) *rbacv1.ClusterRole
- func ConvertToK8sClusterRoleBinding(crb *rbacv1.ClusterRoleBinding) *model.K8sClusterRoleBinding
- func ConvertToK8sDaemonSet(daemonSet *appsv1.DaemonSet) *model.K8sDaemonSet
- func ConvertToK8sDeployment(deployment *appsv1.Deployment) *model.K8sDeployment
- func ConvertToK8sIngress(ingress *networkingv1.Ingress, clusterID int) *model.K8sIngress
- func ConvertToK8sNamespace(name string, labels, annotations model.KeyValueList) *corev1.Namespace
- func ConvertToK8sPod(pod *corev1.Pod) *model.K8sPod
- func ConvertToK8sPods(pods []corev1.Pod) []*model.K8sPod
- func ConvertToK8sRole(req *model.CreateRoleReq) *rbacv1.Role
- func ConvertToK8sRoleBinding(req *model.CreateRoleBindingReq) *rbacv1.RoleBinding
- func ConvertToK8sServiceAccount(req *model.CreateServiceAccountReq) *corev1.ServiceAccount
- func ConvertToK8sStatefulSet(statefulSet *appsv1.StatefulSet) *model.K8sStatefulSet
- func ConvertToPVCEntities(pvcs []corev1.PersistentVolumeClaim, clusterID int) []*model.K8sPVC
- func ConvertToPVCEntity(pvc *corev1.PersistentVolumeClaim, clusterID int) *model.K8sPVC
- func ConvertToPVEntities(pvs []corev1.PersistentVolume, clusterID int) []*model.K8sPV
- func ConvertToPVEntity(pv *corev1.PersistentVolume, clusterID int) *model.K8sPV
- func ConvertUnstructuredToYAML(obj *unstructured.Unstructured) (string, error)
- func ConvertUpdatePVCReqToPVC(req *model.UpdatePVCReq) *corev1.PersistentVolumeClaim
- func ConvertUpdatePVReqToPV(req *model.UpdatePVReq, existingPV *corev1.PersistentVolume) *corev1.PersistentVolume
- func CreateServiceAccountToken(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string, ...) (*model.ServiceAccountTokenInfo, error)
- func DaemonSetToYAML(daemonSet *appsv1.DaemonSet) (string, error)
- func DeploymentToYAML(deployment *appsv1.Deployment) (string, error)
- func ExtractDaemonSetFromRevision(revision *appsv1.ControllerRevision, daemonSet *appsv1.DaemonSet) error
- func ExtractStatefulSetFromRevision(revision *appsv1.ControllerRevision, statefulSet *appsv1.StatefulSet) error
- func FilterClusterRolesByName(clusterRoles []rbacv1.ClusterRole, nameFilter string) []rbacv1.ClusterRole
- func FilterDaemonSetsByStatus(daemonSets []*model.K8sDaemonSet, status string) []*model.K8sDaemonSet
- func FilterDeploymentsByStatus(deployments []appsv1.Deployment, status string) []appsv1.Deployment
- func FilterEventsByObject(events []corev1.Event, objectKind, objectName string) []corev1.Event
- func FilterEventsByReason(events []corev1.Event, reason string) []corev1.Event
- func FilterEventsByTimeRange(events []corev1.Event, startTime, endTime time.Time) []corev1.Event
- func FilterEventsByType(events []corev1.Event, eventType string) []corev1.Event
- func FilterNamespacesByLabels(namespaces []corev1.Namespace, labels map[string]string) []corev1.Namespace
- func FilterNamespacesByName(namespaces []corev1.Namespace, nameFilter string) []corev1.Namespace
- func FilterNamespacesBySearch(namespaces []corev1.Namespace, search string) []corev1.Namespace
- func FilterNamespacesByStatus(namespaces []corev1.Namespace, status string) []corev1.Namespace
- func FilterNodesByNames(nodes []corev1.Node, nodeNames []string) []corev1.Node
- func FilterNodesByRoles(nodes []corev1.Node, roles []string) []corev1.Node
- func FilterNodesByStatus(nodes []corev1.Node, statuses []model.NodeStatus) []corev1.Node
- func FilterPVCsByAccessMode(pvcs []corev1.PersistentVolumeClaim, accessMode string) []corev1.PersistentVolumeClaim
- func FilterPVCsByStatus(pvcs []corev1.PersistentVolumeClaim, status string) []corev1.PersistentVolumeClaim
- func FilterPVCsByStorageClass(pvcs []corev1.PersistentVolumeClaim, storageClass string) []corev1.PersistentVolumeClaim
- func FilterPVsByAccessMode(pvs []corev1.PersistentVolume, accessMode string) []corev1.PersistentVolume
- func FilterPVsByStatus(pvs []corev1.PersistentVolume, status string) []corev1.PersistentVolume
- func FilterPVsByStorageClass(pvs []corev1.PersistentVolume, storageClass string) []corev1.PersistentVolume
- func FilterServicesByType(services []corev1.Service, serviceType string) []corev1.Service
- func FilterStatefulSetsByStatus(statefulSets []appsv1.StatefulSet, status string) []appsv1.StatefulSet
- func FindTaintByKey(taints []corev1.Taint, key string) (*corev1.Taint, bool)
- func FormatEventAge(timestamp time.Time) string
- func GetChangeReason(annotations map[string]string) string
- func GetClusterRoleAge(clusterRole rbacv1.ClusterRole) string
- func GetClusterRolePermissions(clusterRole rbacv1.ClusterRole) map[string][]string
- func GetDeploymentAge(deployment appsv1.Deployment) string
- func GetDeploymentHistory(ctx context.Context, kubeClient *kubernetes.Clientset, ...) ([]*model.K8sDeploymentHistory, int64, error)
- func GetDeploymentPods(ctx context.Context, kubeClient *kubernetes.Clientset, ...) ([]*model.K8sPod, int64, error)
- func GetEventSeverity(eventType, reason string) model.EventSeverity
- func GetEventSummary(events []corev1.Event) map[string]interface{}
- func GetIngressAge(ingress networkingv1.Ingress) string
- func GetInt32Value(ptr *int32) int32
- func GetNamespaceResourceQuota(namespace *corev1.Namespace) map[string]string
- func GetNamespaceStatus(phase corev1.NamespacePhase) string
- func GetNodeStatusMessage(node corev1.Node) string
- func GetNodeTaintsByEffect(taints []corev1.Taint, effect corev1.TaintEffect) []corev1.Taint
- func GetPVAge(pv corev1.PersistentVolume) string
- func GetPVCAccessModes(pvc corev1.PersistentVolumeClaim) []string
- func GetPVCActualStorageSize(pvc corev1.PersistentVolumeClaim) string
- func GetPVCAge(pvc corev1.PersistentVolumeClaim) string
- func GetPVCCapacity(pvc corev1.PersistentVolumeClaim) (string, int64)
- func GetPVCStorageSize(pvc corev1.PersistentVolumeClaim) string
- func GetPVCapacity(pv corev1.PersistentVolume) (string, int64)
- func GetPodAge(pod corev1.Pod) string
- func GetServiceAccountToken(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string) (*model.ServiceAccountTokenInfo, error)
- func GetStatefulSetAge(statefulSet appsv1.StatefulSet) string
- func GetStatefulSetPods(ctx context.Context, kubeClient *kubernetes.Clientset, ...) ([]*model.K8sPod, int64, error)
- func GetTaintsByKeys(taints []corev1.Taint, keys []string) []corev1.Taint
- func GroupEventsByObject(events []corev1.Event) map[string][]corev1.Event
- func GroupEventsByReason(events []corev1.Event) map[string][]corev1.Event
- func GroupEventsByType(events []corev1.Event) map[string][]corev1.Event
- func HandleK8sError(err error, operation, resource, name, namespace string, clusterID int) error
- func HasMultipleDocuments(yamlContent string) bool
- func IngressStatus(item *networkingv1.Ingress) string
- func IngressToYAML(ingress *networkingv1.Ingress) (string, error)
- func IsActivePod(pod corev1.Pod) bool
- func IsAlreadyExistsError(err error) bool
- func IsConflictError(err error) bool
- func IsDaemonSetPod(pod corev1.Pod) bool
- func IsDeploymentReady(deployment appsv1.Deployment) bool
- func IsEventCritical(eventType, reason string) bool
- func IsForbiddenError(err error) bool
- func IsIngressReady(ingress networkingv1.Ingress) bool
- func IsNamespaceActive(namespace *corev1.Namespace) bool
- func IsNamespaceTerminating(namespace *corev1.Namespace) bool
- func IsNodeReady(node corev1.Node) bool
- func IsNotFoundError(err error) bool
- func IsPVAvailable(pv corev1.PersistentVolume) bool
- func IsPVBound(pv corev1.PersistentVolume) bool
- func IsPVCBound(pvc corev1.PersistentVolumeClaim) bool
- func IsPVCExpandable(pvc corev1.PersistentVolumeClaim) bool
- func IsPVCPending(pvc corev1.PersistentVolumeClaim) bool
- func IsPodReady(pod corev1.Pod) bool
- func IsStatefulSetReady(statefulSet appsv1.StatefulSet) bool
- func IsSystemClusterRole(clusterRole rbacv1.ClusterRole) bool
- func IsSystemNamespace(namespace string) bool
- func LogAndWrapError(logger *zap.Logger, err error, operation string, fields ...zap.Field) error
- func PVCToYAML(pvc *corev1.PersistentVolumeClaim) (string, error)
- func PVToYAML(pv *corev1.PersistentVolume) (string, error)
- func PaginateK8sClusterRoleBindings(clusterRoleBindings []*model.K8sClusterRoleBinding, page, pageSize int) ([]*model.K8sClusterRoleBinding, int64)
- func PaginateK8sClusterRoles(clusterRoles []*model.K8sClusterRole, page, pageSize int) ([]*model.K8sClusterRole, int64)
- func PaginateK8sDaemonSets(daemonSets []*model.K8sDaemonSet, page, size int) ([]*model.K8sDaemonSet, int64)
- func PaginateK8sDeployments(deployments []*model.K8sDeployment, page, size int) ([]*model.K8sDeployment, int64)
- func PaginateK8sIngresses(ingresses []*model.K8sIngress, page, size int) ([]*model.K8sIngress, int64)
- func PaginateK8sRoleBindings(roleBindings []*model.K8sRoleBinding, page, pageSize int) (model.ListResp[*model.K8sRoleBinding], error)
- func PaginateK8sRoles(roles []*model.K8sRole, page, pageSize int) ([]*model.K8sRole, int64)
- func PaginateK8sServiceAccounts(serviceAccounts []corev1.ServiceAccount, page, pageSize int) []corev1.ServiceAccount
- func PaginateK8sStatefulSets(statefulSets []*model.K8sStatefulSet, page, size int) ([]*model.K8sStatefulSet, int64)
- func PaginatePVCList(pvcs []*model.K8sPVC, page, size int) ([]*model.K8sPVC, int64)
- func PaginatePVList(pvs []*model.K8sPV, page, size int) ([]*model.K8sPV, int64)
- func ParseEventMessage(message string) map[string]string
- func ParseTaintYaml(taintYaml string) (taintsResult []corev1.Taint, returnErr error)
- func ParseYAMLToClusterRole(yamlContent string) (*rbacv1.ClusterRole, error)
- func ParseYamlTemplate(templateContent string, variables []string) (string, error)
- func PodStatus(pod *corev1.Pod) string
- func PodToYAML(pod *corev1.Pod) (string, error)
- func RemoveTaintByKey(taints []corev1.Taint, key string) []corev1.Taint
- func RoleBindingToYAML(roleBinding *rbacv1.RoleBinding) (string, error)
- func RoleToYAML(role *rbacv1.Role) (string, error)
- func SecretToYAML(sec *corev1.Secret) (string, error)
- func ServiceAccountToYAML(serviceAccount *corev1.ServiceAccount) (string, error)
- func ServiceToYAML(service *corev1.Service) (string, error)
- func ShouldSkipPodDrain(pod corev1.Pod, options *DrainOptions) bool
- func SortDaemonSetsByCreationTime(daemonSets []*model.K8sDaemonSet, desc bool)
- func SortEventsByTime(events []corev1.Event) []corev1.Event
- func SortStatefulSetsByCreationTime(statefulSets []*model.K8sStatefulSet, desc bool)
- func SplitYamlDocuments(yamlContent string) []string
- func StatefulSetToYAML(statefulSet *appsv1.StatefulSet) (string, error)
- func TaintExists(taints []corev1.Taint, targetTaint corev1.Taint) bool
- func UpdateSecretFromRequest(existing *corev1.Secret, req *model.UpdateSecretReq) (*corev1.Secret, error)
- func ValidateAnnotationKey(key string) error
- func ValidateAnnotationValue(value string) error
- func ValidateAnnotations(annotations []model.KeyValue) error
- func ValidateBasicParams(clusterID int, nodeName string) error
- func ValidateClusterCreateParams(name, apiServerAddr, kubeConfigContent string) error
- func ValidateClusterExists(cluster *model.K8sCluster, clusterID int) error
- func ValidateClusterID(clusterID int) error
- func ValidateClusterRole(clusterRole *rbacv1.ClusterRole) error
- func ValidateClusterUpdateParams(id int) error
- func ValidateContainerName(name string) error
- func ValidateDaemonSet(daemonSet *appsv1.DaemonSet) error
- func ValidateDeployment(deployment *appsv1.Deployment) error
- func ValidateImageName(image string) error
- func ValidateIngress(ingress *networkingv1.Ingress) error
- func ValidateKubernetesName(name string) error
- func ValidateLabelKey(key string) error
- func ValidateLabelKeys(labelKeys []string) error
- func ValidateLabelPrefix(prefix string) error
- func ValidateLabelValue(value string) error
- func ValidateLabels(labels []model.KeyValue) error
- func ValidateName(name string, resource string) error
- func ValidateNamespace(namespace string) error
- func ValidateNamespaceFilters(req *model.K8sNamespaceListReq) error
- func ValidateNamespaceName(name string) error
- func ValidateNodeLabels(labels map[string]string) error
- func ValidateNodeLabelsMap(labels map[string]string) error
- func ValidateNodeName(nodeName string) error
- func ValidatePV(pv *corev1.PersistentVolume) error
- func ValidatePVC(pvc *corev1.PersistentVolumeClaim) error
- func ValidatePVCCreate(req *model.CreatePVCReq) error
- func ValidatePVCUpdate(req *model.UpdatePVCReq) error
- func ValidatePVCreate(req *model.CreatePVReq) error
- func ValidatePVUpdate(req *model.UpdatePVReq) error
- func ValidatePod(pod *corev1.Pod) error
- func ValidateRequest(req interface{}) error
- func ValidateResourceQuantities(cluster *model.K8sCluster) error
- func ValidateResourceQuota(resources map[string]string) error
- func ValidateSecretData(secretType corev1.SecretType, data map[string][]byte, ...) error
- func ValidateService(service *corev1.Service) error
- func ValidateStatefulSet(statefulSet *appsv1.StatefulSet) error
- func ValidateTaint(taint *corev1.Taint) error
- func ValidateYamlContent(content string) error
- func ValidateYamlWithCluster(ctx context.Context, discoveryClient discovery.DiscoveryInterface, ...) error
- func YAMLToClusterRole(yamlStr string) (*rbacv1.ClusterRole, error)
- func YAMLToClusterRoleBinding(yamlStr string) (*rbacv1.ClusterRoleBinding, error)
- func YAMLToConfigMap(y string) (*corev1.ConfigMap, error)
- func YAMLToDaemonSet(yamlContent string) (*appsv1.DaemonSet, error)
- func YAMLToDeployment(yamlContent string) (*appsv1.Deployment, error)
- func YAMLToIngress(yamlContent string) (*networkingv1.Ingress, error)
- func YAMLToPV(yamlContent string) (*corev1.PersistentVolume, error)
- func YAMLToPVC(yamlContent string) (*corev1.PersistentVolumeClaim, error)
- func YAMLToPod(yamlContent string) (*corev1.Pod, error)
- func YAMLToRole(yamlStr string) (*rbacv1.Role, error)
- func YAMLToRoleBinding(yamlStr string) (*rbacv1.RoleBinding, error)
- func YAMLToSecret(y string) (*corev1.Secret, error)
- func YAMLToService(yamlContent string) (*corev1.Service, error)
- func YAMLToServiceAccount(yamlStr string) (*corev1.ServiceAccount, error)
- func YAMLToStatefulSet(yamlContent string) (*appsv1.StatefulSet, error)
- type DrainOptions
- type K8sError
- type PodFileStreamPipe
Constants ¶
const ( // 通用状态 StatusPending = "Pending" StatusUnknown = "Unknown" StatusReady = "Ready" StatusTerminating = "Terminating" StatusRunning = "Running" StatusUpdating = "Updating" StatusSucceeded = "Succeeded" StatusFailed = "Failed" StatusEvicted = "Evicted" )
K8s资源状态常量定义
Variables ¶
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 正常级别的事件原因
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 ¶
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 BuildDaemonSetFromYaml ¶ added in v0.0.4
func BuildDaemonSetFromYaml(req *model.CreateDaemonSetByYamlReq) (*appsv1.DaemonSet, error)
BuildDaemonSetFromYaml 从YAML构建DaemonSet对象
func BuildDaemonSetFromYamlForUpdate ¶ added in v0.0.4
func BuildDaemonSetFromYamlForUpdate(req *model.UpdateDaemonSetByYamlReq) (*appsv1.DaemonSet, error)
BuildDaemonSetFromYamlForUpdate 构建用于更新的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 BuildIngressListOptions ¶
func BuildIngressListOptions(req *model.GetIngressListReq) metav1.ListOptions
BuildIngressListOptions 构建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 BuildK8sServiceAccount ¶
func BuildK8sServiceAccount(name, namespace string, labels, annotations model.KeyValueList) *corev1.ServiceAccount
BuildK8sServiceAccount 构建K8s ServiceAccount对象
func BuildK8sServiceFromCore ¶ added in v0.0.8
func BuildK8sServiceFromCore(clusterID int, service corev1.Service) *model.K8sService
BuildK8sServiceFromCore 构建K8sService模型
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 ¶
BuildNodeListPagination 构建节点列表分页逻辑
func BuildNodeTaints ¶
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 BuildStatefulSetFromYaml ¶ added in v0.0.4
func BuildStatefulSetFromYaml(req *model.CreateStatefulSetByYamlReq) (*appsv1.StatefulSet, error)
BuildStatefulSetFromYaml 从YAML构建StatefulSet对象
func BuildStatefulSetFromYamlForUpdate ¶ added in v0.0.4
func BuildStatefulSetFromYamlForUpdate(req *model.UpdateStatefulSetByYamlReq) (*appsv1.StatefulSet, error)
BuildStatefulSetFromYamlForUpdate 构建用于更新的StatefulSet对象
func BuildStatefulSetListOptions ¶
func BuildStatefulSetListOptions(req *model.GetStatefulSetListReq) metav1.ListOptions
BuildStatefulSetListOptions 构建StatefulSet列表查询选项
func BuildStatefulSetListPagination ¶ added in v0.0.5
func BuildStatefulSetListPagination(statefulSets []appsv1.StatefulSet, page, size int) ([]appsv1.StatefulSet, int64)
BuildStatefulSetListPagination 构建StatefulSet列表分页逻辑
func BuildTaintYaml ¶
BuildTaintYaml 构建污点YAML字符串 (从NodeTaintEntity)
func BuildTaintYamlFromK8sTaints ¶
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 ¶
CleanConfigMapForYAML 清理系统字段,便于导出 YAML
func CleanSecretForYAML ¶
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 ¶
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 ConvertEndpointsToModel ¶ added in v0.0.8
func ConvertEndpointsToModel(endpoints *corev1.Endpoints) []model.K8sServiceEndpoint
ConvertEndpointsToModel 将Kubernetes Endpoints转换为模型格式
func ConvertEventToK8sEvent ¶
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 ¶
ConvertK8sRoleRefToModel 将K8s RoleRef转换为模型RoleRef
func ConvertK8sRoleToRoleInfo ¶
ConvertK8sRoleToRoleInfo 将K8s Role转换为K8sRole
func ConvertK8sSubjectsToModel ¶
ConvertK8sSubjectsToModel 将K8s Subject列表转换为模型Subject列表
func ConvertKeyValueListToLabels ¶
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 ¶
ConvertRoleRefToK8s 将模型RoleRef转换为K8s RoleRef
func ConvertSubjectsToK8s ¶
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 ConvertToK8sDaemonSet ¶ added in v0.0.4
func ConvertToK8sDaemonSet(daemonSet *appsv1.DaemonSet) *model.K8sDaemonSet
ConvertToK8sDaemonSet 将 appsv1.DaemonSet 转换为 model.K8sDaemonSet
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 ¶
ConvertToK8sPod 将单个 Kubernetes Pod 转换为内部 Pod 模型
func ConvertToK8sPods ¶
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 ConvertToK8sStatefulSet ¶ added in v0.0.4
func ConvertToK8sStatefulSet(statefulSet *appsv1.StatefulSet) *model.K8sStatefulSet
ConvertToK8sStatefulSet 将 appsv1.StatefulSet 转换为 model.K8sStatefulSet
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 ¶
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配置用于回滚
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 ¶
FilterEventsByObject 根据涉及对象过滤事件
func FilterEventsByReason ¶
FilterEventsByReason 根据事件原因过滤事件
func FilterEventsByTimeRange ¶
FilterEventsByTimeRange 根据时间范围过滤事件
func FilterEventsByType ¶
FilterEventsByType 根据事件类型过滤事件
func FilterNamespacesByLabels ¶
func FilterNamespacesByLabels(namespaces []corev1.Namespace, labels map[string]string) []corev1.Namespace
FilterNamespacesByLabels 根据标签过滤命名空间
func FilterNamespacesByName ¶
FilterNamespacesByName 根据命名空间名称过滤
func FilterNamespacesBySearch ¶
FilterNamespacesBySearch 根据搜索关键字过滤命名空间
func FilterNamespacesByStatus ¶
FilterNamespacesByStatus 根据状态过滤命名空间
func FilterNodesByNames ¶
FilterNodesByNames 根据节点名称过滤
func FilterNodesByRoles ¶
FilterNodesByRoles 根据节点角色过滤
func FilterNodesByStatus ¶
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 ¶
FilterServicesByType 根据Service类型过滤
func FilterStatefulSetsByStatus ¶
func FilterStatefulSetsByStatus(statefulSets []appsv1.StatefulSet, status string) []appsv1.StatefulSet
FilterStatefulSetsByStatus 根据StatefulSet状态过滤
func FindTaintByKey ¶
FindTaintByKey 根据键查找污点
func GetChangeReason ¶ added in v0.0.4
GetChangeReason 从annotations中获取变更原因
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 ¶
GetEventSummary 获取事件摘要信息
func GetIngressAge ¶
func GetIngressAge(ingress networkingv1.Ingress) string
GetIngressAge 获取Ingress年龄
func GetNamespaceResourceQuota ¶
GetNamespaceResourceQuota 获取命名空间资源配额信息
func GetNamespaceStatus ¶
func GetNamespaceStatus(phase corev1.NamespacePhase) string
GetNamespaceStatus 获取命名空间状态的中文描述
func GetNodeStatusMessage ¶
GetNodeStatusMessage 获取节点状态描述信息
func GetNodeTaintsByEffect ¶
GetNodeTaintsByEffect 根据污点效果获取节点污点
func GetPVCAccessModes ¶
func GetPVCAccessModes(pvc corev1.PersistentVolumeClaim) []string
GetPVCAccessModes 获取PVC访问模式的字符串列表
func GetPVCActualStorageSize ¶
func GetPVCActualStorageSize(pvc corev1.PersistentVolumeClaim) string
GetPVCActualStorageSize 获取 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 GetServiceAccountToken ¶
func GetServiceAccountToken(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string) (*model.ServiceAccountTokenInfo, error)
GetServiceAccountToken 使用 TokenRequest API 获取 ServiceAccount 的短期令牌
func GetStatefulSetAge ¶ added in v0.0.5
func GetStatefulSetAge(statefulSet appsv1.StatefulSet) string
GetStatefulSetAge 获取StatefulSet年龄
func GetStatefulSetPods ¶ added in v0.0.5
func GetStatefulSetPods(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, statefulSetName string) ([]*model.K8sPod, int64, error)
GetStatefulSetPods 获取StatefulSet关联的Pod列表
func GetTaintsByKeys ¶
GetTaintsByKeys 根据键列表获取污点
func GroupEventsByObject ¶
GroupEventsByObject 按涉及对象分组
func GroupEventsByReason ¶
GroupEventsByReason 按事件原因分组
func GroupEventsByType ¶
GroupEventsByType 按事件类型分组
func HandleK8sError ¶
HandleK8sError 处理Kubernetes API错误
func HasMultipleDocuments ¶
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 IsAlreadyExistsError ¶
IsAlreadyExistsError 检查是否为资源已存在错误
func IsDeploymentReady ¶
func IsDeploymentReady(deployment appsv1.Deployment) bool
IsDeploymentReady 判断Deployment是否就绪
func IsEventCritical ¶
IsEventCritical 判断事件是否为关键事件
func IsIngressReady ¶
func IsIngressReady(ingress networkingv1.Ingress) bool
IsIngressReady 判断Ingress是否就绪
func IsNamespaceActive ¶
IsNamespaceActive 检查命名空间是否处于活跃状态
func IsNamespaceTerminating ¶
IsNamespaceTerminating 检查命名空间是否正在终止
func IsPVCExpandable ¶
func IsPVCExpandable(pvc corev1.PersistentVolumeClaim) bool
IsPVCExpandable 判断PVC是否支持扩容
func IsPVCPending ¶
func IsPVCPending(pvc corev1.PersistentVolumeClaim) bool
IsPVCPending 判断 PVC 是否处于等待状态
func IsStatefulSetReady ¶ added in v0.0.5
func IsStatefulSetReady(statefulSet appsv1.StatefulSet) bool
IsStatefulSetReady 判断StatefulSet是否就绪
func IsSystemClusterRole ¶
func IsSystemClusterRole(clusterRole rbacv1.ClusterRole) bool
IsSystemClusterRole 判断是否为系统 ClusterRole
func IsSystemNamespace ¶
IsSystemNamespace 判断是否为系统命名空间
func LogAndWrapError ¶
LogAndWrapError 记录错误并包装
func PVCToYAML ¶
func PVCToYAML(pvc *corev1.PersistentVolumeClaim) (string, error)
PVCToYAML 将 PVC 转换为 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 ¶
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 对 K8sStatefulSet 列表进行分页
func PaginatePVCList ¶
PaginatePVCList 对PVC列表进行分页处理
func PaginatePVList ¶
PaginatePVList 对PV列表进行分页处理
func ParseEventMessage ¶
ParseEventMessage 解析事件消息,提取关键信息
func ParseTaintYaml ¶
ParseTaintYaml 解析污点YAML字符串为 corev1.Taint 切片
func ParseYAMLToClusterRole ¶
func ParseYAMLToClusterRole(yamlContent string) (*rbacv1.ClusterRole, error)
ParseYAMLToClusterRole 将 YAML 转换为 ClusterRole
func ParseYamlTemplate ¶
ParseYamlTemplate 解析模板变量
func RemoveTaintByKey ¶
RemoveTaintByKey 根据键移除污点
func RoleBindingToYAML ¶
func RoleBindingToYAML(roleBinding *rbacv1.RoleBinding) (string, error)
RoleBindingToYAML 将RoleBinding转换为YAML
func SecretToYAML ¶
SecretToYAML 将 Secret 转换为 YAML 字符串
func ServiceAccountToYAML ¶
func ServiceAccountToYAML(serviceAccount *corev1.ServiceAccount) (string, error)
ServiceAccountToYAML 将ServiceAccount转换为YAML
func ServiceToYAML ¶
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 ¶
SortEventsByTime 按时间排序事件(最新的在前)
func SortStatefulSetsByCreationTime ¶
func SortStatefulSetsByCreationTime(statefulSets []*model.K8sStatefulSet, desc bool)
SortStatefulSetsByCreationTime 按创建时间排序StatefulSet列表
func SplitYamlDocuments ¶
SplitYamlDocuments 分割多文档YAML
func StatefulSetToYAML ¶
func StatefulSetToYAML(statefulSet *appsv1.StatefulSet) (string, error)
StatefulSetToYAML 将StatefulSet转换为YAML
func TaintExists ¶
TaintExists 检查污点是否存在
func UpdateSecretFromRequest ¶
func UpdateSecretFromRequest(existing *corev1.Secret, req *model.UpdateSecretReq) (*corev1.Secret, error)
UpdateSecretFromRequest 从更新请求更新 Kubernetes Secret
func ValidateAnnotationKey ¶
ValidateAnnotationKey 验证注解键
func ValidateAnnotationValue ¶
ValidateAnnotationValue 验证注解值
func ValidateAnnotations ¶
ValidateAnnotations 验证注解
func ValidateBasicParams ¶
ValidateBasicParams 验证基础参数
func ValidateClusterCreateParams ¶
ValidateClusterCreateParams 验证创建集群的参数
func ValidateClusterExists ¶
func ValidateClusterExists(cluster *model.K8sCluster, clusterID int) error
ValidateClusterExists 验证集群是否存在
func ValidateClusterRole ¶
func ValidateClusterRole(clusterRole *rbacv1.ClusterRole) error
ValidateClusterRole 验证 ClusterRole 配置
func ValidateClusterUpdateParams ¶
ValidateClusterUpdateParams 验证更新集群的参数
func ValidateContainerName ¶
ValidateContainerName 验证容器名称
func ValidateDaemonSet ¶
ValidateDaemonSet 验证DaemonSet配置
func ValidateDeployment ¶
func ValidateDeployment(deployment *appsv1.Deployment) error
ValidateDeployment 验证Deployment配置
func ValidateIngress ¶
func ValidateIngress(ingress *networkingv1.Ingress) error
ValidateIngress 验证Ingress配置
func ValidateKubernetesName ¶
ValidateKubernetesName 验证Kubernetes资源名称
func ValidateNamespaceFilters ¶
func ValidateNamespaceFilters(req *model.K8sNamespaceListReq) error
ValidateNamespaceFilters 验证命名空间过滤参数
func ValidateNamespaceName ¶
ValidateNamespaceName 验证命名空间名称
func ValidateNodeLabels ¶
ValidateNodeLabels 验证节点标签
func ValidateNodeLabelsMap ¶
ValidateNodeLabelsMap 验证节点标签映射
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 ValidateResourceQuantities ¶
func ValidateResourceQuantities(cluster *model.K8sCluster) error
ValidateResourceQuantities 验证资源配额格式
func ValidateResourceQuota ¶
ValidateResourceQuota 验证资源配额
func ValidateSecretData ¶
func ValidateSecretData(secretType corev1.SecretType, data map[string][]byte, stringData map[string]string) error
ValidateSecretData 验证 Secret 数据的有效性
func ValidateService ¶
ValidateService 验证Service配置
func ValidateStatefulSet ¶
func ValidateStatefulSet(statefulSet *appsv1.StatefulSet) error
ValidateStatefulSet 验证StatefulSet配置
func ValidateYamlContent ¶
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 ¶
YAMLToConfigMap 将 YAML 反序列化为 ConfigMap
func YAMLToDaemonSet ¶
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 YAMLToRoleBinding ¶
func YAMLToRoleBinding(yamlStr string) (*rbacv1.RoleBinding, error)
YAMLToRoleBinding 将YAML转换为RoleBinding
func YAMLToSecret ¶
YAMLToSecret 将 YAML 反序列化为 Secret
func YAMLToService ¶
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 ¶
NewK8sError 创建新的Kubernetes错误
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)