Skip to content

feat: add the sre factory - #4

Merged
justinwilkin merged 7 commits into
mainfrom
feat/sre-factory
Oct 27, 2026
Merged

justinwilkin merged 7 commits into
mainfrom
feat/sre-factory

Conversation

@justinwilkin

@justinwilkin justinwilkin commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Adds factories/sre, a factory that triages Alertmanager alerts in the cluster, proposes fixes to the deploy repository and sweeps the cluster's costs with OpenCost.

Needs kora 0.11.0-rc.6, which carries runkora/kora#812.

Changes

  • factories/sre: The platform repository (tenant oncall, models, a read-only ClusterRole for the cluster connection) and the factory repository (cluster and GitHub connections, Alertmanager and GitHub sources, OpenCost MCP server, ops environment, sre role, three agents, six triggers).
    • incident-triage groups an alert storm into one run, inspects the cluster with kubectl, opens an incident issue and adds remediate when a manifest change fixes the cause. It closes the issue with a summary when the alert resolves.
    • remediator opens the fix as a pull request from the remediate label. Reviews and comments route back to it with a decision model, joining its open run.
    • cost-sweeper runs weekly against OpenCost's MCP server and files a cost issue with rightsizing recommendations.
    • demo/ is a deploy repository with a crash-looping checkout service.
  • Quickstart:
    • make example offers sre and checks its placeholders. It installs OpenCost without Prometheus, fills in the cluster connection's CA from the cluster and deploys demo/.
    • make alert posts a sample Alertmanager alert, and STATUS=resolved resolves it.
    • The egress gateway may reach the k3d API server on 6443.
    • glauth gains two oncall users.
  • Versions: kora 0.11.0-rc.6 and OpenCost chart 2.5.33.

Testing

  • All ten kustomizations build. A server-side dry run on the quickstart accepts every resource.
  • Ran the factory on the quickstart against a private deploy repository:
    • OpenCost's MCP server registered, and cost-sweeper filed a cost issue from its data.
    • make alert routed to incident-triage, which opened the incident issue.
    • remediator opened the fix from the remediate label in about a minute. A review routed back to its open run, and it pushed the requested change.
    • The org's branch ruleset blocked the factory's own merge.
    • The resolved alert closed the incident with a summary.
  • On rc.6, incident-triage read the cluster with kubectl through the gateway on 6443, found MODE: lvie in shop/checkout.yaml itself and added remediate. remediator then opened the fix.

Three agents triage Alertmanager alerts in the cluster through a read-only
kubernetes connection, propose fixes to the deploy repository and sweep the
cluster's costs weekly through OpenCost's MCP server.
make example installs OpenCost, fills in the cluster connection's CA and
deploys the broken checkout service. make alert posts a sample Alertmanager
alert. The egress gateway may reach the k3d API server on 6443.
rc.6 carries runkora/kora#812, which the sre factory's cluster connection
needs to reach an API server on 6443.
@justinwilkin
justinwilkin marked this pull request as ready for review October 27, 2026 05:22
make validate reads quickstart/manifests as Kubernetes manifests, and a helm
values file has no kind.
@runkora

runkora Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Visual Walkthrough

This pull request adds the SRE factory: triggers, agents and connections for alert triage, remediation and cost sweeps.

Factory wiring

Triggers route events to agents, and agents reach GitHub and the cluster through connections.

flowchart TB
    subgraph SRC["Event sources"]
        AM[Alertmanager]:::context
        GHW[GitHub webhook]:::context
    end
    subgraph FAC["Factory triggers and agents"]
        TRA[Alert triggers]:::added
        TRG[GitHub triggers]:::added
        SCH[Weekly schedule]:::added
        TRI[Incident triage]:::added
        REM[Remediator]:::added
        CST[Cost sweeper]:::added
    end
    subgraph CONN["Connections"]
        CLC[Cluster connection]:::added
        GHC[GitHub connection]:::added
    end
    K8S[Cluster API]:::context
    GHAPI[GitHub API]:::context
    AM --> TRA
    GHW --> TRG
    SCH --> CST
    TRA --> TRI
    TRG --> TRI
    TRG --> REM
    TRI --> CLC
    TRI --> GHC
    REM --> GHC
    CST --> GHC
    CLC --> K8S
    GHC --> GHAPI
    classDef added fill:#1f883d,stroke:#1a7f37,stroke-width:2px,color:#ffffff
    classDef changed fill:#bf8700,stroke:#9a6700,stroke-width:2px,color:#ffffff
    classDef removed fill:#cf222e,stroke:#a40e26,stroke-width:2px,stroke-dasharray:5,color:#ffffff
    classDef context fill:transparent,stroke:#8c959f,stroke-width:1px,stroke-dasharray:3,color:#8c959f
    linkStyle default stroke:#8c959f,stroke-width:2px
    style SRC fill:transparent,stroke:#8c959f
    style FAC fill:transparent,stroke:#8c959f
    style CONN fill:transparent,stroke:#8c959f
