clustercache

package
v1.114.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetControllerOf added in v1.114.0

func GetControllerOf(pod *Pod) *metav1.OwnerReference

GetControllerOf returns a pointer to a copy of the controllerRef if controllee has a controller

func GetControllerOfNoCopy added in v1.114.0

func GetControllerOfNoCopy(pod *Pod) *metav1.OwnerReference

GetControllerOfNoCopy returns a pointer to the controllerRef if controllee has a controller

Types

type CachingWatchController

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

CachingWatchController composites the watching behavior and a cache to ensure that all up to date resources are readily available

func (*CachingWatchController) GetAll

func (c *CachingWatchController) GetAll() []interface{}

func (*CachingWatchController) Run

func (c *CachingWatchController) Run(threadiness int, stopCh chan struct{})

func (*CachingWatchController) SetRemovedHandler

func (c *CachingWatchController) SetRemovedHandler(handler WatchHandler) WatchController

func (*CachingWatchController) SetUpdateHandler

func (c *CachingWatchController) SetUpdateHandler(handler WatchHandler) WatchController

func (*CachingWatchController) WarmUp

func (c *CachingWatchController) WarmUp(cancelCh chan struct{})

type ClusterCache

type ClusterCache interface {
	// Run starts the watcher processes
	Run()

	// Stops the watcher processes
	Stop()

	// GetAllNamespaces returns all the cached namespaces
	GetAllNamespaces() []*Namespace

	// GetAllNodes returns all the cached nodes
	GetAllNodes() []*Node

	// GetAllPods returns all the cached pods
	GetAllPods() []*Pod

	// GetAllServices returns all the cached services
	GetAllServices() []*Service

	// GetAllDaemonSets returns all the cached DaemonSets
	GetAllDaemonSets() []*DaemonSet

	// GetAllDeployments returns all the cached deployments
	GetAllDeployments() []*Deployment

	// GetAllStatfulSets returns all the cached StatefulSets
	GetAllStatefulSets() []*StatefulSet

	// GetAllReplicaSets returns all the cached ReplicaSets
	GetAllReplicaSets() []*ReplicaSet

	// GetAllPersistentVolumes returns all the cached persistent volumes
	GetAllPersistentVolumes() []*PersistentVolume

	// GetAllPersistentVolumeClaims returns all the cached persistent volume claims
	GetAllPersistentVolumeClaims() []*PersistentVolumeClaim

	// GetAllStorageClasses returns all the cached storage classes
	GetAllStorageClasses() []*StorageClass

	// GetAllJobs returns all the cached jobs
	GetAllJobs() []*Job

	// GetAllPodDisruptionBudgets returns all cached pod disruption budgets
	GetAllPodDisruptionBudgets() []*PodDisruptionBudget

	// GetAllReplicationControllers returns all cached replication controllers
	GetAllReplicationControllers() []*ReplicationController
}

ClusterCache defines an contract for an object which caches components within a cluster, ensuring up to date resources using watchers

func NewClusterImporter

func NewClusterImporter(source *config.ConfigFile) ClusterCache

Creates a new ClusterCache implementation which uses an import process to provide cluster data

func NewKubernetesClusterCache

func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache

func NewKubernetesClusterCacheV1 added in v1.114.0

func NewKubernetesClusterCacheV1(client kubernetes.Interface) ClusterCache

type ClusterExporter

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

ClusterExporter manages and runs an file export process which dumps the local kubernetes cluster to a target location.

func NewClusterExporter

func NewClusterExporter(cluster ClusterCache, target *config.ConfigFile, interval time.Duration) *ClusterExporter

NewClusterExporter creates a new ClusterExporter instance for exporting the kubernetes cluster.

func (*ClusterExporter) Export

func (ce *ClusterExporter) Export() error

Export stores the cluster cache data into a PODO, marshals as JSON, and saves it to the target location.

func (*ClusterExporter) Run

func (ce *ClusterExporter) Run()

Run starts the automated process of running Export on a specific interval.

func (*ClusterExporter) Stop

func (ce *ClusterExporter) Stop()

Stop halts the Cluster export on an interval

type ClusterImporter

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

ClusterImporter is an implementation of ClusterCache which leverages a backing configuration file as it's source of the cluster data.

func (*ClusterImporter) GetAllDaemonSets

func (ci *ClusterImporter) GetAllDaemonSets() []*DaemonSet

GetAllDaemonSets returns all the cached DaemonSets

func (*ClusterImporter) GetAllDeployments

func (ci *ClusterImporter) GetAllDeployments() []*Deployment

GetAllDeployments returns all the cached deployments

func (*ClusterImporter) GetAllJobs

func (ci *ClusterImporter) GetAllJobs() []*Job

