kube

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Overview

ResourceHandler responsible for doing common operations on kubernetes resources. like

UPDATE DELETE CREATE GetLogs deployment(or other resources) and so on. 具体可以handle哪些k8s资源,请查看本包内的api/types.go文件, 后续可追加.

It's using cache, can reduce the request stress of k8s apiServer.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist    = errors.New("cluster not exist. ")
	ErrMaintaining = errors.New("cluster being maintaining .please try again later. ")
)
View Source
var ClusterManager *clusterManager

Functions

func InitClusterManager

func InitClusterManager()

func ResourceNotFound

func ResourceNotFound(err error) bool

func SetDefaultNamespaceIfScopedAndNoneSet

func SetDefaultNamespaceIfScopedAndNoneSet(u *unstructured.Unstructured, helper *resource.Helper)

func SetNamespaceIfScoped

func SetNamespaceIfScoped(namespace string, u *unstructured.Unstructured, helper *resource.Helper)

Types

type CacheFactory

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

func (*CacheFactory) DeploymentLister

func (c *CacheFactory) DeploymentLister() appsv1.DeploymentLister

func (*CacheFactory) PodLister

func (c *CacheFactory) PodLister() corev1.PodLister

type ClusterClient

type ClusterClient struct {
	Cluster    *db.Cluster
	Config     *rest.Config
	KubeClient ResourceHandler
}

type Metadata

type Metadata struct {
	Name      string
	Namespace string
	Group     string
	Version   string
	Resource  string
	Kind      string
}

type ResourceHandler

type ResourceHandler interface {
	Create(kind string, namespace string, object *runtime.Unknown) (*runtime.Unknown, error)
	Update(kind string, namespace string, name string, object *runtime.Unknown) (*runtime.Unknown, error)
	Get(kind string, namespace string, name string) (runtime.Object, error)
	List(kind string, namespace string, labelSelector string) ([]runtime.Object, error)
	Delete(kind string, namespace string, name string, options *metav1.DeleteOptions) error
	Apply(kind string, obj runtime.Object) error
	GetClientVersioned() *versioned.Clientset
}

func NewResourceHandler

func NewResourceHandler(kubeClient *kubernetes.Clientset, versionedClient *versioned.Clientset, cacheFactory *CacheFactory) ResourceHandler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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