# rverchere/ovh-mks-exporter architecture

> Architecture diagram of the GitHub repository rverchere/ovh-mks-exporter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rverchere/ovh-mks-exporter
- Repository: https://github.com/rverchere/ovh-mks-exporter

## Overview

##### Main Components

a. External Systems:
- OVH Cloud API (primary data source)
- Prometheus Server (metrics consumer)
- Kubernetes Cluster (deployment environment)

b. Internal Components:
- OVH MKS Exporter (core application)
- Metrics Collectors (internal modules)
- HTTP Server (for exposing metrics)

##### Component Relationships

- OVH MKS Exporter → OVH Cloud API (API calls with authentication)
- Prometheus → OVH MKS Exporter (scrapes metrics)
- Kubernetes → OVH MKS Exporter (hosts the application)

##### Detailed Component Breakdown

a. OVH MKS Exporter Core (based on internal/ directory):
- Collector Module (collector.go)
- Exporter Module (exporter.go)
- OVH Metrics Module (ovh_metrics.go)
- Version Module (version.go)

b. Configuration Layer:
- Environment Variables
- Kubernetes Secrets (for OVH API credentials)
- Helm Chart Configuration

##### Key Workflows to Highlight

a. Metric Collection Flow:
1. Prometheus triggers scrape
2. Exporter calls OVH API
3. Data is transformed into metrics
4. Metrics are exposed via HTTP endpoint

b. Deployment Flow:
1. Helm chart deployment
2. Secret management
3. ServiceMonitor configuration

##### Additional Details

Specific elements:
- Metric types (as listed in README)
- Authentication flow with OVH API
- Kubernetes resources (ServiceMonitor, Service, Deployment)

##### Architectural Notes

Aspects:
- Prometheus integration pattern
- Kubernetes-native design
- Secure credential management
- Modular collector design

This design should reflect the project's nature as a Kubernetes-native Prometheus exporter while highlighting its specific role in monitoring OVH managed Kubernetes clusters.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Systems"]
        OVH_API["OVH Cloud API"]:::external
        PROM["Prometheus Server"]:::external
    end

    subgraph K8s["Kubernetes Cluster"]
        subgraph Core["OVH MKS Exporter Core"]
            MAIN["Main Application"]:::app
            COLLECTOR["Collector Module"]:::module
            EXPORTER["Exporter Module"]:::module
            OVH_METRICS["OVH Metrics Module"]:::module
            VERSION["Version Module"]:::module
        end

        subgraph Config["Configuration Layer"]
            HELM["Helm Chart"]:::config
            SECRETS["Kubernetes Secrets"]:::config
            SA["Service Account"]:::config
            VALUES["Values Configuration"]:::config
        end

        subgraph K8sRes["Kubernetes Resources"]
            DEPLOY["Deployment"]:::k8s
            SVC["Service"]:::k8s
            SM["ServiceMonitor"]:::k8s
            RULES["Prometheus Rules"]:::k8s
        end
    end

    %% Relationships
    PROM --> SM
    SM --> SVC
    SVC --> DEPLOY
    DEPLOY --> MAIN
    MAIN --> COLLECTOR
    COLLECTOR --> EXPORTER
    COLLECTOR --> OVH_METRICS
    COLLECTOR --> VERSION
    OVH_METRICS --> OVH_API
    SECRETS --> MAIN
    SA --> MAIN
    HELM --> DEPLOY
    HELM --> SVC
    HELM --> SM
    HELM --> SECRETS
    VALUES --> HELM

    %% Click Events
    click MAIN "https://github.com/rverchere/ovh-mks-exporter/blob/main/cmd/ovh-mks-exporter/main.go"
    click COLLECTOR "https://github.com/rverchere/ovh-mks-exporter/blob/main/internal/collector.go"
    click EXPORTER "https://github.com/rverchere/ovh-mks-exporter/blob/main/internal/exporter.go"
    click OVH_METRICS "https://github.com/rverchere/ovh-mks-exporter/blob/main/internal/ovh_metrics.go"
    click VERSION "https://github.com/rverchere/ovh-mks-exporter/blob/main/internal/version.go"
    click HELM "https://github.com/rverchere/ovh-mks-exporter/tree/main/deployment/charts/ovh-mks-exporter"
    click DEPLOY "https://github.com/rverchere/ovh-mks-exporter/blob/main/deployment/charts/ovh-mks-exporter/templates/deployment.yaml"
    click SVC "https://github.com/rverchere/ovh-mks-exporter/blob/main/deployment/charts/ovh-mks-exporter/templates/service.yaml"
    click SM "https://github.com/rverchere/ovh-mks-exporter/blob/main/deployment/charts/ovh-mks-exporter/templates/servicemonitor.yaml"
    click SECRETS "https://github.com/rverchere/ovh-mks-exporter/blob/main/deployment/charts/ovh-mks-exporter/templates/ovh-token-secret.yaml"
    click RULES "https://github.com/rverchere/ovh-mks-exporter/blob/main/deployment/manifests/prometheus-rules-etcd-quota.yaml"
    click VALUES "https://github.com/rverchere/ovh-mks-exporter/blob/main/deployment/charts/ovh-mks-exporter/values.yaml"
    click SA "https://github.com/rverchere/ovh-mks-exporter/blob/main/deployment/charts/ovh-mks-exporter/templates/serviceaccount.yaml"

    %% Styling
    classDef external fill:#2374AB,color:#fff
    classDef app fill:#57A773,color:#fff
    classDef module fill:#98B9AB,color:#000
    classDef config fill:#ED9B40,color:#000
    classDef k8s fill:#7D8491,color:#fff

    %% Legend
    subgraph Legend
        EXT["External System"]:::external
        APP["Application Component"]:::app
        MOD["Module"]:::module
        CONF["Configuration"]:::config
        K8S["Kubernetes Resource"]:::k8s
    end
```
