# stanleytho/support-tools architecture

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

- Interactive diagram: https://gitdiagram.com/stanleytho/support-tools
- Repository: https://github.com/stanleytho/support-tools

## Overview

##### Project type and purpose
- This is an open-source “support-tools” monorepo for Rancher clusters. It bundles multiple independent scripts, Dockerized utilities, Helm charts and YAML manifests used for collecting data, troubleshooting, maintenance (cleanup, rotation), and cluster-level diagnostics.
- Its primary use case is to equip Rancher Support engineers (or any operator) with repeatable, scriptable workflows to diagnose, collect logs, inspect etcd, rotate tokens, clean up resources, and deploy lightweight helper workloads via Helm or static manifests.

##### File structure
- Top-level directories:
- collection – non-mutating scripts to gather cluster/node information and logs
- files – static payloads (curl-format.txt, etc.) used by scripts
- charts – Helm charts (rancher-support utilities as pods in-cluster)
- troubleshooting-scripts – targeted checks for etcd, kube-apiserver, scheduler, leader election
- dozens of standalone tool folders (e.g., bad-ingress-scanner, rotate-tokens, etc.) each containing a small shell script or Dockerfile plus readme
- Other artifacts:
- _config.yml, .drone.yml – CI/CD config
- Dockerfiles and run.sh wrappers – indicate containerized execution for many modules
- example-deployment.yml – pattern for deploying scripts as jobs or DaemonSets

##### README for additional insights
- Confirms two high-level categories: “collection” (non-destructive) and “files” (shared assets).
- Implies that most other directories are “mutating” or “maintenance” tools that should be used cautiously.

a. Main components:
- Operator Workstation (CLI) – where shell scripts or Helm CLI are run
- Container Registry – hosts images built via Dockerfiles in each tool’s folder
- Kubernetes Cluster(s) – target clusters under support, running Rancher
– Rancher Server API
– etcd Cluster
– Kube-API Server, Scheduler, Controller Manager
- Helm Tiller/Helm-v3 client – for deploying charts from /charts
- Support-Tool Pods (deployments/Jobs) – containers from charts or manual YAMLs
- Local file assets – “files/” used by scripts

b. Relationships and interactions:
- Operator triggers script or helm install from Workstation →
– local scripts call kubectl / helm / curl against Kubernetes API or Rancher API
- Kubernetes API → schedules Support-Tool Pods (via Job/Deployment) → these pods mount ConfigMaps/Secrets (from templates) → collect data or perform tasks → write results to stdout or to mounted volume
- Scripts with Dockerfiles: Operator builds image → pushes to registry → scripts deploy containers via run.sh or provided YAML → interact with cluster
- troubleshooting-scripts run either on operator node (local) or as pods, invoking cluster-internal endpoints

c. Architectural patterns / design principles:
- Modular tool-per-folder pattern: each script is its own micro-utility
- Separation between “collection” (read-only) vs “mutating” tools
- Infrastructure-as-code: manifests and Helm charts describe in-cluster components
- Containerization for consistency across environments

