util

package
v0.0.0-...-5561049 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	NodeNameEnvVar                  = "POD_NODE_NAME"
	NamespaceNameEnvVar             = "POD_NAMESPACE_NAME"
	InstallationMethodEnvVar        = "INSTALLATION_METHOD"
	ClusterUUIDEnvVar               = "CLUSTER_UUID"
	ExternalEndpointAccessKeyEnvVar = "K8S_EVENTS_ENDPOINT_TOKEN"
	ForceGC                         = "FORCE_GC"
	KubernetesVersionEnvVar         = "KUBERNETES_VERSION"
	KubernetesProviderEnvVar        = "KUBERNETES_PROVIDER"
)
View Source
const (
	POD_PHASE_PENDING = iota + 1
	POD_PHASE_RUNNING
	POD_PHASE_SUCCEEDED
	POD_PHASE_FAILED
	POD_PHASE_UNKNOWN
)
View Source
const (
	CONTAINER_STATE_RUNNING = iota + 1
	CONTAINER_STATE_WAITING
	CONTAINER_STATE_TERMINATED
)
View Source
const (
	PVC_PHASE_PENDING = iota + 1
	PVC_PHASE_BOUND
	PVC_PHASE_LOST
	PVC_PHASE_UNKNOWN
)
View Source
const (
	PV_PHASE_PENDING = iota + 1
	PV_PHASE_AVAILABLE
	PV_PHASE_BOUND
	PV_PHASE_RELEASED
	PV_PHASE_FAILED
	PV_PHASE_UNKNOWN
)

Variables

View Source
var (
	// NeverStop may be passed to make it never stop
	NeverStop <-chan struct{} = make(chan struct{})
)

Functions

func AddK8sTags

func AddK8sTags(tags map[string]string)

func ClusterCollector

func ClusterCollector() bool

func ConditionStatusFloat64

func ConditionStatusFloat64(status kube_api.ConditionStatus) float64

func ConvertPVCPhase

func ConvertPVCPhase(phase kube_api.PersistentVolumeClaimPhase) int64

func ConvertPVPhase

func ConvertPVPhase(phase kube_api.PersistentVolumePhase) int64

func ConvertPodPhase

func ConvertPodPhase(phase kube_api.PodPhase) int64

func GetClusterUUID

func GetClusterUUID() string

func GetExternalEndpointAccessKey

func GetExternalEndpointAccessKey() string

func GetFieldSelector

func GetFieldSelector(resourceType string) fields.Selector

func GetInstallationMethod

func GetInstallationMethod() string

func GetKubernetesProvider

func GetKubernetesProvider() string

func GetKubernetesVersion

func GetKubernetesVersion() string

func GetNamespaceName

func GetNamespaceName() string

func GetNamespaceStore

func GetNamespaceStore(kubeClient kubernetes.Interface) cache.Store

func GetNodeHostnameAndIP

func GetNodeHostnameAndIP(node *kube_api.Node) (string, net.IP, error)

func GetNodeLister

func GetNodeLister(kubeClient kubernetes.Interface) (v1listers.NodeLister, *cache.Reflector, error)

func GetNodeName

func GetNodeName() string

func GetNodeRole

func GetNodeRole(node *kube_api.Node) string

func GetPodLister

func GetPodLister(kubeClient kubernetes.Interface) (v1listers.PodLister, error)

func GetPodStuckInTerminating

func GetPodStuckInTerminating() *v1.Pod

func GetServiceLister

func GetServiceLister(kubeClient kubernetes.Interface) (v1listers.ServiceLister, error)

func HasOwnerReference

func HasOwnerReference(ownerReferences []metav1.OwnerReference) bool

func IsStuckInTerminating

func IsStuckInTerminating(pod *v1.Pod) bool

func JobConditionIsFailed

func JobConditionIsFailed(condition batchv1.JobCondition) bool

func NewDummyMetricsSourceProvider

func NewDummyMetricsSourceProvider(name string, collectionIterval, timeout time.Duration, sources ...metrics.Source) metrics.SourceProvider

func PodConditionIsUnchedulable

func PodConditionIsUnchedulable(condition kube_api.PodCondition) bool

func Retry

func Retry(f func(), duration time.Duration, stopCh <-chan struct{})

TODO: this needs a test! Tricky... Retry makes the function run infinitely after certain time period

func ScrapeAnyNodes

func ScrapeAnyNodes() bool

func ScrapeCluster

func ScrapeCluster() bool

func ScrapeOnlyOwnNode

func ScrapeOnlyOwnNode() bool

func SetAgentType

func SetAgentType(value AgentType)

func SetKubernetesProvider

func SetKubernetesProvider(providerID string)

func SetKubernetesVersion

func SetKubernetesVersion(version string)

Types

type AgentType

type AgentType interface {
	ScrapeCluster() bool
	ScrapeAnyNodes() bool
	ScrapeOnlyOwnNode() bool
	ClusterCollector() bool
}

type ConfigHandler

type ConfigHandler interface {
	Handle(cfg interface{})
}

