kom

package
v0.1.55 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 43 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractDeploymentRevision added in v0.0.30

func ExtractDeploymentRevision(annotations map[string]string) (int, error)

ExtractDeploymentRevision 从 annotations 中提取 deployment.kubernetes.io/revision 的值,并转换为 int

Types

type ClusterInst added in v0.1.29

type ClusterInst struct {
	ID            string                 // 集群ID
	Kubectl       *Kubectl               // kom
	Client        *kubernetes.Clientset  // kubernetes 客户端
	Config        *rest.Config           // rest config
	DynamicClient *dynamic.DynamicClient // 动态客户端

	Cache *ristretto.Cache[string, any]
	// contains filtered or unexported fields
}

ClusterInst 单一集群实例

type ClusterInstances added in v0.0.10

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

ClusterInstances 集群实例管理器

func Clusters added in v0.0.10

func Clusters() *ClusterInstances

Clusters 集群实例管理器

func (*ClusterInstances) AllClusters added in v0.0.10

func (c *ClusterInstances) AllClusters() map[string]*ClusterInst

AllClusters 返回所有集群实例

func (*ClusterInstances) DefaultCluster added in v0.0.10

func (c *ClusterInstances) DefaultCluster() *ClusterInst

DefaultCluster 返回一个默认的 ClusterInst 实例。 当 clusters 列表为空时,返回 nil。 首先尝试返回 ID 为 "InCluster" 的实例,如果不存在, 则尝试返回 ID 为 "default" 的实例。 如果上述两个实例都不存在,则返回 clusters 列表中的任意一个实例。

func (*ClusterInstances) GetClusterById added in v0.0.10

func (c *ClusterInstances) GetClusterById(id string) *ClusterInst

GetClusterById 根据集群ID获取集群实例

func (*ClusterInstances) RegisterByConfig added in v0.0.10

func (c *ClusterInstances) RegisterByConfig(config *rest.Config) (*Kubectl, error)

RegisterByConfig 注册集群

func (*ClusterInstances) RegisterByConfigWithID added in v0.0.10

func (c *ClusterInstances) RegisterByConfigWithID(config *rest.Config, id string) (*Kubectl, error)

RegisterByConfigWithID 注册集群

func (*ClusterInstances) RegisterByPath added in v0.0.10

func (c *ClusterInstances) RegisterByPath(path string) (*Kubectl, error)

RegisterByPath 通过kubeconfig文件路径注册集群

func (*ClusterInstances) RegisterByPathWithID added in v0.0.10

func (c *ClusterInstances) RegisterByPathWithID(path string, id string) (*Kubectl, error)

RegisterByPathWithID 通过kubeconfig文件路径注册集群

func (*ClusterInstances) RegisterInCluster added in v0.0.10

func (c *ClusterInstances) RegisterInCluster() (*Kubectl, error)

RegisterInCluster 注册InCluster集群

func (*ClusterInstances) RemoveClusterById added in v0.1.5

func (c *ClusterInstances) RemoveClusterById(id string)

RemoveClusterById 删除集群

func (*ClusterInstances) SetRegisterCallbackFunc added in v0.0.10

func (c *ClusterInstances) SetRegisterCallbackFunc(callback func(cluster *ClusterInst) func())

SetRegisterCallbackFunc 设置回调注册函数

func (*ClusterInstances) Show added in v0.0.10

func (c *ClusterInstances) Show()

Show 显示所有集群信息

type Condition added in v0.1.0

type Condition struct {
	Depth     int
	AndOr     string
	Field     string
	Operator  string
	Value     interface{} // 通过detectType 赋值为精确类型值,detectType之前都是string
	ValueType string      // number, string, bool, time
}

type ContainerInfo added in v0.1.51

type ContainerInfo struct {
	Name  string `json:"name,omitempty"`
	Image string `json:"image,omitempty"`
}

type Env added in v0.1.33

type Env struct {
	ContainerName string `json:"containerName,omitempty"`
	EnvName       string `json:"envName,omitempty"`
	EnvValue      string `json:"envValue,omitempty"`
}

Env 每行三个值,容器名称、ENV名称、ENV值

type FileInfo added in v0.0.21

type FileInfo struct {
	Name        string `json:"name"`
	Type        string `json:"type"` // file or directory
	Permissions string `json:"permissions"`
	Owner       string `json:"owner"`
	Group       string `json:"group"`
	Size        int64  `json:"size"`
	ModTime     string `json:"modTime"`
	Path        string `json:"path"`  // 存储路径
	IsDir       bool   `json:"isDir"` // 指示是否
}

