Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ HolmesGPT integrates with popular observability and cloud platforms. The followi
| [<img src="images/integration_logos/kafka_logo.png" alt="Kafka" width="20" style="vertical-align: middle;"> **Kafka**](https://holmesgpt.dev/data-sources/builtin-toolsets/kafka/) | Fetch metadata, list consumers and topics or find lagging consumer groups |
| [<img src="images/integration_logos/kubernetes-icon.png" alt="Kubernetes" width="20" style="vertical-align: middle;"> **Kubernetes**](https://holmesgpt.dev/data-sources/builtin-toolsets/kubernetes/) | Pod logs, K8s events, and resource status (kubectl describe) |
| [<img src="images/integration_logos/kubernetes-icon.png" alt="Kubernetes Remediation" width="20" style="vertical-align: middle;"> **Kubernetes Remediation (MCP)**](https://holmesgpt.dev/data-sources/builtin-toolsets/kubernetes-remediation-mcp/) | Apply fixes like scaling, rollbacks, and resource edits (MCP) |
| [<img src="images/integration_logos/kyverno-icon.png" alt="Kyverno" width="20" style="vertical-align: middle;"> **Kyverno**](https://holmesgpt.dev/data-sources/builtin-toolsets/kyverno/) | Troubleshoot Kyverno policy violations, admission webhook failures, and policy reports |
| [<img src="images/integration_logos/grafana_loki-icon.png" alt="Loki" width="20" style="vertical-align: middle;"> **Loki**](https://holmesgpt.dev/data-sources/builtin-toolsets/grafanaloki/) | Query logs for Kubernetes resources or any query |
| [<img src="images/integration_logos/postgres-icon.png" alt="MariaDB" width="20" style="vertical-align: middle;"> **MariaDB**](https://holmesgpt.dev/data-sources/builtin-toolsets/mariadb-mcp/) | MariaDB database queries and diagnostics (MCP) |
| [<img src="images/integration_logos/postgres-icon.png" alt="MongoDB" width="20" style="vertical-align: middle;"> **MongoDB**](https://holmesgpt.dev/data-sources/builtin-toolsets/mongodb/) | Query data, diagnose performance, inspect schemas, find slow operations |
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/builtin-toolsets/.nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ nav:
- Kubernetes: kubernetes.md
- Kubernetes Remediation (MCP): kubernetes-remediation-mcp.md
- KubeVela: kubevela.md
- Kyverno: kyverno.md
- MariaDB: database-mariadb.md
- MariaDB (MCP): mariadb-mcp.md
- MongoDB: mongodb.md
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/builtin-toolsets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ HolmesGPT includes pre-built integrations for popular monitoring and observabili
- [:material-package:{ .lg .middle } **Helm**](helm.md)
- [:simple-redhatopenshift:{ .lg .middle } **OpenShift**](openshift.md)
- [:simple-kubernetes:{ .lg .middle } **KubeVela**](kubevela.md)
- [:material-shield-check:{ .lg .middle } **Kyverno**](kyverno.md)
- [:simple-kubernetes:{ .lg .middle } **Kubectl Run**](kubectl-run.md)
- [:simple-argo:{ .lg .middle } **ArgoCD**](argocd.md)
- [:simple-cilium:{ .lg .middle } **Cilium**](cilium.md)
Expand Down
85 changes: 85 additions & 0 deletions docs/data-sources/builtin-toolsets/kyverno.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Kyverno

By enabling this toolset, HolmesGPT will be able to troubleshoot Kyverno policy engine issues, including policy violations, admission webhook failures, and background scan results.

## Prerequisites

Kyverno must be installed on your Kubernetes cluster. HolmesGPT uses `kubectl` to query Kyverno custom resources, so no additional CLI tools are required.

HolmesGPT needs read access to Kyverno CRDs. If you use Kubernetes RBAC, ensure the service account has permissions to `get` and `list` the following resources:

```yaml
# Add to your ClusterRole
- apiGroups: ["kyverno.io"]
resources: ["clusterpolicies", "policies"]
verbs: ["get", "list"]
- apiGroups: ["reports.kyverno.io", "wgpolicyk8s.io"]
resources: ["clusterpolicyreports", "policyreports"]
verbs: ["get", "list"]
- apiGroups: ["kyverno.io"]
resources: ["updaterequests", "clusterupdaterequests"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
```

## Configuration

=== "Holmes CLI"

Add the following to **~/.holmes/config.yaml**:

```yaml
toolsets:
kyverno/core:
enabled: true
```

--8<-- "snippets/toolset_refresh_warning.md"

To test, run:

```bash
holmes ask "Are there any Kyverno policy violations in my cluster?"
```

=== "Robusta Helm Chart"

```yaml
holmes:
customClusterRoleRules:
- apiGroups: ["kyverno.io"]
resources: ["clusterpolicies", "policies", "updaterequests", "clusterupdaterequests"]
verbs: ["get", "list"]
- apiGroups: ["reports.kyverno.io", "wgpolicyk8s.io"]
resources: ["clusterpolicyreports", "policyreports"]
verbs: ["get", "list"]
toolsets:
kyverno/core:
enabled: true
```

--8<-- "snippets/helm_upgrade_command.md"

## Common Use Cases

```bash
holmes ask "Are there any Kyverno policy violations in my cluster?"
```

```bash
holmes ask "Which resources are failing the require-labels policy?"
```

```bash
holmes ask "Why was my deployment blocked by Kyverno?"
```

```bash
holmes ask "Are there any failing UpdateRequests in Kyverno?"
```

```bash
holmes ask "Show me the Kyverno controller logs for recent errors"
```
2 changes: 1 addition & 1 deletion docs/why-holmesgpt.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ HolmesGPT ships with read-only integrations for every major observability vendor
- **Logs**: Loki, Elasticsearch/OpenSearch, Datadog, Coralogix, Splunk
- **Traces**: Tempo, Datadog, NewRelic
- **Dashboards**: Grafana
- **Infrastructure**: Kubernetes, Docker, Helm, ArgoCD, Crossplane, OpenShift, Cilium, KubeVela
- **Infrastructure**: Kubernetes, Docker, Helm, ArgoCD, Crossplane, Kyverno, OpenShift, Cilium, KubeVela
- **CI/CD**: Jenkins
- **Cloud**: AWS RDS, Azure SQL, Azure AKS, GCP
- **Databases**: PostgreSQL, MySQL, ClickHouse, MariaDB, SQL Server, MongoDB Atlas
Expand Down
98 changes: 98 additions & 0 deletions holmes/plugins/toolsets/kyverno.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
toolsets:
kyverno/core:
description: "Tools for troubleshooting Kyverno policy engine, policy violations, admission webhooks, and policy reports"
docs_url: "https://holmesgpt.dev/data-sources/builtin-toolsets/kyverno/"
icon_url: "https://raw.githubusercontent.com/kyverno/kyverno/main/img/logo.png"
llm_instructions: |
You have tools to debug Kyverno policy engine issues in Kubernetes clusters.
Kyverno enforces security and operational policies through admission webhooks (validate, mutate, generate) and background scans.
Policy results are recorded in PolicyReport (namespaced) and ClusterPolicyReport (cluster-scoped) resources.

ALWAYS follow this investigation order:
1. List ClusterPolicies and namespaced Policies to understand what rules are active and their failure action (Enforce vs Audit)
2. Check policy report summaries to identify namespaces or resources with violations:
- kyverno_list_policy_report_summaries shows fail/pass/warn counts per namespace
- kyverno_list_cluster_policy_report_summaries shows cluster-scoped violations
3. Dig into specific policy reports to get detailed violation messages and affected resource names
4. For generate/mutate-existing issues, check UpdateRequests for pending or failed operations
5. If controllers appear to be failing, check Kyverno controller logs for webhook timeouts or evaluation errors

Key concepts:
- Enforce mode: blocks non-compliant resources at admission (immediately visible to users as rejected requests)
- Audit mode: allows resources but records violations in PolicyReports (silent, for visibility only)
- Background scanning: periodically checks existing resources; results go into PolicyReports without blocking
- UpdateRequests: intermediary queue resources for generate and mutate-existing rules; Failed or Pending state indicates processing issues

{% if tool_names|list|length > 0 %}
The following Kyverno tools are available: {{ ", ".join(tool_names) }}
{% endif %}

DO NOT tell the user to check resources manually. Investigate on their behalf using the available tools and report findings with specific policy names, rule names, violation messages, and affected resource names.
tags:
- core
prerequisites:
- command: "kubectl api-resources --api-group=kyverno.io --no-headers 2>/dev/null | grep -q clusterpolicies"

tools:
- name: "kyverno_list_cluster_policies"
description: "List all ClusterPolicy resources with their rule counts, background scan status, and validation failure action (Enforce/Audit)"
command: "kubectl get clusterpolicies -o wide 2>&1"

- name: "kyverno_get_cluster_policy"
description: "Get the full specification of a ClusterPolicy including all rules, match conditions, exclude conditions, and failure action (Enforce/Audit)"
command: "kubectl get clusterpolicy {{ policy_name }} -o yaml 2>&1"

- name: "kyverno_list_policies"
description: "List namespaced Policy resources across all namespaces or in a specific namespace"
command: "kubectl get policies{% if namespace %} -n {{ namespace }}{% else %} -A{% endif %} -o wide 2>&1"

- name: "kyverno_get_policy"
description: "Get the full specification of a namespaced Policy including all rules and failure action"
command: "kubectl get policy {{ policy_name }} -n {{ namespace }} -o yaml 2>&1"

- name: "kyverno_list_policy_report_summaries"
description: "List PolicyReport summaries showing pass/fail/warn/error counts per namespace to identify namespaces with policy violations"
command: "kubectl get policyreports{% if namespace %} -n {{ namespace }}{% else %} -A{% endif %} 2>&1"

- name: "kyverno_get_policy_report"
description: "Get the full PolicyReport for a namespace including all individual rule results with violation messages and affected resource names"
command: "kubectl get policyreport -n {{ namespace }} -o yaml 2>&1"

- name: "kyverno_list_cluster_policy_report_summaries"
description: "List ClusterPolicyReport summaries showing pass/fail/warn/error counts for cluster-scoped resource violations"
command: "kubectl get clusterpolicyreports 2>&1"

- name: "kyverno_get_cluster_policy_report"
description: "Get the full ClusterPolicyReport including all individual rule results with violation messages and affected cluster-scoped resource names"
command: "kubectl get clusterpolicyreport {{ report_name }} -o yaml 2>&1"

- name: "kyverno_list_update_requests"
description: "List UpdateRequests which queue work for Kyverno generate and mutate-existing rules; Failed or Pending state indicates processing issues with resource generation or mutation"
command: "kubectl get updaterequests{% if namespace %} -n {{ namespace }}{% else %} -A{% endif %} 2>&1"

- name: "kyverno_get_update_request"
description: "Get details of a specific UpdateRequest including its current state, retry count, and error message for diagnosing generate or mutate-existing rule failures"
command: "kubectl get updaterequest {{ request_name }} -n {{ namespace }} -o yaml 2>&1"

- name: "kyverno_controller_logs"
description: "Get logs from Kyverno admission, background, and reports controllers to diagnose webhook failures, policy evaluation errors, and background scan issues. The namespace parameter defaults to 'kyverno'."
script: |
#!/bin/bash
NS="{{ namespace | default('kyverno') }}"
TAIL="{{ tail | default(100) }}"
echo "=== Kyverno Admission Controller ==="
kubectl logs -n "$NS" -l app.kubernetes.io/component=admission-controller --tail="$TAIL" 2>/dev/null \
|| kubectl logs -n "$NS" -l app=kyverno --tail="$TAIL" 2>&1
echo ""
echo "=== Kyverno Background Controller ==="
kubectl logs -n "$NS" -l app.kubernetes.io/component=background-controller --tail="$TAIL" 2>/dev/null \
|| echo "(background-controller not found; cluster may use a legacy single-controller deployment)"
echo ""
echo "=== Kyverno Reports Controller ==="
kubectl logs -n "$NS" -l app.kubernetes.io/component=reports-controller --tail="$TAIL" 2>/dev/null \
|| echo "(reports-controller not found; cluster may use a legacy single-controller deployment)"
transformers:
- name: llm_summarize
config:
input_threshold: 5000
prompt: "Summarize the Kyverno controller logs focusing on policy violations, admission webhook failures, background scan errors, policy evaluation issues, and any panic or crash messages. Highlight the most critical errors."
Loading
Loading