type ContainerStateInfo

type ContainerStateInfo struct {
	Value    int
	State    string
	Reason   string
	ExitCode int32
}

func NewContainerStateInfo

func NewContainerStateInfo(state kube_api.ContainerState) ContainerStateInfo

func (ContainerStateInfo) AddMetricTags

func (csi ContainerStateInfo) AddMetricTags(tags map[string]string)

func (ContainerStateInfo) IsKnownState

func (csi ContainerStateInfo) IsKnownState() bool

type DummyDataProcessor

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

func NewDummyDataProcessor

func NewDummyDataProcessor(latency time.Duration) *DummyDataProcessor

func (*DummyDataProcessor) Name

func (dummy *DummyDataProcessor) Name() string

func (*DummyDataProcessor) Process

func (dummy *DummyDataProcessor) Process(data *metrics.Batch) (*metrics.Batch, error)

type DummyMetricsSource

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

func NewDummyMetricsSource

func NewDummyMetricsSource(name string, latency time.Duration) *DummyMetricsSource

func NewDummyMetricsSourceWithError

func NewDummyMetricsSourceWithError(name string, latency time.Duration, autoDiscovered bool) *DummyMetricsSource

func (*DummyMetricsSource) AutoDiscovered

func (dummy *DummyMetricsSource) AutoDiscovered() bool

func (*DummyMetricsSource) Cleanup

func (src *DummyMetricsSource) Cleanup()

func (*DummyMetricsSource) Name

func (dummy *DummyMetricsSource) Name() string

func (*DummyMetricsSource) Scrape

func (dummy *DummyMetricsSource) Scrape() (*metrics.Batch, error)

type DummyMetricsSourceProvider

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

func (*DummyMetricsSourceProvider) CollectionInterval

func (dummy *DummyMetricsSourceProvider) CollectionInterval() time.Duration

func (*DummyMetricsSourceProvider) GetMetricsSources

func (dummy *DummyMetricsSourceProvider) GetMetricsSources() []metrics.Source

func (*DummyMetricsSourceProvider) Name

func (dummy *DummyMetricsSourceProvider) Name() string

func (*DummyMetricsSourceProvider) Timeout

func (dummy *DummyMetricsSourceProvider) Timeout() time.Duration

type DummyProviderHandler

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

func NewDummyProviderHandler

func NewDummyProviderHandler(count int) *DummyProviderHandler

func (*DummyProviderHandler) AddProvider

func (d *DummyProviderHandler) AddProvider(provider metrics.SourceProvider)

func (*DummyProviderHandler) DeleteProvider

func (d *DummyProviderHandler) DeleteProvider(name string)

type DummySink

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

func NewDummySink

func NewDummySink(name string, latency time.Duration) *DummySink

func (*DummySink) Export

func (dummy *DummySink) Export(*metrics.Batch)

func (*DummySink) ExportEvent

func (dummy *DummySink) ExportEvent(*events.Event)

func (*DummySink) GetExportCount

func (dummy *DummySink) GetExportCount() int

func (*DummySink) IsStopped

func (dummy *DummySink) IsStopped() bool

func (*DummySink) Name

func (dummy *DummySink) Name() string

func (*DummySink) Stop

func (dummy *DummySink) Stop()

type FileListener

type FileListener interface {
	Changed(file string)
}

type FileWatcher

type FileWatcher interface {
	Watch()
	Stop()
}

func NewFileWatcher

func NewFileWatcher(file string, listener FileListener, initialDelay time.Duration) FileWatcher

type LabelCopier

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

LabelCopier maps kubernetes objects' labels to metrics

func NewLabelCopier

func NewLabelCopier(separator string, storedLabels, ignoredLabels []string) (*LabelCopier, error)

NewLabelCopier creates a new instance of LabelCopier type

func (*LabelCopier) Copy

func (copier *LabelCopier) Copy(in map[string]string, out map[string]string)

Copy copies the given set of pod labels into a set of metric labels, using the following logic: - all labels, unless found in ignoredLabels, are concatenated into a Separator-separated key:value pairs and stored under metrics.LabelLabels.Key - labels found in storedLabels are additionally stored under key provided

type StringInterner

type StringInterner map[string]*string

What is an interner? Is that a thing? Good question, here's a good description https://en.wikipedia.org/wiki/String_interning

func NewStringInterner

func NewStringInterner() StringInterner

func (StringInterner) Intern

func (interner StringInterner) Intern(s string) *string

type WorkloadCache

type WorkloadCache interface {
	GetWorkloadForPodName(podName, ns string) (name, kind, nodeName string)
	GetWorkloadForPod(pod *corev1.Pod) (string, string)
	GetPod(podName, ns string) (pod *corev1.Pod, err error)
}

func GetWorkloadCache

func GetWorkloadCache(kubeClient kubernetes.Interface) (WorkloadCache, error)

func NewWorkloadCache

func NewWorkloadCache(kubeClient kubernetes.Interface) (WorkloadCache, error)

Jump to

Keyboard shortcuts

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