d. Key technologies:
- Kubernetes (Jobs/Deployments, ConfigMaps, ServiceAccounts)
- Helm (charts in /charts)
- Shell scripting (bash, sh), PowerShell for Windows collectors
- Docker (for containerizing tools)
- Rancher API / kubectl / etcdctl / curl / jq

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Operator Workstation Layer
    subgraph "Operator Workstation" 
        direction TB
        WS_CLI("Shell & PowerShell CLI"):::cli
        WS_CLI -->|runs| Collection["Collection Scripts"]:::script
        WS_CLI -->|runs| Troubleshoot["Troubleshooting Scripts"]:::script
        WS_CLI -->|runs| Maintenance["Mutating/Maintenance Tools"]:::script
        Collection -->|"uses assets"| Assets["files/"]:::asset
    end

    %% Local Shared Assets
    Assets -->|"includes"| CurlFmt["curl-format.txt"]:::asset

    %% Container Registry
    Registry["Container Registry"]:::registry

    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        direction TB
        subgraph "Control Plane"
            direction TB
            RancherAPI["Rancher Server API"]:::api
            Etcd["etcd Cluster"]:::db
            KubeAPI["Kube-API Server"]:::api
            Scheduler["Scheduler"]:::api
            ControllerMgr["Controller Manager"]:::api
            RancherAPI --> Etcd
            KubeAPI --> Scheduler
            KubeAPI --> ControllerMgr
        end
        subgraph "Support-Tool Workloads"
            direction TB
            HelmClient["Helm Client"]:::tools
            HelmClient -->|"deploy charts"| HelmCharts["charts/"]:::chart
            HelmCharts --> SupportPods["Support-Tool Pods (Jobs/Deployments)"]:::pod
            SupportPods -->|"mounts ConfigMaps/Secrets"| Configs["ConfigMaps/Secrets"]:::config
            SupportPods -->|"writes data"| PVC["PVC/Volume"]:::storage
        end
    end

    %% CI/CD and Examples
    subgraph "CI/CD & Docs"
        direction TB
        Drone[".drone.yml"]:::ci
        ConfigYml["_config.yml"]:::ci
        GitIgnore[".gitignore"]:::ci
        README["README.md"]:::doc
    end

    %% Flows
    WS_CLI --> Registry
    Registry --> SupportPods
    WS_CLI -->|kubectl/helm/curl| KubeAPI
    SupportPods -->|results| WS_CLI

    %% Click Events for Collection Scripts
    click Collection "https://github.com/stanleytho/support-tools/tree/master/collection/"
    click Assets "https://github.com/stanleytho/support-tools/tree/master/files/"
    click CurlFmt "https://github.com/stanleytho/support-tools/blob/master/files/curl-format.txt"

    click Collection "https://github.com/stanleytho/support-tools/blob/master/collection/rancher/v1.6/logs-collector/rancher16_logs_collector.sh"
    click Collection "https://github.com/stanleytho/support-tools/blob/master/collection/rancher/v2.x/logs-collector/rancher2_logs_collector.sh"
    click Collection "https://github.com/stanleytho/support-tools/blob/master/collection/rancher/v2.x/rancher-pod-collector/rancher-pod-collector.sh"
    click Collection "https://github.com/stanleytho/support-tools/blob/master/collection/rancher/v2.x/windows-log-collector/win-log-collect.ps1"

    %% Click Events for Maintenance Tools
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/bad-ingress-scanner/check.sh"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/change-nodetemplate-owner/change-nodetemplate-owner.sh"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/rotate-tokens/rotate-tokens.sh"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/cleanup-evicted-pods/README.md"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/cleanup-evicted-pods/deploy.yaml"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/extended-rancher-2-cleanup/extended-cleanup-rancher2.sh"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/instant-fio-master/instant-fio-master.sh"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/rancher-single-tool/rancher-single-tool.sh"
    click Maintenance "https://github.com/stanleytho/support-tools/blob/master/kubecert/kubecert.sh"

    %% Click Events for Troubleshooting Scripts
    click Troubleshoot "https://github.com/stanleytho/support-tools/tree/master/troubleshooting-scripts/"
    click Troubleshoot "https://github.com/stanleytho/support-tools/blob/master/troubleshooting-scripts/etcd/check-endpoints.sh"
    click Troubleshoot "https://github.com/stanleytho/support-tools/blob/master/troubleshooting-scripts/kube-apiserver/responsiveness.sh"
    click Troubleshoot "https://github.com/stanleytho/support-tools/blob/master/troubleshooting-scripts/kube-apiserver/check_endpoints.sh"
    click Troubleshoot "https://github.com/stanleytho/support-tools/blob/master/troubleshooting-scripts/kube-scheduler/find-leader.sh"
    click Troubleshoot "https://github.com/stanleytho/support-tools/blob/master/troubleshooting-scripts/determine-leader/rancher2_determine_leader.sh"

    %% Click Events for Charts
    click HelmCharts "https://github.com/stanleytho/support-tools/tree/master/charts/"
    click HelmCharts "https://github.com/stanleytho/support-tools/blob/master/charts/systems-info/Chart.yaml"
    click HelmCharts "https://github.com/stanleytho/support-tools/tree/master/charts/systems-info/templates/"
    click HelmCharts "https://github.com/stanleytho/support-tools/blob/master/charts/systems-information/Chart.yaml"
    click HelmCharts "https://github.com/stanleytho/support-tools/tree/master/charts/systems-information/templates/"
    click HelmCharts "https://github.com/stanleytho/support-tools/blob/master/charts/index.yaml"

    %% Click Events for Containerized Utilities
    click Registry "https://github.com/stanleytho/support-tools/tree/master/bad-ingress-scanner/Dockerfile"
    click Registry "https://github.com/stanleytho/support-tools/blob/master/bad-ingress-scanner/run.sh"
    click Registry "https://github.com/stanleytho/support-tools/tree/master/change-nodetemplate-owner/Dockerfile"
    click Registry "https://github.com/stanleytho/support-tools/tree/master/etcd-tools/Dockerfile"
    click Registry "https://github.com/stanleytho/support-tools/blob/master/etcd-tools/etcd-join.sh"
    click Registry "https://github.com/stanleytho/support-tools/blob/master/etcd-tools/restore-etcd-single.sh"
    click Registry "https://github.com/stanleytho/support-tools/tree/master/collection/rancher/v2.x/systems-information/Dockerfile"
    click Registry "https://github.com/stanleytho/support-tools/blob/master/collection/rancher/v2.x/systems-information/run.sh"
    click Registry "https://github.com/stanleytho/support-tools/tree/master/rancher-metadata-syncer/Dockerfile"
    click Registry "https://github.com/stanleytho/support-tools/blob/master/rancher-metadata-syncer/run.sh"
    click Registry "https://github.com/stanleytho/support-tools/blob/master/cluster-agent-tool/cluster-agent-tool.sh"

    %% Click Events for Examples & Manifests
    click CI "https://github.com/stanleytho/support-tools/blob/master/NGINX-to-pods-check/example-deployment.yml"
    click CI "https://github.com/stanleytho/support-tools/blob/master/bad-ingress-scanner/deployment.yaml"
    click CI "https://github.com/stanleytho/support-tools/blob/master/cleanup-etcd-part-files/delete-part-files.yaml"
    click CI "https://github.com/stanleytho/support-tools/blob/master/cleanup-etcd-part-files/alt-s3-sync.yaml"
    click CI "https://github.com/stanleytho/support-tools/blob/master/rancher-metadata-syncer/deployment-configmap.yaml"
    click CI "https://github.com/stanleytho/support-tools/blob/master/rancher-metadata-syncer/deployment-proxy.yaml"
    click CI "https://github.com/stanleytho/support-tools/blob/master/swiss-army-knife/admin-tools.yaml"
    click CI "https://github.com/stanleytho/support-tools/blob/master/swiss-army-knife/overlaytest.yaml"

    %% Click Events for CI/CD & Docs
    click Drone "https://github.com/stanleytho/support-tools/blob/master/.drone.yml"
    click ConfigYml "https://github.com/stanleytho/support-tools/blob/master/_config.yml"
    click GitIgnore "https://github.com/stanleytho/support-tools/blob/master/.gitignore"
    click README "https://github.com/stanleytho/support-tools/blob/master/README.md"

    %% Styles
    classDef cli fill:#f9f,stroke:#333,stroke-width:1px;
    classDef script fill:#ff9,stroke:#333,stroke-width:1px;
    classDef asset fill:#9ff,stroke:#333,stroke-width:1px;
    classDef registry fill:#ccf,stroke:#333,stroke-width:1px;
    classDef api fill:#cfc,stroke:#333,stroke-width:1px;
    classDef db fill:#fcf,stroke:#333,stroke-width:1px;
    classDef tools fill:#ffc,stroke:#333,stroke-width:1px;
    classDef chart fill:#cff,stroke:#333,stroke-width:1px;
    classDef pod fill:#fce,stroke:#333,stroke-width:1px;
    classDef config fill:#efe,stroke:#333,stroke-width:1px;
    classDef storage fill:#eed,stroke:#333,stroke-width:1px;
    classDef ci fill:#ddd,stroke:#333,stroke-width:1px;
    classDef doc fill:#ddd,stroke:#333,stroke-width:1px;
```
