Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Kubernetes Pod Execution Time

This example demonstrates metering execution time of Pods running in Kubernetes.

Table of Contents

Prerequisites

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:

Preparations

Create a new Kubernetes cluster using kind:

kind create cluster

Tip

Alternatively, set up your kubectl context to point to your existing cluster.

Deploy the test Pods to the cluster:

kubectl apply -f seed/pod.yaml

Create 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_namespace
    • pod_name: $.pod_name

Tip

Read more about creating a meter in the general examples README.

Deploy the example

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-openmeter

Note

If you use OpenMeter Cloud, you can omit the openmeter.url parameter.

Checking events

Read more in the general examples README.

Cleanup

Uninstall Benthos from the cluster:

helm delete --namespace benthos benthos-openmeter

Remove the sample Pods from the cluster:

kubectl delete -f seed/pod.yaml

Delete the cluster:

kind delete cluster

Advanced configuration

This 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.

Production use

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.