Loading

Legend: green = added, amber = changed, red = removed, dashed grey = context

Node Code Symbols
Alert triggers triage-alert.yaml triage-alert, resolve-alert
GitHub triggers remediate.yaml remediate, remediator-on-review, incident-comment
Weekly schedule sweep-weekly.yaml sweep-weekly
Incident triage incident-triage.yaml incident-triage
Remediator remediator.yaml remediator
Cost sweeper cost-sweeper.yaml cost-sweeper
Cluster connection cluster-connection.yaml cluster, cluster-reader
GitHub connection github-connection.yaml github, github-app
Alert to fix path

An alert opens an incident issue, and a remediate label hands the fix to the remediator. The pull request refs the incident, which stays open until the alert resolves.

sequenceDiagram
    participant AM as Alertmanager
    participant TT as Alert triggers
    participant TI as Incident triage
    participant K as Cluster API
    participant GH as GitHub
    participant RM as Remediator
    AM->>TT: alert firing
    TT->>TI: start or join run
    TI->>GH: search open incident issues
    alt issue already open
        TI->>GH: comment new evidence
    else no open issue
        TI->>K: read pods, logs, events
        K-->>TI: workload state
        TI->>GH: open incident issue
        opt fix in deploy repository
            TI->>GH: add remediate label
            GH->>RM: start remediate run
            RM->>GH: open pull request refs incident
        end
    end
Loading
Node Code Symbols
Alert triggers triage-alert.yaml triage-alert
Incident triage incident-triage.yaml incident-triage
Remediator remediator.yaml remediator
Cost sweep path

The weekly sweep reads OpenCost through a relay in the tenant namespace and files a cost issue.

flowchart TB
    SCH[Weekly schedule]:::added
    CST[Cost sweeper]:::added
    subgraph NS["Tenant namespace"]
        MCPS[OpenCost MCP server]:::added
        RLY[OpenCost relay]:::added
    end
    OC[OpenCost]:::context
    GHC[GitHub connection]:::added
    SCH --> CST
    CST --> MCPS
    MCPS -->|served by| RLY
    RLY --> OC
    CST --> GHC
    classDef added fill:#1f883d,stroke:#1a7f37,stroke-width:2px,color:#ffffff
    classDef changed fill:#bf8700,stroke:#9a6700,stroke-width:2px,color:#ffffff
    classDef removed fill:#cf222e,stroke:#a40e26,stroke-width:2px,stroke-dasharray:5,color:#ffffff
    classDef context fill:transparent,stroke:#8c959f,stroke-width:1px,stroke-dasharray:3,color:#8c959f
    linkStyle default stroke:#8c959f,stroke-width:2px
    style NS fill:transparent,stroke:#8c959f
Loading

Legend: green = added, amber = changed, red = removed, dashed grey = context

Node Code Symbols
Weekly schedule sweep-weekly.yaml sweep-weekly
Cost sweeper cost-sweeper.yaml cost-sweeper
OpenCost MCP server opencost-mcp.yaml opencost
OpenCost relay opencost-mcp.yaml opencost-mcp Deployment, Service
GitHub connection github-connection.yaml github

@runkora

runkora Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Visual Walkthrough

This pull request adds the SRE factory, which triages alerts, files incident and cost issues, and proposes fixes to the deploy repository.

Incident response loop

The factory triages a firing alert, records an incident issue, and hands a repository fix to the remediator. The remediator's pull request refs the incident, which stays open until the alert resolves.

sequenceDiagram
    participant AM as Alertmanager
    participant T as triage-alert trigger
    participant I as incident-triage agent
    participant C as cluster connection
    participant G as GitHub
    participant R as remediator agent
    AM->>T: alert firing
    T->>I: start triage run
    I->>C: read pods, logs and events
    C-->>I: cluster state
    alt agent reads a Secret
        I->>C: read Secret
        C-->>I: refused by cluster role
    end
    I->>G: open incident issue
    alt fix is in the repository
        I->>G: add remediate label
        G->>R: label starts fix run
        R->>G: open pull request refs incident
        G->>R: review starts fix run
    else no repository fix
        I->>G: issue states the cause
    end
    AM->>I: alert resolved
    I->>G: comment summary and close issue
