This example demonstrates metering execution time of Pods running in Kubernetes.
- Prerequisites
- Preparations
- Deploy the example
- Checking events
- Cleanup
- Advanced configuration
- Production use
Any local (or remote if that's what's available for you) Kubernetes cluster will do.
We will use kind in this example.
Additional tools you are going to need:
Create a new Kubernetes cluster using kind:
kind create clusterTip
Alternatively, set up your kubectl context to point to your existing cluster.
Deploy the test Pods to the cluster:
kubectl apply -f seed/pod.yamlCreate a meter in OpenMeter with the following details:
- Event type:
kube-pod-exec-time - Aggregation:
SUM - Value property:
$.duration_seconds - Group by (optional):
pod_namespace:$.pod_namespacepod_name:$.pod_name
Tip
Read more about creating a meter in the general examples README.
Deploy Benthos to your cluster:
helm install --wait --namespace benthos --create-namespace --set preset=kubernetes-pod-exec-time --set openmeter.url=<OPENMETER URL> --set openmeter.token=<OPENMETER_TOKEN> benthos-openmeter oci://ghcr.io/openmeterio/helm-charts/benthos-openmeterNote
If you use OpenMeter Cloud, you can omit the openmeter.url parameter.
Read more in the general examples README.
Uninstall Benthos from the cluster:
helm delete --namespace benthos benthos-openmeterRemove the sample Pods from the cluster:
kubectl delete -f seed/pod.yamlDelete the cluster:
kind delete clusterThis example uses a custom Benthos plugin called kubernetes_resources (included in this project) to periodically scrape the Kubernetes API for active pods.
The entire pipeline can be found in config.yaml.
Check out the configuration file and the Benthos documentation for more details.
We are actively working on improving the documentation and the examples. In the meantime, feel free to contact us in email or on Discord.
We are more than happy to help you set up OpenMeter in your production environment.