opencost / opencost

Cost monitoring for Kubernetes workloads and cloud costs
http://opencost.io
Apache License 2.0
5.18k stars 546 forks source link

Opencost Plugin Request: Crossplane Hyperscaler Providers #2758

Open dholeshu opened 4 months ago

dholeshu commented 4 months ago

After reading the blog post about opencost plugins, the idea about a crossplane plugin came up.

There should be a crossplane plugin for opencost that supports collecting cost metrics about hyperscaler resources created through crossplane providers for three main hyperscalers azure, aws and gcp. The hyperscaler resources are represented as k8s custom resources inside the clusters and are getting managed by crossplane providers.

An AWS EC2 instance CR for example, would look like this:

apiVersion: ec2.aws.upbound.io/v1beta1
kind: Instance
metadata:
  annotations:
    uptest.upbound.io/timeout: "3600"
    meta.upbound.io/example-id: ec2/v1beta1/instance
  labels:
    testing.upbound.io/example-name: sample-instance
  name: sample-instance
spec:
  forProvider:
    region: us-west-1
    ami: ami-07b068f843ec78e72
    instanceType: t2.micro
    networkInterface:
    - deviceIndex: 0
      networkInterfaceIdSelector:
        matchLabels:
          testing.upbound.io/example-name: sample-instance
    creditSpecification:
    - cpuCredits: unlimited

Many more example resources can be found here.

Feel free to reach out to me in case of further questions or lets discuss :-)

dwbrown2 commented 4 months ago

This sounds like a really interesting use! Any more detail on how you'd intend to consume this data? I'm trying to understand if a plugin would be the right approach or if a more CRD-aware solution would be the answer.

cc @chipzoller @ameijer @AjayTripathy

mattray commented 4 months ago

@dholeshu let us know if you need any assistance if you're thinking about implementing this