Metering
meshStack supports metering and billing for the most common types of Kubernetes resources. Metering is based on periodically sampling the state of Kubernetes resources from the platform's API.
The accuracy of sampling-based metering naturally depends on the sampling interval. While insufficient for supporting a per-second billing model, it works very well for billing resources on a per-hour billing model.
Prerequisites
- The "meshfed-metering" service account must be configured as described here
- CPU and memory limits have to be defined for all containers, as metering is currently based on these limits
- Kubernetes APIs are accessible by meshStack metering collector components
Supported Resources
Resources with the following traits are addressable in the Product Catalog. Platform Operators can use the traits of these resources to define fine-granular product and pricing rules.
Pod
let PodResourceTraits =
{-
milliCpu:
Configured total CPU limit of all containers in this Pod, in milli CPU (1/1000 of a CPU).
The primitive usage quantity unit in product catalog entries is 'mCPU', e.g. '2500 mCPU'.
ramMb:
Configured total RAM limit of all containers in this Pod, in MiB.
The primitive usage quantity unit in product catalog entries is 'MiBy', e.g. '1024 MiBy'.
status:
Status phase of this pod. See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/
-}
{ milliCpu : Integer, ramMb : Integer, status : Text }
let example
: PodResourceTraits
= { milliCpu = +2500, ramMb = +1024, status = "Running" }
PersistentVolumeClaim
let PersistentVolumeClaimResourceTraits =
{-
status:
Status phase of this PersistentVolumeClaim. See https://docs.openshift.com/container-platform/4.1/storage/understanding-persistent-storage.html#pv-phase_understanding-persistent-storage
storageClassName:
Name of the Storage Class used for this volume.
storageMb:
Total Capacity of the Volume, in MiB.
-}
{ status : Text, storageClassName : Text, storageMb : Integer }
let example
: PersistentVolumeClaimResourceTraits
= { status = "Bound", storageClassName = "slow", storageMb = +5120 }