FileInfo 文件节点结构

type Filter added in v0.1.0

type Filter struct {
	Columns    []string    `json:"columns,omitempty"`
	Conditions []Condition `json:"condition,omitempty"` // xx=?
	Order      string      `json:"order,omitempty"`
	Limit      int         `json:"limit,omitempty"`
	Offset     int         `json:"offset,omitempty"`
	Sql        string      `json:"sql,omitempty"`    // 原始sql
	Parsed     bool        `json:"parsed,omitempty"` // 是否解析过
	From       string      `json:"from,omitempty"`   // From TableName
}

type Kubectl added in v0.0.10

type Kubectl struct {
	ID        string     // cluster id
	Statement *Statement // statement
	Error     error      // 存放ERROR信息
	// contains filtered or unexported fields
}

func Cluster added in v0.0.10

func Cluster(id string) *Kubectl

Cluster 获取集群

func DefaultCluster added in v0.0.10

func DefaultCluster() *Kubectl

DefaultCluster 获取默认集群,简化调用方式

func (*Kubectl) AllNamespace added in v0.0.30

func (k *Kubectl) AllNamespace() *Kubectl

func (*Kubectl) Applier added in v0.0.10

func (k *Kubectl) Applier() *applier

func (*Kubectl) CRD added in v0.0.10

func (k *Kubectl) CRD(group string, version string, kind string) *Kubectl

func (*Kubectl) Callback added in v0.0.10

func (k *Kubectl) Callback() *callbacks

func (*Kubectl) Client added in v0.0.10

func (k *Kubectl) Client() *kubernetes.Clientset

func (*Kubectl) ClusterCache added in v0.1.18

func (k *Kubectl) ClusterCache() *ristretto.Cache[string, any]

func (*Kubectl) Command deprecated added in v0.0.15

func (k *Kubectl) Command(command string, args ...string) *Kubectl

Deprecated: use Ctl().Pod().Command() instead.

func (*Kubectl) ContainerName added in v0.0.15

func (k *Kubectl) ContainerName(c string) *Kubectl

ContainerName Deprecated: use Ctl().Pod().ContainerName() instead.

func (*Kubectl) Create added in v0.0.10

func (k *Kubectl) Create(dest interface{}) *Kubectl

func (*Kubectl) Ctl added in v0.0.25

func (k *Kubectl) Ctl() *ctl

func (*Kubectl) Delete added in v0.0.10

func (k *Kubectl) Delete() *Kubectl

func (*Kubectl) Describe added in v0.1.4

func (k *Kubectl) Describe(dest interface{}) *Kubectl

func (*Kubectl) DynamicClient added in v0.0.10

func (k *Kubectl) DynamicClient() *dynamic.DynamicClient

func (*Kubectl) Execute added in v0.0.15

func (k *Kubectl) Execute(dest interface{}) *Kubectl

Execute 请确保dest 是一个指向字节切片的指针。定义var s []byte 使用&s Deprecated: use Ctl().Pod().Command().Execute() instead.

func (*Kubectl) FillTotalCount added in v0.1.22

func (k *Kubectl) FillTotalCount(total *int64) *Kubectl

func (*Kubectl) ForceDelete added in v0.1.44

func (k *Kubectl) ForceDelete() *Kubectl

func (*Kubectl) From added in v0.1.0

func (k *Kubectl) From(tableName string) *Kubectl

func (*Kubectl) GVK added in v0.0.11

func (k *Kubectl) GVK(group string, version string, kind string) *Kubectl

func (*Kubectl) Get added in v0.0.10

func (k *Kubectl) Get(dest interface{}) *Kubectl

func (*Kubectl) GetLogs deprecated added in v0.0.15

func (k *Kubectl) GetLogs(requestPtr interface{}, opt *v1.PodLogOptions) *Kubectl

Deprecated: use Ctl().Pod().GetLogs() instead.

func (*Kubectl) Limit added in v0.1.0

func (k *Kubectl) Limit(limit int) *Kubectl

func (*Kubectl) List added in v0.0.10

func (k *Kubectl) List(dest interface{}, opt ...metav1.ListOptions) *Kubectl

func (*Kubectl) Name added in v0.0.10

func (k *Kubectl) Name(name string) *Kubectl

func (*Kubectl) Namespace added in v0.0.10

func (k *Kubectl) Namespace(namespaces ...string) *Kubectl

Namespace 设置命名空间 * 传入*代表取所有的命名空间,等同于调用AllNamespace()方法

func (*Kubectl) Offset added in v0.1.0

func (k *Kubectl) Offset(offset int) *Kubectl

func (*Kubectl) Order added in v0.1.0

func (k *Kubectl) Order(order string) *Kubectl

Order Order(" id desc") Order(" date asc")

func (*Kubectl) Patch added in v0.0.10

func (k *Kubectl) Patch(dest interface{}, pt types.PatchType, data string) *Kubectl

func (*Kubectl) Poder deprecated added in v0.0.10

func (k *Kubectl) Poder() *pod

Deprecated: use Ctl().Pod() instead.

func (*Kubectl) RemoveManagedFields added in v0.0.32

func (k *Kubectl) RemoveManagedFields() *Kubectl

func (*Kubectl) Resource added in v0.0.10

func (k *Kubectl) Resource(obj runtime.Object) *Kubectl

func (*Kubectl) RestConfig added in v0.0.10

func (k *Kubectl) RestConfig() *rest.Config

func (*Kubectl) Skip added in v0.1.0

func (k *Kubectl) Skip(skip int) *Kubectl

Skip AliasFor Offset

func (*Kubectl) Sql added in v0.1.0

func (k *Kubectl) Sql(sql string, values ...interface{}) *Kubectl

Sql TODO Insert Update Delete

 已支持Select
	解析sql为函数调用,实现支持原生sql语句

select * from pod where pod.name='?', 'abc'

func (*Kubectl) Status added in v0.0.10

func (k *Kubectl) Status() *status

func (*Kubectl) Stdin deprecated added in v0.0.16

func (k *Kubectl) Stdin(reader io.Reader) *Kubectl

Deprecated: use Ctl().Pod().Stdin() instead.

func (*Kubectl) Tools added in v0.0.23

func (k *Kubectl) Tools() *tools

func (*Kubectl) Update added in v0.0.10

func (k *Kubectl) Update(dest interface{}) *Kubectl

func (*Kubectl) Watch added in v0.0.22

func (k *Kubectl) Watch(dest interface{}, opt ...metav1.ListOptions) *Kubectl

func (*Kubectl) Where added in v0.1.0

func (k *Kubectl) Where(condition string, values ...interface{}) *Kubectl

func (*Kubectl) WithCache added in v0.1.18

func (k *Kubectl) WithCache(ttl time.Duration) *Kubectl

func (*Kubectl) WithContext added in v0.0.10

func (k *Kubectl) WithContext(ctx context.Context) *Kubectl

func (*Kubectl) WithFieldSelector added in v0.0.24

func (k *Kubectl) WithFieldSelector(fieldSelector string) *Kubectl

func (*Kubectl) WithLabelSelector added in v0.0.24

func (k *Kubectl) WithLabelSelector(labelSelector string) *Kubectl

type PodMount added in v0.1.35

type PodMount struct {
	Name      string `json:"name",omitempty`
	MountPath string `json:"mountPath",omitempty`
	SubPath   string `json:"subPath",omitempty`
	Mode      *int32 `json:"mode",omitempty`
	ReadOnly  bool   `json:"readOnly",omitempty`
}

PodMount 是Pod的挂载信息 挂载的类型有:configMap、secret

type ResourceUsageFraction added in v0.1.9

type ResourceUsageFraction struct {
	RequestFraction float64 `json:"requestFraction"` // 请求使用占比(百分比)占总可分配值的比例
	LimitFraction   float64 `json:"limitFraction"`   // 限制使用占比(百分比)占总可分配值的比例
}

ResourceUsageFraction 定义单种资源的使用占比

type ResourceUsageResult added in v0.1.9

type ResourceUsageResult struct {
	Requests       map[corev1.ResourceName]resource.Quantity     `json:"requests"`       // 请求用量
	Limits         map[corev1.ResourceName]resource.Quantity     `json:"limits"`         // 限制用量
	Allocatable    map[corev1.ResourceName]resource.Quantity     `json:"allocatable"`    // 节点可分配的实时值
	UsageFractions map[corev1.ResourceName]ResourceUsageFraction `json:"usageFractions"` // 使用占比
}

ResourceUsageResult 定义资源使用情况的结构体 存放Pod、Node 的资源使用情况

type ResourceUsageRow added in v0.1.11

type ResourceUsageRow struct {
	ResourceType    string `json:"resourceType"`
	Total           string `json:"total"`
	Request         string `json:"request"`
	RequestFraction string `json:"requestFraction"`
	Limit           string `json:"limit"`
	LimitFraction   string `json:"limitFraction"`
}

ResourceUsageRow 临时结构体,用于存储每一行数据

type RolloutHistory added in v0.0.31

type RolloutHistory struct {
	Kind              string                  `json:"kind,omitempty"`
	Name              string                  `json:"name,omitempty"`
	Namespace         string                  `json:"namespace,omitempty"`
	Revision          string                  `json:"revision,omitempty"`
	CreationTimestamp metav1.Time             `json:"creationTimestamp"`
	GVK               schema.GroupVersionKind `json:"gvk,omitempty"`
	ExtraInfo         map[string]string       `json:"extraInfo,omitempty"`
	Containers        []ContainerInfo         `json:"containers,omitempty"`
}

type SelectedNode added in v0.1.37

type SelectedNode struct {
	Reason  string `json:"reason,omitempty"`    // 选中类型,NodeSelector/NodeAffinity/Tolerations/NodeName
	Name    string `json:"node_name,omitempty"` // 节点名称
	Current bool   `json:"current,omitempty"`   // 是否是当前节点
}

type Statement

type Statement struct {
	*Kubectl            `json:"Kubectl,omitempty"`  // 基础配置
	RowsAffected        int64                       `json:"rowsAffected,omitempty"`        // 返回受影响的行数
	TotalCount          *int64                      `json:"totalCount,omitempty"`          // 返回查询总数,分页使用。只在List查询列表方法中生效。
	AllNamespace        bool                        `json:"allNamespace,omitempty"`        // 所有名空间
	Namespace           string                      `json:"namespace,omitempty"`           // 资源所属命名空间
	NamespaceList       []string                    `json:"namespace_list,omitempty"`      // 多个命名空间,查询列表专用,只有查询列表时会出现跨命名空间查询的情况。在使用时,如果是所有命名空间,就不用NamespaceList
	Name                string                      `json:"name,omitempty"`                // 资源名称
	GVR                 schema.GroupVersionResource `json:"GVR"`                           // 资源类型
	GVK                 schema.GroupVersionKind     `json:"GVK"`                           // 资源类型
	Namespaced          bool                        `json:"namespaced,omitempty"`          // 是否是命名空间资源
	ListOptions         []metav1.ListOptions        `json:"listOptions,omitempty"`         // 列表查询参数,作为可变参数使用,默认只取第一个,也只使用一个
	Context             context.Context             `json:"-"`                             // 上下文
	Dest                interface{}                 `json:"dest,omitempty"`                // 返回结果存放对象,一般为结构体指针
	PatchType           types.PatchType             `json:"patchType,omitempty"`           // PATCH类型
	PatchData           string                      `json:"patchData,omitempty"`           // PATCH数据
	RemoveManagedFields bool                        `json:"removeManagedFields,omitempty"` // 是否移除管理字段

	ContainerName  string                  `json:"containerName,omitempty"` // 容器名称,执行获取容器内日志等操作使用
	Command        string                  `json:"command,omitempty"`       // 容器内执行命令,包括ls、cat以及用户输入的命令
	Args           []string                `json:"args,omitempty"`          // 容器内执行命令参数
	PodLogOptions  *v1.PodLogOptions       `json:"-" `                      // 获取容器日志使用
	Stdin          io.Reader               `json:"-" `                      // 设置输入
	Filter         Filter                  `json:"filter,omitempty"`
	StdoutCallback func(data []byte) error `json:"-"`
	StderrCallback func(data []byte) error `json:"-"`
	CacheTTL       time.Duration           `json:"cacheTTL,omitempty"`    // 设置缓存时间
	ForceDelete    bool                    `json:"forceDelete,omitempty"` // 强制删除标志
	// contains filtered or unexported fields
}

func (*Statement) ParseFromRuntimeObj

func (s *Statement) ParseFromRuntimeObj(obj runtime.Object) *Statement

func (*Statement) ParseGVKFromRuntimeObj

func (s *Statement) ParseGVKFromRuntimeObj(obj runtime.Object) *Statement

func (*Statement) ParseGVKs

func (s *Statement) ParseGVKs(gvks []schema.GroupVersionKind, versions ...string) *Statement

func (*Statement) ParseNsNameFromRuntimeObj

func (s *Statement) ParseNsNameFromRuntimeObj(obj runtime.Object) *Statement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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