GetAllJobs returns all the cached jobs

func (*ClusterImporter) GetAllNamespaces

func (ci *ClusterImporter) GetAllNamespaces() []*Namespace

GetAllNamespaces returns all the cached namespaces

func (*ClusterImporter) GetAllNodes

func (ci *ClusterImporter) GetAllNodes() []*Node

GetAllNodes returns all the cached nodes

func (*ClusterImporter) GetAllPersistentVolumeClaims

func (ci *ClusterImporter) GetAllPersistentVolumeClaims() []*PersistentVolumeClaim

GetAllPersistentVolumeClaims returns all the cached persistent volume claims

func (*ClusterImporter) GetAllPersistentVolumes

func (ci *ClusterImporter) GetAllPersistentVolumes() []*PersistentVolume

GetAllPersistentVolumes returns all the cached persistent volumes

func (*ClusterImporter) GetAllPodDisruptionBudgets

func (ci *ClusterImporter) GetAllPodDisruptionBudgets() []*PodDisruptionBudget

GetAllPodDisruptionBudgets returns all cached pod disruption budgets

func (*ClusterImporter) GetAllPods

func (ci *ClusterImporter) GetAllPods() []*Pod

GetAllPods returns all the cached pods

func (*ClusterImporter) GetAllReplicaSets

func (ci *ClusterImporter) GetAllReplicaSets() []*ReplicaSet

GetAllReplicaSets returns all the cached ReplicaSets

func (*ClusterImporter) GetAllReplicationControllers

func (ci *ClusterImporter) GetAllReplicationControllers() []*ReplicationController

func (*ClusterImporter) GetAllServices

func (ci *ClusterImporter) GetAllServices() []*Service

GetAllServices returns all the cached services

func (*ClusterImporter) GetAllStatefulSets

func (ci *ClusterImporter) GetAllStatefulSets() []*StatefulSet

GetAllStatfulSets returns all the cached StatefulSets

func (*ClusterImporter) GetAllStorageClasses

func (ci *ClusterImporter) GetAllStorageClasses() []*StorageClass

GetAllStorageClasses returns all the cached storage classes

func (*ClusterImporter) Run

func (ci *ClusterImporter) Run()

Run starts the watcher processes

func (*ClusterImporter) Stop

func (ci *ClusterImporter) Stop()

Stops the watcher processes

type Container added in v1.114.0

type Container struct {
	Name      string
	Resources v1.ResourceRequirements
}

type DaemonSet added in v1.114.0

type DaemonSet struct {
	Name           string
	Namespace      string
	Labels         map[string]string
	SpecContainers []v1.Container
}

type Deployment added in v1.114.0

type Deployment struct {
	Name                    string
	Namespace               string
	Labels                  map[string]string
	Annotations             map[string]string
	MatchLabels             map[string]string
	SpecSelector            *metav1.LabelSelector
	SpecReplicas            *int32
	SpecStrategy            appsv1.DeploymentStrategy
	StatusAvailableReplicas int32
	PodSpec                 PodSpec
}

type GenericStore added in v1.114.0

type GenericStore[Input UIDGetter, Output any] struct {
	// contains filtered or unexported fields
}

GenericStore is a generic store implementation. It converts objects to a different type using a transform function. The main purpose is to reduce a memory footprint by storing only the necessary data.

func CreateStore added in v1.114.0

func CreateStore[Input UIDGetter, Output any](
	restClient rest.Interface,
	resource string,
	transformFunc func(input Input) Output,
) *GenericStore[Input, Output]

func NewGenericStore added in v1.114.0

func NewGenericStore[Input UIDGetter, Output any](transformFunc func(input Input) Output) *GenericStore[Input, Output]

NewGenericStore creates a new instance of GenericStore.

func (*GenericStore[Input, Output]) Add added in v1.114.0

func (s *GenericStore[Input, Output]) Add(obj any) error

Add inserts an object into the store.

func (*GenericStore[Input, Output]) Delete added in v1.114.0

func (s *GenericStore[Input, Output]) Delete(obj any) error

Delete removes an object from the store.

func (*GenericStore[Input, Output]) Get added in v1.114.0

func (s *GenericStore[Input, Output]) Get(_ interface{}) (item interface{}, exists bool, err error)

func (*GenericStore[Input, Output]) GetAll added in v1.114.0

func (s *GenericStore[Input, Output]) GetAll() []Output

GetAll returns all stored objects.

func (*GenericStore[Input, Output]) GetByKey added in v1.114.0

func (s *GenericStore[Input, Output]) GetByKey(_ string) (item interface{}, exists bool, err error)

func (*GenericStore[Input, Output]) List added in v1.114.0

