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 ConvertCreatePVReqToPVWithValidation(req *model.CreatePVReq) (*corev1.PersistentVolume, error)
- 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 FormatBytes(bytes int64) string
- 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
func AddOrUpdateTaint ¶
func ApplySingleDocument ¶
func ApplyYamlToCluster ¶
func BuildClusterRoleBindingListOptions ¶
func BuildClusterRoleBindingListOptions(req *model.GetClusterRoleBindingListReq) metav1.ListOptions
func BuildClusterRoleListOptions ¶
func BuildClusterRoleListOptions(req *model.GetClusterRoleListReq) metav1.ListOptions
func BuildClusterRoleListQueryOptions ¶
func BuildClusterRoleListQueryOptions(req *model.GetClusterRoleListReq) metav1.ListOptions
func BuildConfigMapListOptions ¶
func BuildConfigMapListOptions(labelSelector string) metav1.ListOptions
func BuildDaemonSetFromRequest ¶
func BuildDaemonSetFromRequest(req *model.CreateDaemonSetReq) (*appsv1.DaemonSet, error)
func BuildDaemonSetFromYaml ¶ added in v0.0.4
func BuildDaemonSetFromYaml(req *model.CreateDaemonSetByYamlReq) (*appsv1.DaemonSet, error)
func BuildDaemonSetFromYamlForUpdate ¶ added in v0.0.4
func BuildDaemonSetFromYamlForUpdate(req *model.UpdateDaemonSetByYamlReq) (*appsv1.DaemonSet, error)
func BuildDaemonSetListOptions ¶
func BuildDaemonSetListOptions(req *model.GetDaemonSetListReq) metav1.ListOptions
func BuildDeleteOptions ¶
func BuildDeleteOptions(gracePeriodSeconds int) metav1.DeleteOptions
func BuildDeploymentFromRequest ¶
func BuildDeploymentFromRequest(req *model.CreateDeploymentReq) (*appsv1.Deployment, error)
func BuildDeploymentFromYaml ¶
func BuildDeploymentFromYaml(req *model.CreateDeploymentByYamlReq) (*appsv1.Deployment, error)
func BuildDeploymentFromYamlForUpdate ¶
func BuildDeploymentFromYamlForUpdate(req *model.UpdateDeploymentByYamlReq) (*appsv1.Deployment, error)
func BuildDeploymentListOptions ¶
func BuildDeploymentListOptions(req *model.GetDeploymentListReq) metav1.ListOptions
func BuildDeploymentListPagination ¶
func BuildDeploymentListPagination(deployments []appsv1.Deployment, page, size int) ([]appsv1.Deployment, int64)
func BuildIngressFromSpec ¶
func BuildIngressFromSpec(req *model.CreateIngressReq) (*networkingv1.Ingress, error)
BuildIngressFromSpec 根据请求构建Ingress对象
func BuildIngressListOptions ¶
func BuildIngressListOptions(req *model.GetIngressListReq) metav1.ListOptions
func BuildK8sClusterRole ¶
func BuildK8sClusterRole(name string, labels, annotations model.KeyValueList, rules []model.PolicyRule) *rbacv1.ClusterRole
func BuildK8sClusterRoleBinding ¶
func BuildK8sClusterRoleBinding(name string, labels, annotations model.KeyValueList, roleRef model.RoleRef, subjects []model.Subject) *rbacv1.ClusterRoleBinding
func BuildK8sDaemonSet ¶
func BuildK8sDaemonSetHistory ¶
func BuildK8sDaemonSetHistory(revision appsv1.ControllerRevision) (*model.K8sDaemonSetHistory, error)
func BuildK8sDeployment ¶
func BuildK8sDeployment(ctx context.Context, clusterID int, deployment appsv1.Deployment) (*model.K8sDeployment, error)
func BuildK8sNode ¶
func BuildK8sRole ¶
func BuildK8sRole(name, namespace string, labels, annotations model.KeyValueList, rules []model.PolicyRule) *rbacv1.Role
func BuildK8sRoleBinding ¶
func BuildK8sRoleBinding(name, namespace string, labels, annotations model.KeyValueList, roleRef model.RoleRef, subjects []model.Subject) *rbacv1.RoleBinding
func BuildK8sServiceAccount ¶
func BuildK8sServiceAccount(name, namespace string, labels, annotations model.KeyValueList) *corev1.ServiceAccount
func BuildK8sServiceFromCore ¶ added in v0.0.8
func BuildK8sServiceFromCore(clusterID int, service corev1.Service) *model.K8sService
func BuildK8sStatefulSet ¶
func BuildK8sStatefulSet(ctx context.Context, clusterID int, statefulSet appsv1.StatefulSet) (*model.K8sStatefulSet, error)
func BuildK8sStatefulSetHistory ¶
func BuildK8sStatefulSetHistory(revision appsv1.ControllerRevision) (*model.K8sStatefulSetHistory, error)
func BuildNamespaceListOptions ¶
func BuildNamespaceListOptions(req *model.K8sNamespaceListReq) metav1.ListOptions
func BuildNodeListOptions ¶
func BuildNodeListOptions(req *model.GetNodeListReq) metav1.ListOptions
func BuildNodeListPagination ¶
func BuildPVCListOptions ¶
func BuildPVCListOptions(req *model.GetPVCListReq) metav1.ListOptions
func BuildPVListOptions ¶
func BuildPVListOptions(req *model.GetPVListReq) metav1.ListOptions
func BuildPodFromRequest ¶
func BuildPodFromRequest(req *model.CreatePodReq) (*corev1.Pod, error)
func BuildRoleBindingListOptions ¶
func BuildRoleBindingListOptions(req *model.GetRoleBindingListReq) metav1.ListOptions
func BuildRoleListOptions ¶
func BuildRoleListOptions(req *model.GetRoleListReq) metav1.ListOptions
func BuildSecretFromRequest ¶
func BuildSecretFromRequest(req *model.CreateSecretReq) (*corev1.Secret, error)
func BuildServiceAccountListOptions ¶
func BuildServiceAccountListOptions(req *model.GetServiceAccountListReq) metav1.ListOptions
func BuildServiceAccountResponse ¶
func BuildServiceAccountResponse(sa *corev1.ServiceAccount, clusterID int) *model.K8sServiceAccount
func BuildServiceFromRequest ¶
func BuildServiceFromRequest(req *model.CreateServiceReq) (*corev1.Service, error)
func BuildServiceListOptions ¶
func BuildServiceListOptions(req *model.GetServiceListReq) metav1.ListOptions
func BuildStatefulSetFromRequest ¶
func BuildStatefulSetFromRequest(req *model.CreateStatefulSetReq) (*appsv1.StatefulSet, error)
func BuildStatefulSetFromYaml ¶ added in v0.0.4
func BuildStatefulSetFromYaml(req *model.CreateStatefulSetByYamlReq) (*appsv1.StatefulSet, error)
func BuildStatefulSetFromYamlForUpdate ¶ added in v0.0.4
func BuildStatefulSetFromYamlForUpdate(req *model.UpdateStatefulSetByYamlReq) (*appsv1.StatefulSet, error)
func BuildStatefulSetListOptions ¶
func BuildStatefulSetListOptions(req *model.GetStatefulSetListReq) metav1.ListOptions
func BuildStatefulSetListPagination ¶ added in v0.0.5
func BuildStatefulSetListPagination(statefulSets []appsv1.StatefulSet, page, size int) ([]appsv1.StatefulSet, int64)
func CalculatePVCStorageUsage ¶
func CalculatePVCStorageUsage(pvc corev1.PersistentVolumeClaim) (float64, error)
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
func ConvertClusterRoleToYAML ¶
func ConvertClusterRoleToYAML(clusterRole *rbacv1.ClusterRole) (string, error)
func ConvertClusterRolesToModel ¶
func ConvertClusterRolesToModel(clusterRoles []rbacv1.ClusterRole, clusterID int) []*model.K8sClusterRole
func ConvertCreatePVCReqToPVC ¶
func ConvertCreatePVCReqToPVC(req *model.CreatePVCReq) *corev1.PersistentVolumeClaim
func ConvertCreatePVReqToPV ¶
func ConvertCreatePVReqToPV(req *model.CreatePVReq) *corev1.PersistentVolume
func ConvertCreatePVReqToPVWithValidation ¶ added in v0.0.13
func ConvertCreatePVReqToPVWithValidation(req *model.CreatePVReq) (*corev1.PersistentVolume, error)
ConvertCreatePVReqToPVWithValidation 将请求转换为PV对象并验证卷源
func ConvertEndpointsToModel ¶ added in v0.0.8
func ConvertEndpointsToModel(endpoints *corev1.Endpoints) []model.K8sServiceEndpoint
func ConvertK8sClusterRoleBindingToClusterRoleBindingInfo ¶
func ConvertK8sClusterRoleBindingToClusterRoleBindingInfo(clusterRoleBinding *rbacv1.ClusterRoleBinding, clusterID int) model.K8sClusterRoleBinding
func ConvertK8sClusterRoleToClusterRoleInfo ¶
func ConvertK8sClusterRoleToClusterRoleInfo(clusterRole *rbacv1.ClusterRole, clusterID int) model.K8sClusterRole
func ConvertK8sPolicyRulesToModel ¶
func ConvertK8sPolicyRulesToModel(rules []rbacv1.PolicyRule) []model.PolicyRule
func ConvertK8sRoleBindingToRoleBindingInfo ¶
func ConvertK8sRoleBindingToRoleBindingInfo(roleBinding *rbacv1.RoleBinding, clusterID int) *model.K8sRoleBinding
func ConvertLabelsToKeyValueList ¶
func ConvertLabelsToKeyValueList(labels map[string]string) model.KeyValueList
func ConvertPodContainers ¶
func ConvertPodContainers(pod *corev1.Pod) []model.PodContainer
func ConvertPolicyRulesToK8s ¶
func ConvertPolicyRulesToK8s(rules []model.PolicyRule) []rbacv1.PolicyRule
func ConvertToCorePorts ¶
func ConvertToCorePorts(ports []model.ServicePort) []corev1.ServicePort
func ConvertToK8sClusterRole ¶
func ConvertToK8sClusterRole(req *model.CreateClusterRoleReq) *rbacv1.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
func ConvertToK8sDeployment ¶
func ConvertToK8sDeployment(deployment *appsv1.Deployment) *model.K8sDeployment
func ConvertToK8sIngress ¶
func ConvertToK8sIngress(ingress *networkingv1.Ingress, clusterID int) *model.K8sIngress
func ConvertToK8sNamespace ¶
func ConvertToK8sNamespace(name string, labels, annotations model.KeyValueList) *corev1.Namespace
func ConvertToK8sRole ¶
func ConvertToK8sRole(req *model.CreateRoleReq) *rbacv1.Role
func ConvertToK8sRoleBinding ¶
func ConvertToK8sRoleBinding(req *model.CreateRoleBindingReq) *rbacv1.RoleBinding
func ConvertToK8sServiceAccount ¶
func ConvertToK8sServiceAccount(req *model.CreateServiceAccountReq) *corev1.ServiceAccount
func ConvertToK8sStatefulSet ¶ added in v0.0.4
func ConvertToK8sStatefulSet(statefulSet *appsv1.StatefulSet) *model.K8sStatefulSet
func ConvertToPVCEntities ¶
func ConvertToPVCEntities(pvcs []corev1.PersistentVolumeClaim, clusterID int) []*model.K8sPVC
func ConvertToPVCEntity ¶
func ConvertToPVCEntity(pvc *corev1.PersistentVolumeClaim, clusterID int) *model.K8sPVC
func ConvertToPVEntities ¶
func ConvertToPVEntities(pvs []corev1.PersistentVolume, clusterID int) []*model.K8sPV
func ConvertToPVEntity ¶
func ConvertToPVEntity(pv *corev1.PersistentVolume, clusterID int) *model.K8sPV
func ConvertUnstructuredToYAML ¶
func ConvertUnstructuredToYAML(obj *unstructured.Unstructured) (string, error)
func ConvertUpdatePVCReqToPVC ¶
func ConvertUpdatePVCReqToPVC(req *model.UpdatePVCReq) *corev1.PersistentVolumeClaim
func ConvertUpdatePVReqToPV ¶
func ConvertUpdatePVReqToPV(req *model.UpdatePVReq, existingPV *corev1.PersistentVolume) *corev1.PersistentVolume
基于现有PV对象更新可变字段,保留不可变字段
func CreateServiceAccountToken ¶
func CreateServiceAccountToken(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string, expiryTime *int64) (*model.ServiceAccountTokenInfo, error)
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 FormatBytes ¶ added in v0.0.10
func FormatEventAge ¶
func GetChangeReason ¶ added in v0.0.4
func GetClusterRoleAge ¶
func GetClusterRoleAge(clusterRole rbacv1.ClusterRole) string
func GetClusterRolePermissions ¶
func GetClusterRolePermissions(clusterRole rbacv1.ClusterRole) map[string][]string
func GetDeploymentAge ¶
func GetDeploymentAge(deployment appsv1.Deployment) string
func GetDeploymentHistory ¶
func GetDeploymentHistory(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, deploymentName string) ([]*model.K8sDeploymentHistory, int64, error)
func GetDeploymentPods ¶
func GetEventSeverity ¶
func GetEventSeverity(eventType, reason string) model.EventSeverity
func GetEventSummary ¶
func GetIngressAge ¶
func GetIngressAge(ingress networkingv1.Ingress) string
func GetInt32Value ¶
func GetNamespaceStatus ¶
func GetNamespaceStatus(phase corev1.NamespacePhase) string
func GetNodeStatusMessage ¶
func GetNodeTaintsByEffect ¶
func GetPVAge ¶
func GetPVAge(pv corev1.PersistentVolume) string
func GetPVCAccessModes ¶
func GetPVCAccessModes(pvc corev1.PersistentVolumeClaim) []string
func GetPVCActualStorageSize ¶
func GetPVCActualStorageSize(pvc corev1.PersistentVolumeClaim) string
func GetPVCAge ¶
func GetPVCAge(pvc corev1.PersistentVolumeClaim) string
func GetPVCCapacity ¶
func GetPVCCapacity(pvc corev1.PersistentVolumeClaim) (string, int64)
func GetPVCStorageSize ¶
func GetPVCStorageSize(pvc corev1.PersistentVolumeClaim) string
func GetPVCapacity ¶
func GetPVCapacity(pv corev1.PersistentVolume) (string, int64)
func GetServiceAccountToken ¶
func GetServiceAccountToken(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string) (*model.ServiceAccountTokenInfo, error)
func GetStatefulSetAge ¶ added in v0.0.5
func GetStatefulSetAge(statefulSet appsv1.StatefulSet) string
func GetStatefulSetPods ¶ added in v0.0.5
func GroupEventsByObject ¶
GroupEventsByObject 按涉及对象分组
func GroupEventsByReason ¶
GroupEventsByReason 按事件原因分组
func GroupEventsByType ¶
GroupEventsByType 按事件类型分组
func HandleK8sError ¶
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 ¶
func ParseTaintYaml ¶
func ParseYAMLToClusterRole ¶
func ParseYAMLToClusterRole(yamlContent string) (*rbacv1.ClusterRole, error)
ParseYAMLToClusterRole 将 YAML 转换为 ClusterRole
func 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 ValidateAnnotationKey ¶
func ValidateAnnotationValue ¶
func ValidateAnnotations ¶
func ValidateBasicParams ¶
func ValidateClusterExists ¶
func ValidateClusterExists(cluster *model.K8sCluster, clusterID int) error
func ValidateClusterID ¶
func ValidateClusterRole ¶
func ValidateClusterRole(clusterRole *rbacv1.ClusterRole) error
func ValidateContainerName ¶
func ValidateDaemonSet ¶
func ValidateDeployment ¶
func ValidateDeployment(deployment *appsv1.Deployment) error
func ValidateImageName ¶
func ValidateIngress ¶
func ValidateIngress(ingress *networkingv1.Ingress) error
func ValidateKubernetesName ¶
func ValidateLabelKey ¶
func ValidateLabelKeys ¶
func ValidateLabelPrefix ¶
func ValidateLabelValue ¶
func ValidateLabels ¶
func ValidateName ¶
func ValidateNamespace ¶
func ValidateNamespaceFilters ¶
func ValidateNamespaceFilters(req *model.K8sNamespaceListReq) error
func ValidateNamespaceName ¶
func ValidateNodeLabels ¶
func ValidateNodeLabelsMap ¶
func ValidateNodeName ¶
func ValidatePV ¶
func ValidatePV(pv *corev1.PersistentVolume) error
func ValidatePVC ¶
func ValidatePVC(pvc *corev1.PersistentVolumeClaim) error
func ValidatePVCCreate ¶
func ValidatePVCCreate(req *model.CreatePVCReq) error
func ValidatePVCUpdate ¶
func ValidatePVCUpdate(req *model.UpdatePVCReq) error
func ValidatePVCreate ¶
func ValidatePVCreate(req *model.CreatePVReq) error
func ValidatePVUpdate ¶
func ValidatePVUpdate(req *model.UpdatePVReq) error
func ValidatePod ¶
func ValidateRequest ¶
func ValidateRequest(req interface{}) error
func ValidateResourceQuantities ¶
func ValidateResourceQuantities(cluster *model.K8sCluster) error
func ValidateResourceQuota ¶
func ValidateSecretData ¶
func ValidateService ¶
func ValidateStatefulSet ¶
func ValidateStatefulSet(statefulSet *appsv1.StatefulSet) error
func ValidateTaint ¶
func ValidateYamlContent ¶
func ValidateYamlWithCluster ¶
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 K8sError ¶
type K8sError struct {
Operation string
Resource string
Name string
Namespace string
ClusterID int
Err error
}
K8sError 定义Kubernetes相关错误类型
func NewK8sError ¶
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)