Add Generic CRD Analyzer for Custom Resources#1606
Draft
AlexsJones with Copilot wants to merge 4 commits into
Draft
Add Generic CRD Analyzer for Custom Resources#1606AlexsJones with Copilot wants to merge 4 commits into
AlexsJones with Copilot wants to merge 4 commits into
Conversation
- Added CRDAnalyzerConfig types to pkg/common/types.go for configuration - Implemented CRD analyzer in pkg/analyzer/crd.go with support for: - Discovery of all installed CRDs via apiextensions API - Generic health checks based on common patterns (.status.conditions, .status.phase, etc.) - Configurable per-CRD health checks via YAML config - Detection of stuck resources (deletionTimestamp with finalizers) - Registered CRDAnalyzer in additionalAnalyzerMap - Added comprehensive unit tests in pkg/analyzer/crd_test.go - All tests passing Co-authored-by: AlexsJones <1235925+AlexsJones@users.noreply.github.com>
- Created comprehensive documentation in docs/CRD_ANALYZER.md - Added example configuration file in examples/crd_analyzer_config.yaml - Updated README.md to list the new customResourceAnalyzer - Documentation includes use cases for cert-manager, ArgoCD, Kafka, Prometheus - Added troubleshooting section and best practices Co-authored-by: AlexsJones <1235925+AlexsJones@users.noreply.github.com>
- Fixed analyzer name in README.md to use consistent 'CustomResource' name - Improved TestCRDAnalyzer_NilClientConfig to be more explicit about expected behavior - Added clear comments about what the test verifies Co-authored-by: AlexsJones <1235925+AlexsJones@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add generic CRD analyzer support for custom resources
Add Generic CRD Analyzer for Custom Resources
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📑 Description
Enables K8sGPT to analyze custom resources from any installed CRD without code changes. Discovers CRDs via apiextensions API and applies configurable health checks.
Implementation
Core Analyzer (
pkg/analyzer/crd.go, 330 lines)k8s.io/apiextensions-apiserverstatus.conditions→ flags Ready≠True, Failed=Truestatus.phase→ detects Failed/Errorstatus.health.status→ ArgoCD patternstatus.state→ state-based failuresConfiguration (
pkg/common/types.go)Usage
Testing
14 unit tests covering:
Documentation
docs/CRD_ANALYZER.md: Configuration reference, use cases (cert-manager, ArgoCD, Kafka, Prometheus), troubleshootingexamples/crd_analyzer_config.yaml: Ready-to-use templateREADME.md: Added CustomResource to analyzer list✅ Checks
ℹ Additional Information
Benefits:
No breaking changes. Analyzer is opt-in via filter.
Original prompt
This section details on the original issue you should resolve
<issue_title>[Feature]: Add Generic CRD Analyzer Support for Custom Resources</issue_title>
<issue_description>### Checklist
Is this feature request related to a problem?
Yes
Problem Description
K8sGPT currently supports:
However, there is no analyzer for arbitrary Custom Resource Definitions (CRDs) and their associated custom resources — a gap that limits observability and AI diagnostics for modern Kubernetes clusters relying heavily on CRDs (e.g., cert-manager, ArgoCD, Kafka, PrometheusOperator, etc.).
Solution Description
Introduce a generic CRD analyzer that:
apiextensions.k8s.io/v1) and inspects its OpenAPI v3 schema under.spec.versions[].schema.openAPIV3Schema..status.conditions.status.phase.status.health.status.metadata.deletionTimestamp+.metadata.finalizers🧩 Additionally, make the analyzer configurable via YAML/JSON, like:
Benefits
Expanded Diagnostic Coverage
Enables K8sGPT to analyze custom workloads built on CRDs (e.g., ArgoCD, cert-manager, Kafka) that are otherwise invisible to default analyzers.
Configurable and Extensible
Users can define how health should be checked for each CRD via YAML/JSON — no need to write Go code for every custom resource type.
Schema-Aware Logic
Avoids brittle assumptions by reading and interpreting each CRD’s OpenAPI schema to determine if fields like
.status.conditionsor.status.health.statusexist.Foundation for Future Per-CRD Enhancements
Creates a pluggable framework that can be extended to support more specific behaviors later (e.g., ArgoCD sync failures, cert-manager renewal issues).
Works Out-of-the-Box for Common Patterns
Supports common Kubernetes conventions (e.g.,
.status.conditions,.phase,.state) with safe fallbacks.Faster Insights Without Waiting for Maintainer Support
Users gain immediate visibility into their CRDs without waiting for built-in analyzers to be developed or released.
Easier Collaboration with Users
Since CRD behavior can be customized via config, users can share setups, iterate quickly, and tune without needing to understand the codebase.
Supports Operator and GitOps-Heavy Workloads
Especially valuable for clusters using Flux, ArgoCD, Prometheus, Kafka, and other CRD-heavy platforms.
Potential Drawbacks
Inconsistent CRD Patterns
Not all CRDs follow standard conventions like
.status.conditions, which can lead to diagnostic gaps. However, this can be addressed through user-supplied config specifying expected status paths and health fields.Risk of False Positives or Negatives
Generic checks may not align with CRD-specific logic, but the proposed config layer allows users to define expected conditions or values to minimize noise.
Performance Overhead in Large Clusters
CRD enumeration and analysis may increase runtime in clusters with many custom resources. Users can mitigate this by excluding CRDs via config.
Additional Information
I'm interested in contributing this analyzer and can help with:
pkg/analyzer.If there's a preferred abstraction, interface, or naming convention I should align with, please let me know.
Also, I wasn’t able to join the K8sGPT Slack workspace — the invite link in the README/docs appears to be expired. Is there an updated link or alternate way to connect with the community or maintainers? Sorry that I have to click both the check boxes to be able to submit...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.