opencost/opencost-website

On-Premises Pricing - Further clarifications would be really nice

Closed this issue · 10 comments

The guide for providing pricing for on-promises pricing is unclear for newcomers to OpenCost. It would be really helpful and a timesaver if the guide contained a section where it's stated and shown how the custom pricing (default.json) is mounted to the opencost container in the deployment config.

Let me know you'd like me to create a PR where I give it go.

apiVersion: v1
kind: ConfigMap
metadata:
  name: opencost-conf
data:
  default.json: |
    {
      "provider": "custom",
      "description": "Default prices based on GCP us-central1",
      "CPU": "0.1",
      "spotCPU": "0.1",
      "RAM": "0.2",
      "spotRAM": "0.2",
      "GPU": "1",
      "storage": "0.3",
      "zoneNetworkEgress": "0.01",
      "regionNetworkEgress": "0.01",
      "internetNetworkEgress": "0.12"
    }
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: opencost
  labels:
    app: opencost
spec:
  replicas: 1
  selector:
    matchLabels:
      app: opencost
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: opencost
    spec:
      restartPolicy: Always
      serviceAccountName: opencost
      containers:
        - image: quay.io/kubecost1/kubecost-cost-model:latest
          name: opencost
          resources:
            requests:
              cpu: "10m"
              memory: "55M"
            limits:
              cpu: "999m"
              memory: "1G"
          env:
            - name: PROMETHEUS_SERVER_ENDPOINT
              value: "http://my-prometheus-server.prometheus.svc" # The endpoint should have the form http://<service-name>.<namespace-name>.svc
            - name: CLOUD_PROVIDER_API_KEY
              value: "AIzaSyD29bGxmHAVEOBYtgd8sYM2gM2ekfxQX4U" # The GCP Pricing API requires a key. This is supplied just for evaluation.
            - name: CLUSTER_ID
              value: "cluster-one" # Default cluster ID to use if cluster_id is not set in Prometheus metrics.
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /models/default.json
              name: opencost-defaults
              subPath: default.json
        - image: quay.io/kubecost1/opencost-ui:latest
          name: opencost-ui
          resources:
            requests:
              cpu: "10m"
              memory: "55M"
            limits:
              cpu: "999m"
              memory: "1G"
          imagePullPolicy: Always
      volumes:
        - name: opencost-defaults
          configMap:
            name: opencost-conf #
            items:
              - key: default.json
                path: default.json

#93 updated the website at https://www.opencost.io/docs/on-prem#custom-pricing-using-the-opencost-helm-chart

I was able to update my aws.json and my default.json, I'll think about refactoring this page to make it a bit clearer what our options are.

@daniwk What would you like to see?

opencost/opencost#1756 is related. I was able to override my AWS spot pricing

daniwk commented

Sorry, for getting back to you so late.

After some work with OpenCost I was finally able to load our pricing model to OpenCost and tag nodes with different price SKUs. This required a bit investigation in the source code, OpenCost docs and KubeCost docs. In retrospect, I think it would be helpful for new users if the docs outline, as you say, what the different options are:

  • Default pricing. Explaining default pricing, how it works and how you can override the defaults.
  • Custom CSV Pricing. Explaining what it is (supplying your own price model), how you can provide your own model, how you assign nodes to different SKUs, how you can use the API to verify that OpenCost has assigned the different nodes with the correct SKU.
  • CPU and RAM cost. A section on how OpenCost allocates RAM and CPU cost (based on the ratio of CPU and RAM cost in default.json).

I'd be happy to contribute here.

@daniwk we'd love to have additional documentation on this. Please let me know how I can help you out!

Sorry, for getting back to you so late.

After some work with OpenCost I was finally able to load our pricing model to OpenCost and tag nodes with different price SKUs. This required a bit investigation in the source code, OpenCost docs and KubeCost docs. In retrospect, I think it would be helpful for new users if the docs outline, as you say, what the different options are:

  • Default pricing. Explaining default pricing, how it works and how you can override the defaults.
  • Custom CSV Pricing. Explaining what it is (supplying your own price model), how you can provide your own model, how you assign nodes to different SKUs, how you can use the API to verify that OpenCost has assigned the different nodes with the correct SKU.
  • CPU and RAM cost. A section on how OpenCost allocates RAM and CPU cost (based on the ratio of CPU and RAM cost in default.json).

I'd be happy to contribute here.

Hi @daniwk, thanks for the sharing on this. I do have a quick question on CPU and RAM cost section. From what I read in the code, the ratio could only be derived through CPU and RAM section in the default.json, like here, right? If I want to set it for our cluster, how do we come up with those values? Is that a heuristic value through practice or something we could adjust in a per SKU perspective? We are evaluating the opencost for on-prem cluster as well, and would like to know more about this.

daniwk commented

That's correct, @lordofire. Or to be more precise: I arrived at the same conclusion after searching through the code and docs. I haven't found a way to adjust this ratio on a per SKU basis though. We are mostly concerned with the total node cost, and not the specific CPU and RAM costs, but I guess you could look at your procurement data and infer the CPU and RAM ratio from that.

Hi @daniwk , thanks for sharing!

Could you please help explain how do you derive the ratio of cpu/memory unit price in your situation? In our on-prem DC, we do have some memory optimized instances (which means bigger memory, and less unit cost for per GB memory), so how to determine that will be a problem for us to proceed further. Also, it would be great if you could explain how do you only measure the total node cost without the specific CPU/RAM cost. In my situation, my goal of using opencost is to have a single metric to evaluate our usage cost vs TCO.

daniwk commented

Sorry for getting back to you so late.

In short, we skipped the entire "try to find the ratio of cpu/memory unit price" because we have a lot of different SKUs and the ratio will depend on what SKU you choose. AFAIK, OpenCost doesn't support SKU specific cpu/memory ratio.

When it comes to assigning total node cost it seems we're in a different situation. I work in a cloud company offering compute and managed services. We therefore have a price sheet containing what each compute specification will cost so we're simply assigning these prices to the different nodes (through the Custom CSV provider).

I'm marking this as complete with #159