# kubedeckio/kubebuddy architecture

> Architecture diagram of the GitHub repository kubedeckio/kubebuddy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kubedeckio/kubebuddy
- Repository: https://github.com/kubedeckio/kubebuddy

## Overview

##### Project type and purpose
- KubeBuddy is a **PowerShell-based CLI tool / module** for Kubernetes cluster health and best-practice checks.
- It connects to a K8s API (and optionally Azure APIs for AKS), executes health/security/storage/network checks, and generates **HTML**, **JSON**, or **text** reports.

##### File structure
- Top-level module files:
- KubeBuddy.psd1 (module manifest)
- KubeBuddy.psm1 (public cmdlet definitions)
- Public/kubebuddy.ps1 (wrapper CLI)
- run.ps1 (test runner or entry script)
- “Private/” folder: contains core engine scripts—helper-functions.ps1, menu-functions.ps1, summary-functions.ps1, YAML-checks loader, JSON/HTML report generators, and AKS-specific checks under “Private/aks/…”.
- “Private/yamlChecks/” holds the check definitions in YAML (one file per resource-check type).
- “docs/” and “images/” support documentation and examples; GitHub workflows handle CI/CD, packaging, and publishing to PowerShell Gallery.

##### README for additional insights
- Confirms the module’s **features**: cluster health, workload analysis, event reporting, RBAC/security checks, networking/storage insights, customizable thresholds, report formats, and AKS best-practice checks.
- Shows the **configuration** mechanism (YAML file at ~/.kube/kubebuddy-config.yaml).
- Describes **usage patterns**: Invoke-KubeBuddy with parameters directing which checks to run and which report format to emit.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Runtime Flow
    subgraph "Runtime Flow"
        direction TB

        User["User"]:::user

        subgraph "CLI Layer"
            direction TB
            RunPS["run.ps1"]:::frontend
            PublicCLI["Public/kubebuddy.ps1"]:::frontend
            Cmdlet["KubeBuddy.psm1"]:::frontend
            Manifest["KubeBuddy.psd1"]:::frontend
        end

        subgraph "Core Engine"
            direction TB
            Helpers["helper-functions.ps1"]:::core
            Menu["menu-functions.ps1"]:::core
            Summary["summary-functions.ps1"]:::core
            ShowYAML["show-YamlChecksInteractive.ps1"]:::core
            YamlLoader["yamlChecks-function.ps1"]:::core
            GetData["get-kubedata.ps1"]:::core
            HealthScore["get-clusterHealthScore.ps1"]:::core
        end

        subgraph "Check Modules"
            direction TB
            subgraph "Generic K8s Checks (YAML)"
                direction TB
                CFG["cfg-checks.yaml"]:::core
                Event["event-checks.yaml"]:::core
                Job["job-checks.yaml"]:::core
                Net["net-checks.yaml"]:::core
                Node["node-checks.yaml"]:::core
                NS["ns-checks.yaml"]:::core
                Pod["pod-checks.yaml"]:::core
                RBAC["rbac-checks.yaml"]:::core
                Sec["sec-checks.yaml"]:::core
                Stg["stg-checks.yaml"]:::core
                Wrk["wrk-checks.yaml"]:::core
            end
            subgraph "AKS-Specific Checks"
                direction TB
                AKSFuncs["aks-functions.ps1"]:::core
                BPChk["BestPracticesChecks.ps1"]:::core
                DRChk["DisasterRecoveryChecks.ps1"]:::core
                IACChk["IdentityAndAccessChecks.ps1"]:::core
                MLChk["MonitoringLoggingChecks.ps1"]:::core
                NetChk["NetworkingChecks.ps1"]:::core
                RMChk["ResourceManagementChecks.ps1"]:::core
                SecChk["SecurityChecks.ps1"]:::core
            end
        end

        subgraph "Report Generators"
            direction TB
            JSONGen["create-jsonReport.ps1"]:::frontend
            HTMLGen["Create-htmlReport.ps1"]:::frontend
            ScriptsJS["report-scripts.js"]:::frontend
            StylesCSS["report-styles.css"]:::frontend
            TextOut["Write-Box.ps1"]:::frontend
        end

        Config["~/.kube/kubebuddy-config.yaml"]:::external
        K8sAPI["Kubernetes API"]:::external
        AzureAPI["Azure APIs"]:::external
        Output["Reports (HTML/JSON/Text)"]:::frontend

        %% Runtime Flow Connections
        User -->|"invokes"| RunPS
        RunPS --> PublicCLI
        PublicCLI --> Cmdlet
        Cmdlet --> Manifest
        Manifest --> Helpers
        Helpers --> Menu
        Menu --> Summary
        Summary --> ShowYAML
        ShowYAML --> YamlLoader
        YamlLoader --> CFG & Event & Job & Net & Node & NS & Pod & RBAC & Sec & Stg & Wrk
        Helpers --> GetData
        GetData --> K8sAPI
        GetData --> HealthScore
        HealthScore --> K8sAPI
        AKSFuncs --> AzureAPI
        AKSFuncs --> BPChk & DRChk & IACChk & MLChk & NetChk & RMChk & SecChk
        CFG & Event & Job & Net & Node & NS & Pod & RBAC & Sec & Stg & Wrk --> Helpers
        BPChk & DRChk & IACChk & MLChk & NetChk & RMChk & SecChk --> Helpers
        Summary --> JSONGen
        Summary --> HTMLGen
        Summary --> TextOut
        HTMLGen --> ScriptsJS
        HTMLGen --> StylesCSS
        JSONGen --> Output
        HTMLGen --> Output
        TextOut --> Output
        Config --> Helpers

    end

    %% Build/Publish Flow
    subgraph "Build/Publish Flow"
        direction TB
        subgraph "CI/CD Pipeline"
            direction TB
            DockerBuild["docker-build.yml"]:::ci
            PublishPS["publish-psgal.yml"]:::ci
            Pages["pages.yml"]:::ci
            ScriptAnalyzer["PSScriptAnalyzer.yaml"]:::ci
            Codespell["codespell.yml"]:::ci
            PRBot["pr-bot-welcome.yaml"]:::ci
        end
        subgraph "Documentation"
            direction TB
            Docs["docs/"]:::ci
            Mkdocs["mkdocs.yml"]:::ci
            Netlify["netlify.toml"]:::ci
            Overrides["overrides/"]:::ci
        end
        subgraph "Samples"
            direction TB
            HTMLSample["html-report-sample.html"]:::ci
            JSONSample["json-report-sample.json"]:::ci
            TextSample["text-report-sample.txt"]:::ci
        end
        CI["GitHub Actions"]:::ci
        CI --> DockerBuild & PublishPS & Pages & ScriptAnalyzer & Codespell & PRBot
        CI --> Docs
        Docs --> Mkdocs & Netlify & Overrides
        Docs --> HTMLSample & JSONSample & TextSample
    end

    %% Click Events
    click RunPS "https://github.com/kubedeckio/kubebuddy/blob/main/run.ps1"
    click PublicCLI "https://github.com/kubedeckio/kubebuddy/blob/main/Public/kubebuddy.ps1"
    click Cmdlet "https://github.com/kubedeckio/kubebuddy/blob/main/KubeBuddy.psm1"
    click Manifest "https://github.com/kubedeckio/kubebuddy/blob/main/KubeBuddy.psd1"
    click Helpers "https://github.com/kubedeckio/kubebuddy/blob/main/Private/helper-functions.ps1"
    click Menu "https://github.com/kubedeckio/kubebuddy/blob/main/Private/menu-functions.ps1"
    click Summary "https://github.com/kubedeckio/kubebuddy/blob/main/Private/summary-functions.ps1"
    click ShowYAML "https://github.com/kubedeckio/kubebuddy/blob/main/Private/show-YamlChecksInteractive.ps1"
    click YamlLoader "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks-function.ps1"
    click GetData "https://github.com/kubedeckio/kubebuddy/blob/main/Private/get-kubedata.ps1"
    click HealthScore "https://github.com/kubedeckio/kubebuddy/blob/main/Private/get-clusterHealthScore.ps1"
    click CFG "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/cfg-checks.yaml"
    click Event "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/event-checks.yaml"
    click Job "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/job-checks.yaml"
    click Net "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/net-checks.yaml"
    click Node "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/node-checks.yaml"
    click NS "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/ns-checks.yaml"
    click Pod "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/pod-checks.yaml"
    click RBAC "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/rbac-checks.yaml"
    click Sec "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/sec-checks.yaml"
    click Stg "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/stg-checks.yaml"
    click Wrk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/yamlChecks/wrk-checks.yaml"
    click AKSFuncs "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/aks-functions.ps1"
    click BPChk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/checks/BestPracticesChecks.ps1"
    click DRChk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/checks/DisasterRecoveryChecks.ps1"
    click IACChk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/checks/IdentityAndAccessChecks.ps1"
    click MLChk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/checks/MonitoringLoggingChecks.ps1"
    click NetChk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/checks/NetworkingChecks.ps1"
    click RMChk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/checks/ResourceManagementChecks.ps1"
    click SecChk "https://github.com/kubedeckio/kubebuddy/blob/main/Private/aks/checks/SecurityChecks.ps1"
    click JSONGen "https://github.com/kubedeckio/kubebuddy/blob/main/Private/create-jsonReport.ps1"
    click HTMLGen "https://github.com/kubedeckio/kubebuddy/blob/main/Private/Create-htmlReport.ps1"
    click ScriptsJS "https://github.com/kubedeckio/kubebuddy/blob/main/Private/html/report-scripts.js"
    click StylesCSS "https://github.com/kubedeckio/kubebuddy/blob/main/Private/html/report-styles.css"
    click TextOut "https://github.com/kubedeckio/kubebuddy/blob/main/Private/Write-Box.ps1"
    click Docs "https://github.com/kubedeckio/kubebuddy/tree/main/docs/"
    click HTMLSample "https://github.com/kubedeckio/kubebuddy/blob/main/docs/examples/html-report-sample.html"
    click JSONSample "https://github.com/kubedeckio/kubebuddy/blob/main/docs/examples/json-report-sample.json"
    click TextSample "https://github.com/kubedeckio/kubebuddy/blob/main/docs/examples/text-report-sample.txt"
    click Mkdocs "https://github.com/kubedeckio/kubebuddy/blob/main/mkdocs.yml"
    click Netlify "https://github.com/kubedeckio/kubebuddy/blob/main/netlify.toml"
    click Overrides "https://github.com/kubedeckio/kubebuddy/tree/main/overrides/"
    click DockerBuild "https://github.com/kubedeckio/kubebuddy/blob/main/.github/workflows/docker-build.yml"
    click PublishPS "https://github.com/kubedeckio/kubebuddy/blob/main/.github/workflows/publish-psgal.yml"
    click Pages "https://github.com/kubedeckio/kubebuddy/blob/main/.github/workflows/pages.yml"
    click ScriptAnalyzer "https://github.com/kubedeckio/kubebuddy/blob/main/.github/workflows/PSScriptAnalyzer.yaml"
    click Codespell "https://github.com/kubedeckio/kubebuddy/blob/main/.github/workflows/codespell.yml"
    click PRBot "https://github.com/kubedeckio/kubebuddy/blob/main/.github/workflows/pr-bot-welcome.yaml"

    %% Styles
    classDef user fill:#D0E6A5,stroke:#333,stroke-width:1px
    classDef frontend fill:#A0D2DB,stroke:#333,stroke-width:1px
    classDef core fill:#C3E8AC,stroke:#333,stroke-width:1px
    classDef external fill:#F7B267,stroke:#333,stroke-width:1px
    classDef ci fill:#CCCCCC,stroke:#333,stroke-width:1px
```
