> ## Documentation Index
> Fetch the complete documentation index at: https://www.qovery.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubecost

> Monitor and reduce Kubernetes spend with Kubecost

Kubecost provides real-time cost visibility and insights for your Kubernetes clusters. This guide shows you how to deploy Kubecost on your Qovery cluster to track and optimize your infrastructure spending.

<Note>
  **Prerequisites**: You need a functioning Qovery cluster before starting this tutorial.
</Note>

<Info>This tutorial takes approximately **5 minutes** to complete.</Info>

## Installation

<Note>
  This guide targets chart version 3.1.8. Steps may differ for other versions — check the [official Kubecost docs](https://www.ibm.com/docs/en/kubecost/self-hosted/3.x) for the latest.
</Note>

### Step 1: Add the Kubecost Helm Repository

<Steps>
  <Step title="Add Helm Repository">
    In [Qovery Console](https://console.qovery.com):

    1. Go to **Settings** → **Helm Repositories**
    2. Click **Add Repository**
    3. Configure:
       * Repository name: `Kubecost`
       * Kind: `HTTPS`
       * Repository URL: `https://kubecost.github.io/kubecost`

    See [Helm Repository Management](/configuration/organization/helm-repository) for more details.
  </Step>
</Steps>

### Step 2: Create the Kubecost Helm Service

<Steps>
  <Step title="Create Helm Service">
    In your environment:

    1. Click **Create** → **Helm Chart**
    2. Configure:
       * Service name: `kubecost`
       * Helm source: `Helm repository`
       * Repository: `Kubecost`
       * Chart name: `kubecost`
       * Version: `3.1.8` (or [latest from Kubecost](https://github.com/kubecost/helm-charts/releases))
       * Allow cluster-wide resources: ✔️

    See [Helm Charts](/configuration/helm) for more details on creating a Helm service.
  </Step>
</Steps>

### Step 3: Configure Variables and Values Override

<Steps>
  <Step title="Add optional variables">
    Open the Kubecost service overview and go to the **Variables** section.

    Add these variables as needed:

    | Variable         | Value          | Scope   | Secret | Notes                                                   |
    | ---------------- | -------------- | ------- | ------ | ------------------------------------------------------- |
    | `KUBECOST_TOKEN` | `<your_token>` | Service | ✔️     | Required only for Kubecost Business/Enterprise features |

    See [Environment Variables](/configuration/environment-variables) for more details on managing variables in Qovery.
  </Step>

  <Step title="Configure Values Override">
    In the **Override as file** section of your Helm service, add the following configuration:

    ```yaml theme={null}
    global:
      clusterId: my-cluster-name  # A unique identifier for your cluster in Kubecost
    ```

    If you have a Kubecost token, add it to the override:

    ```yaml theme={null}
    global:
      clusterId: my-cluster-name

    kubecostToken: qovery.env.KUBECOST_TOKEN
    ```

    <Note>
      **How `qovery.env.*` works**: At deploy time, Qovery replaces `qovery.env.KUBECOST_TOKEN` with the actual value of the `KUBECOST_TOKEN` variable. The real value never appears in the Qovery UI — it is only injected at Helm install time. See [Environment Variables in Helm Values](/configuration/helm#environment-variables-in-values) for more details.
    </Note>
  </Step>
</Steps>

### Step 4: Deploy the Chart

<Steps>
  <Step title="Deploy">
    1. Click the **Deploy** button
    2. Follow the deployment logs
    3. Verify Kubecost pods are running
  </Step>
</Steps>

### Step 5: Access Kubecost via Port Forward

Kubecost does not provide authentication by default, so exposing it publicly would leave your cost data accessible to anyone. Use `kubectl port-forward` instead to access the dashboard securely from your local machine.

<Steps>
  <Step title="Connect to your cluster">
    Download your cluster's kubeconfig from the Qovery Console:

    1. Go to **Organization** → **Clusters**
    2. Click on your cluster
    3. Open the **Actions** menu and select **Get Kubeconfig**

    <img src="https://mintcdn.com/qovery/QlI74Z2SIQn_IO46/images/kubecost/kubeconfig.png?fit=max&auto=format&n=QlI74Z2SIQn_IO46&q=85&s=b24bc65c68a94e14c4c7dc8b074e987d" alt="Link" width="1732" height="383" data-path="images/kubecost/kubeconfig.png" />

    Once downloaded, configure `kubectl` to use it:

    ```bash theme={null}
    export KUBECONFIG=/path/to/downloaded/kubeconfig.yaml
    ```

    Verify the connection:

    ```bash theme={null}
    kubectl get nodes
    ```

    See [Cluster Kubeconfig](/configuration/clusters#kubeconfig) for more details.
  </Step>

  <Step title="Get your environment namespace">
    In Qovery Console, go to your environment and find the Kubernetes namespace in the environment details. It follows the pattern `z<env-id-prefix>-<env-name>`.

    Alternatively, list namespaces on your cluster:

    ```bash theme={null}
    kubectl get namespaces
    ```
  </Step>

  <Step title="Find the Kubecost service name">
    List services in your namespace to find the Kubecost dashboard service:

    ```bash theme={null}
    kubectl get svc -n <namespace> | grep frontend
    ```
  </Step>

  <Step title="Forward the Kubecost port">
    Run the following command, replacing `<namespace>` and `<service-name>` with the values from the previous steps:

    ```bash theme={null}
    kubectl port-forward svc/<service-name> 9090:9090 -n <namespace>
    ```

    Then open your browser at [http://localhost:9090](http://localhost:9090).
  </Step>
</Steps>

<Tip>
  Keep the terminal open while using Kubecost — closing it will terminate the port-forward session.
</Tip>

## Conclusion

You've successfully deployed Kubecost on your Qovery cluster. You can now access the Kubecost dashboard to monitor your Kubernetes costs and get optimization recommendations.

Kubecost is now part of IBM, which is why the official documentation is hosted on IBM's website. To learn more about using Kubecost, check out their [Getting Started guide](https://www.ibm.com/docs/en/kubecost/self-hosted/3.x).

## Next Steps

<CardGroup cols={2}>
  <Card title="Kubecost Documentation" icon="book" href="https://www.ibm.com/docs/en/kubecost/self-hosted/3.x">
    Learn more about Kubecost features
  </Card>

  <Card title="Optimize" icon="gauge-high" href="/getting-started/guides/qovery-101/optimize">
    Optimization strategies with Qovery
  </Card>

  <Card title="Qovery Observe" icon="chart-line" href="/configuration/integrations/observability/qovery-observe">
    Built-in observability
  </Card>

  <Card title="Datadog" icon="dog" href="/configuration/integrations/observability/datadog">
    Advanced monitoring with Datadog
  </Card>
</CardGroup>
