DEV Community

Cover image for Setup OpenCost in Kubernetes using Helm
Yevhen Tienkaiev
Yevhen Tienkaiev

Posted on • Edited on

7 1 1

Setup OpenCost in Kubernetes using Helm

My setup is AWS and EKS.

My work based on:

I created custom helm chart based on OpenCost helm chart(official?) here is my default values.yaml:

fullnameOverride: opencost

awsSpotDataRegion: ""
awsSpotDataBucket: ""
awsAccountId: ""

opencost:
  serviceAccount:
    create: true
    annotations:
      eks.amazonaws.com/role-arn: "xxx"
  opencost:
    exporter:
      defaultClusterId: "xxx"
      extraEnv:
        EMIT_KSM_V1_METRICS: "false"
        EMIT_KSM_V1_METRICS_ONLY: "true"
        PROM_CLUSTER_ID_LABEL: cluster
        LOG_LEVEL: info #error
      extraVolumeMounts:
        - name: opencost-conf
          mountPath: /models/aws.json
          subPath: aws.json
    prometheus:
      external:
        enabled: true
        url: "http://mimir-nginx.mimir.svc.cluster.local:80/prometheus"
      internal:
        enabled: false
    ui:
      enabled: true
  extraVolumes:
    - name: opencost-conf
      configMap:
        name: opencost-conf
        items:
          - key: "aws.json"
            path: "aws.json"
Enter fullscreen mode Exit fullscreen mode

Also in my custom chart I included configmap.yaml, here is content of it:

apiVersion: v1
kind: ConfigMap
metadata:
  name: opencost-conf
data:
  aws.json: |
    {
        "provider": "custom",
        "description": "Default prices used to compute allocation between RAM and CPU. AWS pricing API data still used for total node cost.",
        "CPU": "0.031611",
        "spotCPU": "0.006655",
        "RAM": "0.004237",
        "GPU": "0.95",
        "spotRAM": "0.000892",
        "storage": "0.00005479452",
        "zoneNetworkEgress": "0.01",
        "regionNetworkEgress": "0.01",
        "internetNetworkEgress": "0.143",
        "spotLabel": "",
        "spotLabelValue": "",
        "awsServiceKeyName": "",
        "awsServiceKeySecret": "",
        "awsSpotDataRegion": "{{ .Values.awsSpotDataRegion }}",
        "awsSpotDataBucket": "{{ .Values.awsSpotDataBucket }}",
        "awsSpotDataPrefix": "",
        "athenaBucketName": "s3://x",
        "athenaRegion": "us-east-1",
        "athenaDatabase": "",
        "athenaTable": "",
        "projectID": "{{ .Values.awsAccountId }}"
    }
Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (1)

Collapse
 
wiwek13 profile image
wiwek13

what permission did you give to role?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay