Skip to main content

Configuring Cost for Kubernetes

Torque collects cost data using cost collection targets, which are managed in the Administration page's Cloud Accounts tab. For AWS and Azure clouds, you must first add a cost collection target, however for K8s, Torque automatically creates a cost collection target when an agent is installed on the cluster.

Follow the next steps to start collecting cost on your K8s cluster:

  1. Install Kubecost:

    1. Torque collects cost data directly from the pods using a 3rd-party tool called Kubecost. To start collecting costs from your cluster, deploy Kubecost in your cluster.
  2. Validate the relevant cost collection target:

    1. Identifiy the relevant cost collection target. Its name will be the same name as the agent installed on the cluster.
    2. Click the cost collection target's 3 dot menu and select Validate to make sure it works (i.e. cost data can be collected).
  3. Enable the relevant cost collection target:

    1. Go to Administration > Cloud Accounts > Cost Collection Target.

    2. Click the desired cost collection target's Enabled toggle.

      Locale Dropdown

Troubleshooting

  1. Verify that Kubecost is deployed in the cluster.
    1. Navigate your browser to http://localhost:9090/. If you can see kubecost data, it means it's working. If you can't, see this guide for help.
  2. In Torque, try to re-enable the K8S cost collection target and validate that it works.
  3. If the error still exists, run the Get agent deployment file API call with the following body:
    {
    "service_type": "k8s",
    "service_name": "[the name of the agent]",
    "details": {
    "include_agent_deployment": false,
    "enable_kubecost": true
    }
    }
  4. Save the output to a deployment file.
  5. Run the following command on the cluster:
    kubectl apply -f “[generated deployment file]
  6. Try to re-validate the cost collection target.
  7. If the error still exists, call Torque support.