nodesmonitor

package
v0.0.0-...-348f5b6 Latest Latest
Warning

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

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

README

NodesMonitor controller tests example

This example shows how to unit test the relevant behaviors of a sample controller, NodesMonitorController. Its main duty is counting the nodes in the cluster, by honoring the configuration specified by the user in the NodesMonitor custom resource.

Different resources could be used to count different kind of nodes. The user can specify a label filter to select which nodes must be counted, and an alert threshold value. Every time the number of nodes crosses the threshold, a new ThresholdExceeded condition is appended in the related resource. It's also possible to turn on/off the monitoring activity by setting the Active field.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	GroupVersion = schema.GroupVersion{Group: "NodesMonitor", Version: "v1"}

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

	// AddToScheme adds the types in this group-version to the given scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

Functions

This section is empty.

Types

type NodesMonitor

type NodesMonitor struct {
	v1.TypeMeta   `json:",inline"`
	v1.ObjectMeta `json:"metadata,omitempty"`

	Spec   NodesMonitorSpec   `json:"spec,omitempty"`
	Status NodesMonitorStatus `json:"status,omitempty"`
}

func (*NodesMonitor) DeepCopy

func (in *NodesMonitor) DeepCopy() *NodesMonitor

func (*NodesMonitor) DeepCopyInto

func (in *NodesMonitor) DeepCopyInto(out *NodesMonitor)

func (*NodesMonitor) DeepCopyObject

func (in *NodesMonitor) DeepCopyObject() runtime.Object

func (*NodesMonitor) GetObjectKind

func (in *NodesMonitor) GetObjectKind() schema.ObjectKind

type NodesMonitorController

type NodesMonitorController struct {
	client.Client
	Scheme *runtime.Scheme
}

func (NodesMonitorController) Reconcile

type NodesMonitorSpec

type NodesMonitorSpec struct {
	// Active indicates whether the monitor must be enabled or not.
	Active bool `json:"active"`

	// AlertThreshold specifies the threshold for triggering an alert.
	AlertThreshold int `json:"alertThreshold"`

	// NodeLabelFilter selects only nodes with the specified label name
	// (value is ignored).
	NodeLabelFilter string `json:"nodeLabelFilter,omitempty"`
}

type NodesMonitorStatus

type NodesMonitorStatus struct {
	// The current number of nodes found.
	NumNodes int `json:"numNodes"`

	// If the current resource is active or not.
	Active bool `json:"active"`

	// History of the threshold changes.
	Conditions []v1.Condition `json:"conditions,omitempty"`
}

func (*NodesMonitorStatus) AddThresholdExceededCondition

func (nms *NodesMonitorStatus) AddThresholdExceededCondition(thresholdExceeded bool)

func (*NodesMonitorStatus) DeepCopy

func (in *NodesMonitorStatus) DeepCopy() *NodesMonitorStatus

func (*NodesMonitorStatus) GetLatestCondition

func (nms *NodesMonitorStatus) GetLatestCondition() *v1.Condition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