k8s

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBuildConfigFunc

func DefaultBuildConfigFunc() (*rest.Config, error)

Default functions to be used when not testing.

func DefaultNewClientsetFunc

func DefaultNewClientsetFunc(config *rest.Config) (kubernetes.Interface, error)

func GetKubernetesClient

func GetKubernetesClient(
	buildConfigFunc func() (*rest.Config, error),
	newClientsetFunc func(*rest.Config) (kubernetes.Interface, error),
) (*rest.Config, kubernetes.Interface, error)

GetKubernetesClient creates a Kubernetes clientset using in-cluster or kubeconfig setup.

Types

type PodScrapeDetails

type PodScrapeDetails struct {
	Port      string
	Path      string
	PodName   string
	Namespace string
}

PodScrapeDetails stores the metrics endpoint details and metadata for a pod.

type PodScrapeWatcher

type PodScrapeWatcher struct {
	PodMetricsEndpoints map[string]PodScrapeDetails

	// Function variables for update and delete operations, to allow mocking during tests.
	UpdatePodMetricsFunc func(*corev1.Pod)
	DeletePodMetricsFunc func(*corev1.Pod)
	// contains filtered or unexported fields
}

PodScrapeWatcher manages pod metrics and provides methods to handle updates and deletions.

func NewPodScrapeWatcher

func NewPodScrapeWatcher() *PodScrapeWatcher

NewPodScrapeWatcher initializes a new PodScrapeWatcher with default function implementations.

func (*PodScrapeWatcher) DeletePodMetrics

func (pw *PodScrapeWatcher) DeletePodMetrics(pod *corev1.Pod)

DeletePodMetrics removes the pod metrics entry when a pod is deleted.

func (*PodScrapeWatcher) GetPodMetricsEndpoints

func (pw *PodScrapeWatcher) GetPodMetricsEndpoints() map[string]PodScrapeDetails

GetPodMetricsEndpoints returns a copy of the current pod metrics endpoints.

func (*PodScrapeWatcher) UpdatePodMetrics

func (pw *PodScrapeWatcher) UpdatePodMetrics(pod *corev1.Pod)

UpdatePodMetrics updates or adds pod metrics based on the pod annotations.

func (*PodScrapeWatcher) WatchPods

func (pw *PodScrapeWatcher) WatchPods(clientset kubernetes.Interface, namespace string, labels map[string]string)

WatchPods starts the SharedInformer to monitor pod events and updates the metrics endpoints accordingly.

Jump to

Keyboard shortcuts

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