Documentation
¶
Overview ¶
+kubebuilder:object:generate=true +groupName=usage.open-control-plane.io
Index ¶
- Constants
- Variables
- func RegisterToSchemeBuilder(types ...runtime.Object)
- type DailyUsageReport
- type GarbageCollectionConfig
- type NamespaceSelector
- type ResourceReference
- type ResourceToTrack
- type ResourceUsage
- type ResourceUsageList
- type ResourceUsageSpec
- type ResourceUsageStatus
- type Selector
- type Timespan
- type Timespans
- type TrackUntilMode
- type Trait
- type TraitUsage
- type TraitUsages
- type UsageServiceConfig
- type UsageServiceConfigList
- type UsageServiceConfigSpec
Constants ¶
const ( UsagePhaseOngoing = "Ongoing" UsagePhaseCompleted = "Completed" )
const (
DefaultGarbageCollectionInterval = 24 * time.Hour
)
const GroupName = "usage.open-control-plane.io"
Variables ¶
var ( // GroupVersion is group version used to register these objects. GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = runtime.NewSchemeBuilder(func(scheme *runtime.Scheme) error { metav1.AddToGroupVersion(scheme, GroupVersion) return nil }) // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme )
Functions ¶
func RegisterToSchemeBuilder ¶
Types ¶
type DailyUsageReport ¶
type DailyUsageReport struct {
Date metav1.Time `json:"date"`
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
func (*DailyUsageReport) DeepCopy ¶
func (in *DailyUsageReport) DeepCopy() *DailyUsageReport
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DailyUsageReport.
func (*DailyUsageReport) DeepCopyInto ¶
func (in *DailyUsageReport) DeepCopyInto(out *DailyUsageReport)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type GarbageCollectionConfig ¶
type GarbageCollectionConfig struct {
// KeepDuration specifies how long a ResourceUsage record should be kept after its tracking period has ended.
// If not specified, no completed ResourceUsage records will be deleted based on their age.
// +optional
KeepDuration *metav1.Duration `json:"keepDuration,omitempty"`
// KeepCount specifies how many completed ResourceUsage records (per resource) should be kept, regardless of their age.
// If 0, no completed ResourceUsage records will be deleted based on their count.
// +optional
KeepCount int `json:"keepCount,omitempty"`
// AndConditions specifies whether a completed ResourceUsage record should be deleted only if both the KeepDuration and KeepCount conditions are met (true), or if either of them is met (false).
// If not specified, the default is false (delete if either condition is met).
// Has no effect if only one of the conditions is specified.
// +optional
AndConditions bool `json:"andConditions,omitempty"`
// Interval specifies the interval at which the garbage collector runs.
// Defaults to 24 hours if not specified.
// +kubebuilder:default="24h"
// +optional
Interval *metav1.Duration `json:"interval,omitempty"`
}
func (*GarbageCollectionConfig) DeepCopy ¶
func (in *GarbageCollectionConfig) DeepCopy() *GarbageCollectionConfig
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GarbageCollectionConfig.
func (*GarbageCollectionConfig) DeepCopyInto ¶
func (in *GarbageCollectionConfig) DeepCopyInto(out *GarbageCollectionConfig)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*GarbageCollectionConfig) GetInterval ¶
func (gcc *GarbageCollectionConfig) GetInterval() time.Duration
type NamespaceSelector ¶
type NamespaceSelector struct {
// Names is a list of namespace names to select. Only resources in these namespaces will be tracked.
// If this is specified, the LabelSelector in Selector will be ignored.
// Note that there is a difference between a null and an empty list: a null value means that all namespaces are selected, while an empty list means that no namespaces are selected.
// +nullable
// +optional
Names []string `json:"names,omitempty"`
// Selector is a label selector for the namespace. Only resources in namespaces matching this selector will be tracked.
// Will be ignored if specified together with Names.
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`
}
func (*NamespaceSelector) DeepCopy ¶
func (in *NamespaceSelector) DeepCopy() *NamespaceSelector
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceSelector.
func (*NamespaceSelector) DeepCopyInto ¶
func (in *NamespaceSelector) DeepCopyInto(out *NamespaceSelector)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResourceReference ¶
type ResourceReference struct {
metav1.GroupVersionKind `json:",inline"`
commonapi.ObjectReference `json:",inline"`
}
func (*ResourceReference) DeepCopy ¶
func (in *ResourceReference) DeepCopy() *ResourceReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceReference.
func (*ResourceReference) DeepCopyInto ¶
func (in *ResourceReference) DeepCopyInto(out *ResourceReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResourceToTrack ¶
type ResourceToTrack struct {
metav1.GroupVersionKind `json:",inline"`
// Selector allows to filter the tracked resources.
// +optional
Selector *Selector `json:"selector,omitempty"`
// ResourceUsagePeriod specifies the duration which should be tracked in a single ResourceUsage record for this resource type.
// If the duration is exceeded, a new ResourceUsage record will be created for the resource.
// Defaults to 30 days if not specified.
// +kubebuilder:default="720h"
// +optional
ResourceUsagePeriod *metav1.Duration `json:"resourceUsagePeriod,omitempty"`
// TrackUntil specifies when usage tracking is stopped.
// This can either happen when the resource gets a deletion timestamp, or when it is actually removed.
// Valid values are 'Deletion' and 'DeletionTimestamp', defaulting to the former one if not specified.
// +kubebuilder:validation:Enum=Deletion;DeletionTimestamp
// +optional
TrackUntil TrackUntilMode `json:"trackUntil,omitempty"`
// Traits specifies traits which should be tracked for the resource.
// Each trait has an identifier (the key) and specifies the path to the field within the resource's manifest which should be tracked.
// A trait's path can either refer to the resource itself (path starts with 'resource.') or to its namespace (if it is namespaced, path starts with 'namespace.').
// Tracking a trait causes the trait's value to be stored the ResourceUsage record for the resource.
// If the trait changes, all of its values and the time of the change will be stored in the ResourceUsage record.
// Note that this can make the ResourceUsage record grow large, so it should only be used for fields which change rarely.
// +optional
Traits map[string]Trait `json:"traits,omitempty"`
}
func (*ResourceToTrack) DeepCopy ¶
func (in *ResourceToTrack) DeepCopy() *ResourceToTrack
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceToTrack.
func (*ResourceToTrack) DeepCopyInto ¶
func (in *ResourceToTrack) DeepCopyInto(out *ResourceToTrack)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*ResourceToTrack) Default ¶
func (rtt *ResourceToTrack) Default() *ResourceToTrack
Default sets default values in the receiver object and returns it for chaining.
type ResourceUsage ¶
type ResourceUsage struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ResourceUsageSpec `json:"spec,omitempty"`
Status ResourceUsageStatus `json:"status,omitempty"`
}
+kubebuilder:object:root=true +kubebuilder:resource:scope=Cluster,shortName=usage;ru +kubebuilder:metadata:labels="openmcp.cloud/cluster=onboarding" +kubebuilder:subresource:status +kubebuilder:printcolumn:name="kind",type=string,JSONPath=`.spec.resource.kind` +kubebuilder:printcolumn:name="version",type=string,JSONPath=`.spec.resource.version`,priority=10 +kubebuilder:printcolumn:name="group",type=string,JSONPath=`.spec.resource.group`,priority=10 +kubebuilder:printcolumn:name="name",type=string,JSONPath=`.spec.resource.name` +kubebuilder:printcolumn:name="namespace",type=string,JSONPath=`.spec.resource.namespace` +kubebuilder:printcolumn:name="start",type=date,JSONPath=`.spec.trackingPeriod.start` +kubebuilder:printcolumn:name="end",type=date,JSONPath=`.spec.trackingPeriod.end` +kubebuilder:printcolumn:name="phase",type=string,JSONPath=`.status.phase` +kubebuilder:selectablefield:JSONPath=".spec.resource.kind" +kubebuilder:selectablefield:JSONPath=".spec.resource.version" +kubebuilder:selectablefield:JSONPath=".spec.resource.group" +kubebuilder:selectablefield:JSONPath=".spec.resource.name" +kubebuilder:selectablefield:JSONPath=".spec.resource.namespace" +kubebuilder:selectablefield:JSONPath=".status.phase"
func (*ResourceUsage) DeepCopy ¶
func (in *ResourceUsage) DeepCopy() *ResourceUsage
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceUsage.
func (*ResourceUsage) DeepCopyInto ¶
func (in *ResourceUsage) DeepCopyInto(out *ResourceUsage)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*ResourceUsage) DeepCopyObject ¶
func (in *ResourceUsage) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type ResourceUsageList ¶
type ResourceUsageList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ResourceUsage `json:"items"`
}
+kubebuilder:object:root=true
func (*ResourceUsageList) DeepCopy ¶
func (in *ResourceUsageList) DeepCopy() *ResourceUsageList
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceUsageList.
func (*ResourceUsageList) DeepCopyInto ¶
func (in *ResourceUsageList) DeepCopyInto(out *ResourceUsageList)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*ResourceUsageList) DeepCopyObject ¶
func (in *ResourceUsageList) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type ResourceUsageSpec ¶
type ResourceUsageSpec struct {
// Resource specifies the resource for which usage is being tracked.
Resource ResourceReference `json:"resource"`
// TrackingPeriod specifies the time frame for which this usage record is tracking usage.
// The start time is inclusive, while the end time is exclusive.
// The duration should be a multiple of 24 hours.
// +optional
TrackingPeriod Timespan `json:"trackingPeriod"`
// Usage is a list of time periods for which the referenced resource was actually tracked.
// In most cases, this will just be a single entry spanning the whole TrackingPeriod, but if the resource
// is deleted (and potentially recreated) or modified to (not) match a selector during the tracking period, there may be multiple entries.
// This can be expected to be sorted so that the latest - possibly ongoing - tracking period is first.
// +optional
Usage Timespans `json:"usage,omitempty"`
// Traits maps each trait identifier to all values the trait's field has had during the tracking period, along with the duration for which each value was present.
// +optional
Traits map[string]TraitUsages `json:"traits,omitempty"`
}
func (*ResourceUsageSpec) DeepCopy ¶
func (in *ResourceUsageSpec) DeepCopy() *ResourceUsageSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceUsageSpec.
func (*ResourceUsageSpec) DeepCopyInto ¶
func (in *ResourceUsageSpec) DeepCopyInto(out *ResourceUsageSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResourceUsageStatus ¶
type ResourceUsageStatus struct {
// Phase specifies whether this usage record is still being tracked or if it has been completed.
// Must be either 'Ongoing' or 'Completed'.
// +kubebuilder:validation:Enum=Ongoing;Completed
Phase string `json:"phase,omitempty"`
// TotalTrackedDuration specifies the total duration for which the resource was actually tracked during the tracking period.
// This is the sum of the durations of all entries in Usage.
// +optional
TotalTrackedDuration *metav1.Duration `json:"totalTrackedDuration,omitempty"`
}
func (*ResourceUsageStatus) DeepCopy ¶
func (in *ResourceUsageStatus) DeepCopy() *ResourceUsageStatus
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceUsageStatus.
func (*ResourceUsageStatus) DeepCopyInto ¶
func (in *ResourceUsageStatus) DeepCopyInto(out *ResourceUsageStatus)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Selector ¶
type Selector struct {
// ResourceSelector is a label selector for the resource itself. Only resources matching this selector will be tracked.
// +optional
ResourceSelector *metav1.LabelSelector `json:"resource,omitempty"`
// NamespaceSelector allows to restrict the tracked resources to certain namespaces.
// Namespaces can be selected by their labels, or by their names. Only the names are evaluated if both are specified.
// DO NOT specify this in case of cluster-scoped resources, as it will cause errors when trying to fetch the namespace of the resource.
// +optional
NamespaceSelector *NamespaceSelector `json:"namespace,omitempty"`
}
func (*Selector) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Selector.
func (*Selector) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Timespan ¶
type Timespan struct {
// Start specifies the beginning of the time period.
Start *metav1.Time `json:"start,omitempty"`
// End specifies the end of the time period.
End *metav1.Time `json:"end,omitempty"`
}
func (*Timespan) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Timespan.
func (*Timespan) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Timespans ¶
type Timespans []Timespan
func (Timespans) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Timespans.
func (Timespans) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (Timespans) TotalDuration ¶
TotalDuration computes the total duration of all timespans in the slice, ignoring any timespans with a zero start or end time. The duration is truncated to the nearest minute, any seconds or smaller units are discarded.
type TrackUntilMode ¶
type TrackUntilMode string
const ( // TrackUntilDeletion means that usage tracking is stopped when the resource is deleted. TrackUntilDeletion TrackUntilMode = "Deletion" // TrackUntilDeletionTimestamp means that usage tracking is stopped when the resource gets a deletion timestamp. TrackUntilDeletionTimestamp TrackUntilMode = "DeletionTimestamp" )
type Trait ¶
type Trait struct {
// Path is the path to the trait's field within the resource's manifest.
// It must follow the JSONPath syntax, e.g. "resource.status.ready" or "resource.metadata.labels['foo']",
// see http://goessner.net/articles/JsonPath/ for more information.
// Note that the path will automatically be wrapped in curly braces, so it should not include them.
// +kubebuilder:validation:MinLength=1
Path string `json:"path"`
}
func (*Trait) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Trait.
func (*Trait) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type TraitUsage ¶
type TraitUsage struct {
// Value is the value of the trait at the time of usage.
// +nullable
Value apiextensionsv1.JSON `json:"value"`
// Usage specifies the time periods for which the trait had this value.
// This can be expected to be sorted so that the latest - possibly ongoing - tracking period is first.
// +optional
Usage Timespans `json:"usage,omitempty"`
}
func (*TraitUsage) DeepCopy ¶
func (in *TraitUsage) DeepCopy() *TraitUsage
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TraitUsage.
func (*TraitUsage) DeepCopyInto ¶
func (in *TraitUsage) DeepCopyInto(out *TraitUsage)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type TraitUsages ¶
type TraitUsages []TraitUsage
func (TraitUsages) DeepCopy ¶
func (in TraitUsages) DeepCopy() TraitUsages
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TraitUsages.
func (TraitUsages) DeepCopyInto ¶
func (in TraitUsages) DeepCopyInto(out *TraitUsages)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type UsageServiceConfig ¶
type UsageServiceConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec UsageServiceConfigSpec `json:"spec,omitempty"`
}
+kubebuilder:object:root=true +kubebuilder:resource:scope=Cluster,shortName=usc;uscfg +kubebuilder:metadata:labels="openmcp.cloud/cluster=platform"
func (*UsageServiceConfig) DeepCopy ¶
func (in *UsageServiceConfig) DeepCopy() *UsageServiceConfig
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UsageServiceConfig.
func (*UsageServiceConfig) DeepCopyInto ¶
func (in *UsageServiceConfig) DeepCopyInto(out *UsageServiceConfig)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*UsageServiceConfig) DeepCopyObject ¶
func (in *UsageServiceConfig) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type UsageServiceConfigList ¶
type UsageServiceConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []UsageServiceConfig `json:"items"`
}
+kubebuilder:object:root=true
func (*UsageServiceConfigList) DeepCopy ¶
func (in *UsageServiceConfigList) DeepCopy() *UsageServiceConfigList
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UsageServiceConfigList.
func (*UsageServiceConfigList) DeepCopyInto ¶
func (in *UsageServiceConfigList) DeepCopyInto(out *UsageServiceConfigList)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*UsageServiceConfigList) DeepCopyObject ¶
func (in *UsageServiceConfigList) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type UsageServiceConfigSpec ¶
type UsageServiceConfigSpec struct {
// GarbageCollection specifies how usage records should be garbage collected.
// +optional
GarbageCollection *GarbageCollectionConfig `json:"garbageCollection,omitempty"`
// ResourcesToTrack specifies for which resources usage should be tracked.
ResourcesToTrack []ResourceToTrack `json:"resourcesToTrack,omitempty"`
}
func (*UsageServiceConfigSpec) DeepCopy ¶
func (in *UsageServiceConfigSpec) DeepCopy() *UsageServiceConfigSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UsageServiceConfigSpec.
func (*UsageServiceConfigSpec) DeepCopyInto ¶
func (in *UsageServiceConfigSpec) DeepCopyInto(out *UsageServiceConfigSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.