func (s *GenericStore[Input, Output]) List() []interface{}

Stubs to satisfy the cache.Store interface

func (*GenericStore[Input, Output]) ListKeys added in v1.114.0

func (s *GenericStore[Input, Output]) ListKeys() []string

func (*GenericStore[Input, Output]) Replace added in v1.114.0

func (s *GenericStore[Input, Output]) Replace(list []any, _ string) error

Replace replaces the current list of items in the store.

func (*GenericStore[Input, Output]) Resync added in v1.114.0

func (s *GenericStore[Input, Output]) Resync() error

func (*GenericStore[Input, Output]) Update added in v1.114.0

func (s *GenericStore[Input, Output]) Update(obj any) error

Update updates the existing entry in the store.

func (*GenericStore[Input, Output]) Watch added in v1.114.0

func (s *GenericStore[Input, Output]) Watch(stopCh <-chan struct{}, onInit func())

type Job added in v1.114.0

type Job struct {
	Name      string
	Namespace string
	Status    batchv1.JobStatus
}

type KubernetesClusterCache

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

KubernetesClusterCache is the implementation of ClusterCache

func (*KubernetesClusterCache) GetAllDaemonSets

func (kcc *KubernetesClusterCache) GetAllDaemonSets() []*DaemonSet

func (*KubernetesClusterCache) GetAllDeployments

func (kcc *KubernetesClusterCache) GetAllDeployments() []*Deployment

func (*KubernetesClusterCache) GetAllJobs

func (kcc *KubernetesClusterCache) GetAllJobs() []*Job

func (*KubernetesClusterCache) GetAllNamespaces

func (kcc *KubernetesClusterCache) GetAllNamespaces() []*Namespace

func (*KubernetesClusterCache) GetAllNodes

func (kcc *KubernetesClusterCache) GetAllNodes() []*Node

func (*KubernetesClusterCache) GetAllPersistentVolumeClaims

func (kcc *KubernetesClusterCache) GetAllPersistentVolumeClaims() []*PersistentVolumeClaim

func (*KubernetesClusterCache) GetAllPersistentVolumes

func (kcc *KubernetesClusterCache) GetAllPersistentVolumes() []*PersistentVolume

func (*KubernetesClusterCache) GetAllPodDisruptionBudgets

func (kcc *KubernetesClusterCache) GetAllPodDisruptionBudgets() []*PodDisruptionBudget

func (*KubernetesClusterCache) GetAllPods

func (kcc *KubernetesClusterCache) GetAllPods() []*Pod

func (*KubernetesClusterCache) GetAllReplicaSets

func (kcc *KubernetesClusterCache) GetAllReplicaSets() []*ReplicaSet

func (*KubernetesClusterCache) GetAllReplicationControllers

func (kcc *KubernetesClusterCache) GetAllReplicationControllers() []*ReplicationController

func (*KubernetesClusterCache) GetAllServices

func (kcc *KubernetesClusterCache) GetAllServices() []*Service

func (*KubernetesClusterCache) GetAllStatefulSets

func (kcc *KubernetesClusterCache) GetAllStatefulSets() []*StatefulSet

func (*KubernetesClusterCache) GetAllStorageClasses

func (kcc *KubernetesClusterCache) GetAllStorageClasses() []*StorageClass

func (*KubernetesClusterCache) Run

func (kcc *KubernetesClusterCache) Run()

func (*KubernetesClusterCache) Stop

func (kcc *KubernetesClusterCache) Stop()

type KubernetesClusterCacheV2 added in v1.114.0

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

func NewKubernetesClusterCacheV2 added in v1.114.0

func NewKubernetesClusterCacheV2(clientset kubernetes.Interface) *KubernetesClusterCacheV2

func (*KubernetesClusterCacheV2) GetAllDaemonSets added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllDaemonSets() []*DaemonSet

func (*KubernetesClusterCacheV2) GetAllDeployments added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllDeployments() []*Deployment

func (*KubernetesClusterCacheV2) GetAllJobs added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllJobs() []*Job

func (*KubernetesClusterCacheV2) GetAllNamespaces added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllNamespaces() []*Namespace

func (*KubernetesClusterCacheV2) GetAllNodes added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllNodes() []*Node

func (*KubernetesClusterCacheV2) GetAllPersistentVolumeClaims added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllPersistentVolumeClaims() []*PersistentVolumeClaim

func (*KubernetesClusterCacheV2) GetAllPersistentVolumes added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllPersistentVolumes() []*PersistentVolume

func (*KubernetesClusterCacheV2) GetAllPodDisruptionBudgets added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllPodDisruptionBudgets() []*PodDisruptionBudget

func (*KubernetesClusterCacheV2) GetAllPods added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllPods() []*Pod

