# kubecost/cost-analyzer-helm-chart architecture

> Architecture diagram of the GitHub repository kubecost/cost-analyzer-helm-chart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kubecost/cost-analyzer-helm-chart
- Repository: https://github.com/kubecost/cost-analyzer-helm-chart

## Overview

##### Project Type and Purpose
- This is a Helm chart that packages Kubecost deployments. Its main purpose is to deploy, manage, and configure Kubecost in a Kubernetes environment.
- It integrates multiple components such as cost analysis backend (aggregator), a web-based frontend, monitoring integrations (Prometheus, Grafana) and admission controllers along with ancillary services (ETL utilities, diagnostics).

##### File Structure – Key Observations
- Top-Level Directories:
– The “cost-analyzer” directory is central; it contains the Helm chart (Chart.yaml), a variety of Kubernetes manifests grouped under the “templates” subdirectory, and multiple values files (values.yaml, values-*.yaml).
– “.devcontainer” and “.github” contain configurations for development and CI/CD respectively.
– There are also directories for “docs” and “historical-builds” which support documentation and past releases.
- Within “cost-analyzer/templates”, you see resources for:
– Deployments (aggregator, frontend, ETL utilities, diagnostics)
– Services and ServiceAccounts
– ConfigMaps and Secrets (cloud integration secrets, pricing configurations, Grafana dashboards, prometheus alerts, etc.)
– Custom Resource Definitions (CRDs) for extended functionalities.
– Monitoring components for Prometheus and Grafana, indicating careful integrations with Kubernetes monitoring tools.
- The “cost-analyzer/grafana-dashboards” and “cost-analyzer/templates/grafana” directories further emphasize integrated monitoring and dashboard visualizations.

##### Components
- Helm Chart Packaging: At the center, the Helm chart acts as a package manager that installs and updates the Kubecost application.
- Core Kubecost Components:
– Cost Analyzer “Aggregator”: This component collects and processes cost data.
– Frontend: The user interface for access to cost data and insights.
- Monitoring and Integrations:
– Prometheus: Used to collect monitoring metrics. The resources (e.g., ServiceMonitors, PodMonitors, Prometheus rules) integrated into the chart should be depicted.
– Grafana: For dashboards and visualization that display cost data, linked to Prometheus and validated via ConfigMaps and dashboard templates.
- Infrastructure Components:
– Persistent Volumes & Storage: Highlight the use of PVCs for both Prometheus and the cost analyzer.
– Kubernetes Resources (Deployments, Services, Ingress controllers): Show their logical placement.
– Cloud integration secrets and configurations: Components for AWS, Azure, Alibaba integrations enabling cloud cost analysis.
- Ancillary Services:
– ETL Utils, Diagnostics components, Admission Controllers, and CRDs that extend functionality.

##### Architectural Relationships and Interactions
- Data Flow & Dependencies:
– The Helm chart triggers deployment of the aggregator, frontend, ETL utilities, and monitoring setups.
– Aggregator interacts with persistent storage and receives metrics from Prometheus.
– The Prometheus monitoring system collects metrics from various Kubernetes components and feeds this data to Grafana dashboards.
– ConfigMaps, Secrets, and CRDs are consumed by these deployed services for configuration and extended permissions.
- Interaction with Kubernetes APIs: All components are installed as Kubernetes native resources, communicating via standard APIs.
- Dependencies: For example, if “global.prometheus.enabled” is true, then the deployment will provision a local Prometheus instance, else it expects an external one.

- Helm Chart Packaging (center/entry point)
- Kubecost Aggregator (deployment, statefulset)
- Kubecost Frontend
- Monitoring Components:
– Prometheus (with ServiceMonitors, Node Exporters, alerts)
– Grafana (with dashboard configuration maps)
- Persistent Storage (PVCs for cost analyzer and Prometheus)
- Additional Kubernetes Resources (CRDs, Secrets, ConfigMaps, Ingress)
- External Integrations (Cloud service keys for AWS, Azure, Alibaba shown as separate blocks that feed into the system).

## Diagram (Mermaid)

```mermaid
graph TD
    A["Helm Chart Packaging"]:::helm

    subgraph "Deployment Layer"
        subgraph "Kubecost Aggregator"
            AG1["Aggregator Deployment"]:::deployment
            AG2["Aggregator StatefulSet"]:::deployment
            AG3["Aggregator Service"]:::service
        end
        subgraph "Kubecost Frontend"
            FE1["Frontend Deployment"]:::deployment
            FE2["Frontend Service"]:::service
        end
        subgraph "ETL Utilities"
            ETL1["ETL Deployment"]:::deployment
            ETL2["ETL Service"]:::service
        end
        subgraph "Diagnostics Component"
            DIAG1["Diagnostics Deployment"]:::deployment
            DIAG2["Diagnostics Service"]:::service
        end
        subgraph "Admission Controllers"
            AC1["Admission Controller Deployment"]:::deployment
            AC2["Admission Controller Service"]:::service
        end
    end

    subgraph "Monitoring Layer"
        PR["Prometheus"]:::monitor
        SM["Service Monitors"]:::monitor
        GF["Grafana Deployment/Config"]:::monitor
        Dash["Grafana Dashboards"]:::monitor
    end

    subgraph "Persistent Storage"
        PVC1["Kubecost PVC"]:::pvc
        PVC2["Prometheus PVC"]:::pvc
    end

    subgraph "Configurations Layer"
        CFG["ConfigMaps/Secrets/CRDs"]:::config
        CLOUD["Cloud Integration Secrets"]:::config
    end

    A --> AG1
    A --> FE1
    A --> ETL1
    A --> DIAG1
    A --> AC1
    A --> PR
    A --> GF
    A --> CFG
    A --> CLOUD
    A --> PVC1
    A --> PVC2

    AG1 --> PVC1
    PR --> PVC2
    PR -->|"data"| GF
    GF --> Dash
    AG3 --> SM

    classDef helm fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef deployment fill:#bbdefb,stroke:#333,stroke-width:2px;
    classDef service fill:#c8e6c9,stroke:#333,stroke-width:2px;
    classDef monitor fill:#fff9c4,stroke:#333,stroke-width:2px;
    classDef pvc fill:#ffe0b2,stroke:#333,stroke-width:2px;
    classDef config fill:#b2dfdb,stroke:#333,stroke-width:2px;

    %% Click Events
    click A "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/Chart.yaml"
    click AG1 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/aggregator-cloud-cost-deployment.yaml"
    click AG2 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/aggregator-statefulset.yaml"
    click AG3 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/aggregator-service.yaml"
    click FE1 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/frontend-deployment-template.yaml"
    click FE2 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/frontend-service-template.yaml"
    click ETL1 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/etl-utils-deployment.yaml"
    click ETL2 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/etl-utils-service.yaml"
    click DIAG1 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/diagnostics-deployment.yaml"
    click DIAG2 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/diagnostics-service.yaml"
    click AC1 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/kubecost-admission-controller-template.yaml"
    click AC2 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/kubecost-admission-controller-service-template.yaml"
    click PR "https://github.com/kubecost/cost-analyzer-helm-chart/tree/develop/cost-analyzer/templates/prometheus/"
    click SM "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/aggregator-servicemonitor.yaml"
    click SM "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/network-costs-servicemonitor-template.yaml"
    click GF "https://github.com/kubecost/cost-analyzer-helm-chart/tree/develop/cost-analyzer/templates/grafana/"
    click Dash "https://github.com/kubecost/cost-analyzer-helm-chart/tree/develop/cost-analyzer/grafana-dashboards/"
    click PVC1 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/cost-analyzer-pvc-template.yaml"
    click PVC2 "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/prometheus/prometheus-server-pvc.yaml"
    click CFG "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/cost-analyzer-config-map-template.yaml"
    click CFG "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/crds/cluster-turndown-crd.yaml"
    click CLOUD "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/aws-service-key-secret.yaml"
    click CLOUD "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/azure-service-key-secret.yaml"
    click CLOUD "https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/alibaba-service-key-secret.yaml"
```
