How to register data center resources
In Chantico, one of the custom resources that can be provided is the data center resource. This resource defines which equipment and customer-facing services live in your cloud, such as PDUs, bare metals and VMs. The resource defines metrics that are usable to monitor the resource, and coefficients that can be used to calculate the resource’s share in energy consumption measured by other metrics.
The data center resource also defines relationships with parent devices. A bare metal server can be connected to one or more PDUs, for example, and PDUs may have multiple dependent bare metals. Together, this forms a resource graph.
In order to use the graph correctly during aggregation and other calculation, the graph must be acyclic, such that no resource is both the parent of another resource and the other way around, or indirectly (grand-…)parent through other resources.
To create data center resources, have a look at
config/samples/chantico_v1alpha1_datacenterresource.yaml.
- Apply the file to your cluster:
- Edit the file to add a parent to one of the PDUs:
- Apply the file again:
- Check the resource:
Notice that the status of the resource is updated to have a validation message.
- Revert your changes and apply the file again, to check that the validation message disappears.
Set energy metrics and coefficients
Root resources must define energyMetric or energyMetricFrom. Each parent
listed by a child must define coefficient or coefficientFrom. For simple
inline expressions, use the shorthand fields:
An inline coefficient on a parent reference is:
During reconciliation, Chantico expands energyMetric into
energyMetricFrom.value and coefficient into coefficientFrom.value without
changing the stored spec. Coefficients are strings, so numeric values must be wrapped in quotes.
Do not set a shorthand field together with its corresponding From field.
Use energyMetricFrom and coefficientFrom for ConfigMap or Secret references
with valueFrom, or for templates with templateParameters. Inline value
expressions remain supported as well.
Reuse PromQL with ConfigMap templates
Use a ConfigMap template when the same PromQL expression is needed for more
than one resource and only a few labels or values differ. Chantico reads the
template from the ConfigMap in the same namespace as the DataCenterResource,
renders it using Go template syntax, and uses the result as the metric or
coefficient expression. You can also put template text directly in value;
provide templateParameters whenever placeholders need substituting.
- Create a ConfigMap with the PromQL expression under a named key. Template
values use the parameter name, for example
{{ .job }}:
- Reference the template from
spec.energyMetricFromorspec.parents[].coefficientFrom. Each entry intemplateParameterssupplies a named template value:
Template parameter values can be provided directly with value, or loaded with
valueFrom.configMapKeyRef or valueFrom.secretKeyRef. All resources
referenced must be in the same namespace as the DataCenterResource.
IN case of a missing parameter or an invalid key reference, the resource
will not reconcile. Errors will be attached to the DataCenterResource
which can be checked with kubectl describe.
Future steps
The current state of the data center resource may change in a future development iteration to allow more information to be added about which specific time series to monitor from a parent resource in order to aggregate and combine measurements. For example, if a bare metal is connected to a PDU on specific slots, we would want to include only specific walks from that PDU in this resource.