func (*KubernetesClusterCacheV2) GetAllReplicaSets added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllReplicaSets() []*ReplicaSet

func (*KubernetesClusterCacheV2) GetAllReplicationControllers added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllReplicationControllers() []*ReplicationController

func (*KubernetesClusterCacheV2) GetAllServices added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllServices() []*Service

func (*KubernetesClusterCacheV2) GetAllStatefulSets added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllStatefulSets() []*StatefulSet

func (*KubernetesClusterCacheV2) GetAllStorageClasses added in v1.114.0

func (kcc *KubernetesClusterCacheV2) GetAllStorageClasses() []*StorageClass

func (*KubernetesClusterCacheV2) Run added in v1.114.0

func (kcc *KubernetesClusterCacheV2) Run()

func (*KubernetesClusterCacheV2) Stop added in v1.114.0

func (kcc *KubernetesClusterCacheV2) Stop()

type Namespace added in v1.114.0

type Namespace struct {
	Name        string
	Labels      map[string]string
	Annotations map[string]string
}

type Node added in v1.114.0

type Node struct {
	Name           string
	Labels         map[string]string
	Annotations    map[string]string
	Status         v1.NodeStatus
	SpecProviderID string
}

type PersistentVolume added in v1.114.0

type PersistentVolume struct {
	Name        string
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
	Spec        v1.PersistentVolumeSpec
	Status      v1.PersistentVolumeStatus
}

type PersistentVolumeClaim added in v1.114.0

type PersistentVolumeClaim struct {
	Name        string
	Namespace   string
	Spec        v1.PersistentVolumeClaimSpec
	Labels      map[string]string
	Annotations map[string]string
}

type Pod added in v1.114.0

type Pod struct {
	UID               types.UID
	Name              string
	Namespace         string
	Labels            map[string]string
	Annotations       map[string]string
	OwnerReferences   []metav1.OwnerReference
	Status            PodStatus
	Spec              PodSpec
	DeletionTimestamp *time.Time
}

type PodDisruptionBudget added in v1.114.0

type PodDisruptionBudget struct {
	Name      string
	Namespace string
	Spec      policyv1.PodDisruptionBudgetSpec
	Status    policyv1.PodDisruptionBudgetStatus
}

type PodSpec added in v1.114.0

type PodSpec struct {
	NodeName      string
	Containers    []Container
	Volumes       []v1.Volume
	RestartPolicy v1.RestartPolicy
}

type PodStatus added in v1.114.0

type PodStatus struct {
	Phase             v1.PodPhase
	ContainerStatuses []v1.ContainerStatus
}

type ReplicaSet added in v1.114.0

type ReplicaSet struct {
	Name         string
	Namespace    string
	SpecSelector *metav1.LabelSelector
	Spec         appsv1.ReplicaSetSpec
}

type ReplicationController added in v1.114.0

type ReplicationController struct {
	Name      string
	Namespace string
	Spec      v1.ReplicationControllerSpec
}

type Service added in v1.114.0

type Service struct {
	Name         string
	Namespace    string
	SpecSelector map[string]string
	Type         v1.ServiceType
	Status       v1.ServiceStatus
}

type StatefulSet added in v1.114.0

type StatefulSet struct {
	Name         string
	Namespace    string
	Labels       map[string]string
	Annotations  map[string]string
	SpecSelector *metav1.LabelSelector
	SpecReplicas *int32
	PodSpec      PodSpec
}

type StorageClass added in v1.114.0

type StorageClass struct {
	Name        string
	Labels      map[string]string
	Annotations map[string]string
	Parameters  map[string]string
	Provisioner string
	TypeMeta    metav1.TypeMeta
	Size        int
}

type UIDGetter added in v1.114.0

type UIDGetter interface {
	GetUID() types.UID
}

type Volume added in v1.114.0

type Volume struct {
}

type WatchController

type WatchController interface {
	// Initializes the cache
	WarmUp(chan struct{})

	// Run starts the watching process
	Run(int, chan struct{})

	// GetAll returns all of the resources
	GetAll() []interface{}

	// SetUpdateHandler sets a specific handler for adding/updating individual resources
	SetUpdateHandler(WatchHandler) WatchController

	// SetRemovedHandler sets a specific handler for removing individual resources
	SetRemovedHandler(WatchHandler) WatchController
}

WatchController defines a contract for an object which watches a specific resource set for add, updates, and removals

func NewCachingWatcher

func NewCachingWatcher(restClient rest.Interface, resource string, resourceType rt.Object, namespace string, fieldSelector fields.Selector) WatchController

type WatchHandler

type WatchHandler = func(interface{})

Type alias for a receiver func

Jump to

Keyboard shortcuts

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