Loading
Node Code Symbols
triage-alert trigger factory/triggers/triage-alert.yaml triage-alert, coalesce
incident-triage agent factory/agents/incident-triage.yaml incident-triage, connectors
cluster connection factory/shared/cluster-connection.yaml cluster, cluster-reader
remediator agent factory/agents/remediator.yaml remediator, connectors
Weekly cost sweep

A weekly cron run reads OpenCost data and files a cost issue that the remediator can act on. Its pull request fixes the cost issue when merged.

flowchart TB
    subgraph FAC["SRE factory"]
        SW["sweep-weekly trigger"]:::added
        CS["cost-sweeper agent"]:::added
        MCP["opencost MCP server"]:::added
        RELAY["opencost-mcp relay"]:::added
        RM["remediator agent"]:::changed
    end
    OC["OpenCost"]:::context
    ISS["cost issue in GitHub"]:::context
    PR["pull request in deploy repo"]:::context
    SW --> CS
    CS --> MCP
    MCP --> RELAY
    RELAY --> OC
    CS -->|opens cost issue| ISS
    ISS -->|remediate label| RM
    RM -->|opens pull request| PR
    style FAC fill:transparent,stroke:#8c959f
    classDef added fill:#1f883d,stroke:#1a7f37,stroke-width:2px,color:#ffffff
    classDef changed fill:#bf8700,stroke:#9a6700,stroke-width:2px,color:#ffffff
    classDef removed fill:#cf222e,stroke:#a40e26,stroke-width:2px,stroke-dasharray:5,color:#ffffff
    classDef context fill:transparent,stroke:#8c959f,stroke-width:1px,stroke-dasharray:3,color:#8c959f
    linkStyle default stroke:#8c959f,stroke-width:2px
Loading

Legend: green = added, amber = changed, red = removed, dashed grey = context

Node Code Symbols
sweep-weekly trigger factory/triggers/sweep-weekly.yaml sweep-weekly, cronExpression
cost-sweeper agent factory/agents/cost-sweeper.yaml cost-sweeper, mcpTools
opencost MCP server factory/shared/opencost-mcp.yaml opencost, endpoint
opencost-mcp relay factory/shared/opencost-mcp.yaml opencost-mcp, socat relay
remediator agent factory/agents/remediator.yaml remediator, connectors

@runkora runkora Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Walkthrough

The pull request adds an SRE factory with triage, remediation and cost-sweep agents, an oncall tenant and cluster access. It also wires the factory into the quickstart with OpenCost and new Dex users.

Severity Finding Location
medium Restrict who can fire the remediator factories/sre/factory/triggers/remediate.yaml:14
medium Narrow or document the cluster-wide ConfigMap and log read factories/sre/platform/cluster-access.yaml:18
nit Use the oncall tenant in the user table quickstart/manifests/dex/glauth.yaml:19
nit Check the other GitHub App placeholders too quickstart/Makefile:266

Review effort: High
Risk: Medium, new agents with cluster read and repository write
Coverage: 38 of 38 files reviewed

Where to focus

Area Why it needs a person
factories/sre/factory/triggers/ Decide who may trigger the remediator and how alert text reaches it.
factories/sre/platform/cluster-access.yaml Confirm cluster-wide ConfigMap and log reads are acceptable.
factories/sre/factory/agents/ Triage can label issues that start the remediator without a person.

Lower risk

Area Why
factories/sre/platform/models/ Model declarations; several are unused by the agents.
factories/sre/demo/ Demo workload with an intentional fault.
versions.mk Single version bump.
Changes by area
Area Files Change
factories/sre/factory 17 Agents, triggers and shared resources
factories/sre/platform 9 Cluster access, models, oncall tenant
factories/sre/demo 2 Demo shop workload
quickstart 7 Make targets, OpenCost values, Dex users
Root and docs 3 Makefile, README, versions
Checked

Manifest cross-references, quickstart secret names, Dex user IDs.

Comment thread quickstart/manifests/dex/glauth.yaml Resolved
Comment thread quickstart/Makefile Resolved
The remediator referenced the incident with Fixes, and merging the fix closed
it before resolve-alert could summarise it. Incidents now take Refs. Cost
issues keep Fixes.
@justinwilkin
justinwilkin merged commit fa5c631 into main Oct 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants