k8s

package
v0.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DEFAULT_NAMESPACE_NAME = "default"
)

Variables

This section is empty.

Functions

func NewIntStr

func NewIntStr(v int) *intstr.IntOrString

Types

type Client

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

func NewClient

func NewClient(kubeConfigYaml string) (*Client, error)

func NewClientFromFile

func NewClientFromFile(kubeConfPath string) (*Client, error)

func NewClientFromRestConfig added in v0.0.8

func NewClientFromRestConfig(restConf *rest.Config) (*Client, error)

func (*Client) Admin

func (c *Client) Admin() *admin.Client

集群管理

func (*Client) Config

func (c *Client) Config() *config.Client

应用配置

func (*Client) CurrentCluster

func (c *Client) CurrentCluster() *clientcmdapi.Cluster

func (*Client) CurrentContext

func (c *Client) CurrentContext() *clientcmdapi.Context

func (*Client) DeploymentWatcher added in v0.0.8

func (c *Client) DeploymentWatcher(namespaces ...string) *K8sWatcher[*appsv1.Deployment]

func (*Client) Event

func (c *Client) Event() *event.Client

应用事件

func (*Client) Gateway

func (c *Client) Gateway() *gateway.Client

func (*Client) GetContexts

func (c *Client) GetContexts() map[string]*clientcmdapi.Context

func (*Client) K8sClientSet added in v0.0.2

func (c *Client) K8sClientSet() *kubernetes.Clientset

func (*Client) Network

func (c *Client) Network() *network.Client

应用网络

func (*Client) PodWatcher added in v0.0.8

func (c *Client) PodWatcher(namespaces ...string) *K8sWatcher[*corev1.Pod]

func (*Client) ServerResources

func (c *Client) ServerResources() *meta.ApiResourceList

func (*Client) ServerVersion

func (c *Client) ServerVersion() (string, error)

func (*Client) ServiceWatcher added in v0.0.8

func (c *Client) ServiceWatcher(namespaces ...string) *K8sWatcher[*corev1.Service]

func (*Client) Storage

func (c *Client) Storage() *storage.Client

应用存储

func (*Client) WorkLoad

func (c *Client) WorkLoad() *workload.Client

应用负载

type K8sWatcher added in v0.0.8

type K8sWatcher[T runtime.Object] struct {
	// contains filtered or unexported fields
}

K8sWatcher 泛型Watcher,监听指定类型的资源

func NewK8sWatcher added in v0.0.8

func NewK8sWatcher[T runtime.Object](
	clientset kubernetes.Interface,
	namespaces []string,
	listFunc func(kubernetes.Interface, string, metav1.ListOptions) (runtime.Object, error),
	watchFunc func(kubernetes.Interface, string, metav1.ListOptions) (watch.Interface, error),
) *K8sWatcher[T]

NewK8sWatcher 创建泛型Watcher

func (*K8sWatcher[T]) GetName added in v0.0.8

func (w *K8sWatcher[T]) GetName() string

func (*K8sWatcher[T]) GetNamespaces added in v0.0.8

func (w *K8sWatcher[T]) GetNamespaces() []string

func (*K8sWatcher[T]) IsConfigUpdate added in v0.0.8

func (w *K8sWatcher[T]) IsConfigUpdate(configHash string) bool

func (*K8sWatcher[T]) OnError added in v0.0.8

func (w *K8sWatcher[T]) OnError(fn func(error))

func (*K8sWatcher[T]) RegisterHandler added in v0.0.8

func (w *K8sWatcher[T]) RegisterHandler(handler ResourceHandler[T])

RegisterHandler 注册泛型事件处理器

func (*K8sWatcher[T]) Run added in v0.0.8

func (w *K8sWatcher[T]) Run() error

Run 启动Watcher

func (*K8sWatcher[T]) SetConfigHash added in v0.0.8

func (w *K8sWatcher[T]) SetConfigHash(configHash string) *K8sWatcher[T]

func (*K8sWatcher[T]) SetName added in v0.0.8

func (w *K8sWatcher[T]) SetName(name string) *K8sWatcher[T]

func (*K8sWatcher[T]) Stop added in v0.0.8

func (w *K8sWatcher[T]) Stop()

Stop 停止Watcher

func (*K8sWatcher[T]) WithAnnotations added in v0.0.8

func (w *K8sWatcher[T]) WithAnnotations(key, value string) *K8sWatcher[T]

动态为对象补充集群信息, 方便后续处理

type RESOURCE added in v0.0.8

type RESOURCE string
const (
	RESOURCE_DEPLOYMENT RESOURCE = "deployments"
	RESOURCE_POD        RESOURCE = "pods"
	RESOURCE_SERVICE    RESOURCE = "services"
)

type ResourceHandler added in v0.0.8

type ResourceHandler[T runtime.Object] interface {
	OnAdd(obj T)
	OnUpdate(oldObj, newObj T)
	OnDelete(obj T)
}

ResourceHandler 定义泛型资源事件处理接口

type ResourceHandlerFunc added in v0.0.8

type ResourceHandlerFunc[T runtime.Object] struct {
	OnAddFunc    func(obj T)
	OnUpdateFunc func(oldObj, newObj T)
	OnDeleteFunc func(obj T)
}

ResourceHandlerFunc 是一个函数类型,直接实现 ResourceHandler 接口

func NewResourceHandlerFunc added in v0.0.8

func NewResourceHandlerFunc[T runtime.Object](
	onAddFunc func(obj T),
	onUpdateFunc func(oldObj, newObj T),
	onDeleteFunc func(obj T),
) *ResourceHandlerFunc[T]

func (*ResourceHandlerFunc[T]) OnAdd added in v0.0.8

func (f *ResourceHandlerFunc[T]) OnAdd(obj T)

func (*ResourceHandlerFunc[T]) OnDelete added in v0.0.8

func (f *ResourceHandlerFunc[T]) OnDelete(obj T)

func (*ResourceHandlerFunc[T]) OnUpdate added in v0.0.8

func (f *ResourceHandlerFunc[T]) OnUpdate(oldObj, newObj T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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