Documentation ¶
Index ¶
- Constants
- func AddCustomListeners(informer cache.SharedIndexInformer, runtimeCache *Cache)
- func HasCRD(targetGVR schema.GroupVersionResource, CRDs *ResourceList) bool
- func ToUnstructured(obj interface{}) (*unstructured.Unstructured, error)
- type Cache
- type Handler
- type PodMetrics
- func (pm *PodMetrics) Delete(podUID string)
- func (pm *PodMetrics) Get(podUID string) *unstructured.Unstructured
- func (pm *PodMetrics) GetAll(namespace string, _ string) []unstructured.Unstructured
- func (pm *PodMetrics) GetCount() int
- func (pm *PodMetrics) GetHistoricalUsage() []Usage
- func (pm *PodMetrics) GetUsage() (cpu float64, mem float64)
- func (pm *PodMetrics) Update(podUID string, metrics *unstructured.Unstructured)
- type ResourceList
- func (r *ResourceList) CRDExistsInCluster() bool
- func (r *ResourceList) GetResource(uid string) (unstructured.Unstructured, bool)
- func (r *ResourceList) GetResources(namespace string, namePartial string) []unstructured.Unstructured
- func (r *ResourceList) GetSparseResources(namespace string, namePartial string) []unstructured.Unstructured
- type Usage
Constants ¶
const ( Added = "ADDED" Modified = "MODIFIED" Deleted = "DELETED" )
const MAX_HISTORY_LENGTH = 200
Variables ¶
This section is empty.
Functions ¶
func AddCustomListeners ¶
func AddCustomListeners(informer cache.SharedIndexInformer, runtimeCache *Cache)
AddCustomListeners adds additional listeners to a shared informer for updating Custom Resource informers
func HasCRD ¶
func HasCRD(targetGVR schema.GroupVersionResource, CRDs *ResourceList) bool
func ToUnstructured ¶
func ToUnstructured(obj interface{}) (*unstructured.Unstructured, error)
ToUnstructured converts an object to an Unstructured
Types ¶
type Cache ¶
type Cache struct { // Core resources Events *ResourceList Namespaces *ResourceList Nodes *ResourceList // Workload resources Pods *ResourceList Deployments *ResourceList Daemonsets *ResourceList Statefulsets *ResourceList Jobs *ResourceList CronJobs *ResourceList // UDS resources UDSPackages *ResourceList UDSExemptions *ResourceList // Config resources Configmaps *ResourceList Secrets *ResourceList // Cluster ops resources MutatingWebhooks *ResourceList ValidatingWebhooks *ResourceList HPAs *ResourceList PriorityClasses *ResourceList RuntimeClasses *ResourceList PodDisruptionBudgets *ResourceList LimitRanges *ResourceList ResourceQuotas *ResourceList // Network resources Services *ResourceList NetworkPolicies *ResourceList Endpoints *ResourceList VirtualServices *ResourceList // Storage resources PersistentVolumes *ResourceList PersistentVolumeClaims *ResourceList StorageClasses *ResourceList // Metrics PodMetrics *PodMetrics MetricsChanges chan struct{} // CustomResourceDefinitions CRDs *ResourceList // Gateways Gateways *ResourceList // contains filtered or unexported fields }
func (*Cache) CalculateUsage ¶
func (c *Cache) CalculateUsage(metrics *v1beta1.PodMetrics) (float64, float64)
Update the CalculateUsage function
func (*Cache) StartMetricsCollection ¶
func (c *Cache) StartMetricsCollection(ctx context.Context, metricsClient metricsv1beta1.MetricsV1beta1Interface)
StartMetricsCollection starts a goroutine to collect metrics for all pods in the cache
type Handler ¶
type Handler cache.ResourceEventHandlerFuncs
type PodMetrics ¶
func NewPodMetrics ¶
func NewPodMetrics() *PodMetrics
func (*PodMetrics) Delete ¶
func (pm *PodMetrics) Delete(podUID string)
Delete removes the metrics for a pod from the cache
func (*PodMetrics) Get ¶
func (pm *PodMetrics) Get(podUID string) *unstructured.Unstructured
Get returns the metrics for a pod in the cache
func (*PodMetrics) GetAll ¶
func (pm *PodMetrics) GetAll(namespace string, _ string) []unstructured.Unstructured
GetAll returns all metrics in the cache with optional filtering by namespace, second argument is ignored
func (*PodMetrics) GetCount ¶
func (pm *PodMetrics) GetCount() int
GetCount returns the number of metrics in the cache
func (*PodMetrics) GetHistoricalUsage ¶
func (pm *PodMetrics) GetHistoricalUsage() []Usage
GetHistoricalUsage returns the historical usage data
func (*PodMetrics) GetUsage ¶
func (pm *PodMetrics) GetUsage() (cpu float64, mem float64)
GetUsage returns the current CPU and memory usage
func (*PodMetrics) Update ¶
func (pm *PodMetrics) Update(podUID string, metrics *unstructured.Unstructured)
Update updates the metrics for a pod in the cache
type ResourceList ¶
type ResourceList struct { Resources map[string]*unstructured.Unstructured SparseResources map[string]*unstructured.Unstructured HasSynced cache.InformerSynced Changes chan struct{} GVR schema.GroupVersionResource CRDExists bool // contains filtered or unexported fields }
ResourceList is a thread-safe struct to store the list of resources and notify subscribers of changes.
func NewDynamicResourceList ¶
func NewDynamicResourceList(informer cache.SharedIndexInformer, gvk schema.GroupVersionKind, gvr schema.GroupVersionResource) *ResourceList
NewDynamicResourceList initializes a ResourceList with a gvr.
func NewResourceList ¶
func NewResourceList(informer cache.SharedIndexInformer, gvk schema.GroupVersionKind) *ResourceList
NewResourceList initializes a ResourceList and sets up event handlers for resource changes.
func (*ResourceList) CRDExistsInCluster ¶
func (r *ResourceList) CRDExistsInCluster() bool
CRDExistsInCluster returns the value of the MissingCRD field for the ResourceList.
func (*ResourceList) GetResource ¶
func (r *ResourceList) GetResource(uid string) (unstructured.Unstructured, bool)
GetResource returns a resource by UID.
func (*ResourceList) GetResources ¶
func (r *ResourceList) GetResources(namespace string, namePartial string) []unstructured.Unstructured
GetResources returns a slice of the current resources.
func (*ResourceList) GetSparseResources ¶
func (r *ResourceList) GetSparseResources(namespace string, namePartial string) []unstructured.Unstructured
GetSparseResources returns a slice of the current resources with only metadata and status fields.