k8s

package
v0.0.0-...-5a269ca Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const QuotaName = "compute-quota"

Variables

This section is empty.

Functions

func ApplyLimitRange

func ApplyLimitRange(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string, cluster *model.K8sCluster) error

ApplyLimitRange 应用 LimitRange 到指定命名空间

func ApplyResourceQuota

func ApplyResourceQuota(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string, cluster *model.K8sCluster) error

ApplyResourceQuota 应用 ResourceQuota 到指定命名空间

func BuildK8sContainers

func BuildK8sContainers(containers []corev1.Container) []model.K8sPodContainer

BuildK8sContainers 构建 K8sContainer 列表

func BuildK8sContainersWithPointer

func BuildK8sContainersWithPointer(k8sContainers []model.K8sPodContainer) []*model.K8sPodContainer

BuildK8sContainersWithPointer 转换普通切片为指针切片

func BuildK8sNode

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

func BuildK8sPods

func BuildK8sPods(pods *corev1.PodList) []*model.K8sPod

BuildK8sPods BuildK8sNodes 构建 K8sNode 列表

func EnsureNamespace

func EnsureNamespace(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string) error

EnsureNamespace 确保指定的命名空间存在,如果不存在则创建

func GetDaemonSetResources

func GetDaemonSetResources(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string) ([]model.Resource, error)

GetDaemonSetResources 获取 DaemonSet 资源

func GetDeploymentResources

func GetDeploymentResources(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string) ([]model.Resource, error)

GetDeploymentResources 获取 Deployment 资源

func GetDynamicClient

func GetDynamicClient(ctx context.Context, id int, clusterDao admin.ClusterDAO, client client.K8sClient) (*dynamic.DynamicClient, error)

func GetInternalIP

func GetInternalIP(node corev1.Node) string

GetInternalIP 获取节点内部IP

func GetKubeAndMetricsClient

func GetKubeAndMetricsClient(id int, logger *zap.Logger, client client.K8sClient) (*kubernetes.Clientset, *metricsClient.Clientset, error)

func GetKubeClient

func GetKubeClient(clusterId int, client client.K8sClient, l *zap.Logger) (*kubernetes.Clientset, error)

GetKubeClient 获取 Kubernetes 客户端

func GetNodeAge

func GetNodeAge(node corev1.Node) string

GetNodeAge 计算节点存在时间

func GetNodeEvents

func GetNodeEvents(ctx context.Context, client *kubernetes.Clientset, nodeName string) ([]model.OneEvent, error)

GetNodeEvents 获取节点事件

func GetNodeLabels

func GetNodeLabels(node corev1.Node) []string

GetNodeLabels 获取节点标签

func GetNodeResource

func GetNodeResource(ctx context.Context, metricsCli *metricsClient.Clientset, nodeName string, pods *corev1.PodList, node *corev1.Node) ([]string, error)

GetNodeResource 获取节点资源信息

func GetNodeRoles

func GetNodeRoles(node corev1.Node) []string

GetNodeRoles 获取节点角色

func GetNodeStatus

func GetNodeStatus(node corev1.Node) string

GetNodeStatus 获取节点状态

func GetNodesByName

func GetNodesByName(ctx context.Context, client *kubernetes.Clientset, nodeName string) (*corev1.NodeList, error)

GetNodesByName 获取指定集群上的 Node 列表

func GetPodResources

func GetPodResources(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string) ([]model.Resource, error)

GetPodResources 获取 Pod 资源

func GetPodsByNodeName

func GetPodsByNodeName(ctx context.Context, client *kubernetes.Clientset, nodeName string) (*corev1.PodList, error)

GetPodsByNodeName 获取指定节点上的 Pod 列表

func GetReplicaSetResources

func GetReplicaSetResources(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string) ([]model.Resource, error)

GetReplicaSetResources 获取 ReplicaSet 资源

func GetResourceName

func GetResourceName(kind string) string

GetResourceName 根据 Kind 获取资源名称

func GetResourceString

func GetResourceString(node corev1.Node, resourceName string) string

GetResourceString 获取节点资源信息

func GetServiceResources

func GetServiceResources(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string) ([]model.Resource, error)

GetServiceResources 获取 Service 资源

func GetStatefulSetResources

func GetStatefulSetResources(ctx context.Context, kubeClient *kubernetes.Clientset, namespace string) ([]model.Resource, error)

GetStatefulSetResources 获取 StatefulSet 资源

func GetTaintsMapFromTaints

func GetTaintsMapFromTaints(taints []corev1.Taint) map[string]corev1.Taint

GetTaintsMapFromTaints 将 taints 转换为键为 "Key:Value:Effect" 的 map

func InitAadGetKubeClient

func InitAadGetKubeClient(ctx context.Context, cluster *model.K8sCluster, logger *zap.Logger, client client.K8sClient) (*kubernetes.Clientset, error)

func IsNodeSchedulable

func IsNodeSchedulable(node corev1.Node) bool

IsNodeSchedulable 判断节点是否可调度

func MergeTaints

func MergeTaints(existingTaints []corev1.Taint, newTaints []corev1.Taint) []corev1.Taint

MergeTaints 合并新的 taints,避免重复

func RemoveTaints

func RemoveTaints(existingTaints []corev1.Taint, taintsToDelete []corev1.Taint) []corev1.Taint

RemoveTaints 从现有的 taints 中删除指定的 taints

Types

This section is empty.

Jump to

Keyboard shortcuts

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