diff --git a/docs/data-sources/builtin-toolsets/.nav.yml b/docs/data-sources/builtin-toolsets/.nav.yml index 2950406808..4b717ae18a 100644 --- a/docs/data-sources/builtin-toolsets/.nav.yml +++ b/docs/data-sources/builtin-toolsets/.nav.yml @@ -23,6 +23,7 @@ nav: - Internet: internet.md - Kafka: kafka.md - Kubernetes: kubernetes.md + - KubeVela: kubevela.md - MariaDB (MCP): mariadb-mcp.md - MongoDB Atlas: mongodb-atlas.md - New Relic: newrelic.md diff --git a/docs/data-sources/builtin-toolsets/index.md b/docs/data-sources/builtin-toolsets/index.md index 6179a0f5e0..a325ae0ba6 100644 --- a/docs/data-sources/builtin-toolsets/index.md +++ b/docs/data-sources/builtin-toolsets/index.md @@ -27,6 +27,7 @@ HolmesGPT includes pre-built integrations for popular monitoring and observabili - [:material-web:{ .lg .middle } **Internet**](internet.md) - [:simple-apachekafka:{ .lg .middle } **Kafka**](kafka.md) - [:simple-kubernetes:{ .lg .middle } **Kubernetes**](kubernetes.md) +- [:simple-kubernetes:{ .lg .middle } **KubeVela**](kubevela.md) - [:simple-kubernetes:{ .lg .middle } **Kubectl Run**](kubectl-run.md) - [:simple-grafana:{ .lg .middle } **Loki**](grafanaloki.md) - [:simple-mariadb:{ .lg .middle } **MariaDB (MCP)**](mariadb-mcp.md) diff --git a/docs/data-sources/builtin-toolsets/kubevela.md b/docs/data-sources/builtin-toolsets/kubevela.md new file mode 100644 index 0000000000..6618e7bc35 --- /dev/null +++ b/docs/data-sources/builtin-toolsets/kubevela.md @@ -0,0 +1,56 @@ +# KubeVela + +This toolset provides access to KubeVela CLI commands for managing and troubleshooting applications built on the Open Application Model (OAM). + +## Prerequisites + +The KubeVela CLI (`vela`) must be installed and configured to access your cluster. + +**Installation:** + +```bash +# Install vela CLI +curl -fsSl https://kubevela.io/script/install.sh | bash + +# Verify installation +vela version +``` + +## Configuration + +=== "Holmes CLI" + + Add the following to **~/.holmes/config.yaml**: + + + ```yaml + toolsets: + kubevela/core: + enabled: true + ``` + + --8<-- "snippets/toolset_refresh_warning.md" + + To test, run: + + ```bash + holmes ask "What is the status of my KubeVela applications?" + ``` + +## Common Use Cases + +```bash +holmes ask "What KubeVela applications are unhealthy and why?" +``` + +```bash +holmes ask "Show me the workflow status for my payment-service application" +``` + +```bash +holmes ask "What components does my frontend application have and are they running correctly?" +``` + +```bash +holmes ask "Check if there are any trait configuration issues in the user-api application" +``` diff --git a/holmes/plugins/toolsets/kubevela.yaml b/holmes/plugins/toolsets/kubevela.yaml new file mode 100644 index 0000000000..b629ee4835 --- /dev/null +++ b/holmes/plugins/toolsets/kubevela.yaml @@ -0,0 +1,98 @@ +toolsets: + kubevela/core: + description: "Set of tools to inspect KubeVela applications, components, and workflows" + docs_url: "https://holmesgpt.dev/data-sources/builtin-toolsets/kubevela/" + icon_url: "https://kubevela.io/img/logo.svg" + llm_instructions: | + You have access to a set of KubeVela tools for debugging cloud-native application deployments. + KubeVela is an application delivery platform that abstracts Kubernetes complexity using the Open Application Model (OAM). + + IMPORTANT: If you are asked about application health or deployment issues, ALWAYS check: + 1. The application status and health + 2. Component statuses within the application + 3. Workflow execution status if the app uses workflows + 4. Trait configurations (ingress, autoscaling, etc.) + + These tools help you investigate issues with KubeVela-managed applications in your Kubernetes clusters. + In addition to the general investigation steps, ALWAYS follow these steps: + 1. List applications to find the app in question + 2. Get detailed application status including components and traits + 3. Check workflow status if applicable + 4. Inspect component definitions to understand what resources are created + 5. Compare KubeVela application state with actual Kubernetes resources + 6. Check for misconfigurations in traits or policies + + {% if tool_names|list|length > 0 %} + The following commands are available to introspect KubeVela: {{ ", ".join(tool_names) }} + {% endif %} + + ALWAYS investigate the actual Kubernetes resources created by KubeVela to provide complete diagnostics. + DO NOT tell the user to check configurations without being specific - investigate on their behalf and provide actionable solutions. + tags: + - core + prerequisites: + - command: "vela version" + tools: + - name: "vela_app_list" + description: "List all KubeVela applications across namespaces or in a specific namespace" + command: "vela ls{% if namespace %} -n {{ namespace }}{% else %} -A{% endif %}" + + - name: "vela_app_status" + description: "Get detailed status of a KubeVela application including components, traits, and health" + command: "vela status {{ app_name }} -n {{ namespace }}" + + - name: "vela_app_show" + description: "Show the application specification and configuration" + command: "kubectl get application {{ app_name }} -n {{ namespace }} -o yaml" + + - name: "vela_logs" + description: "Get logs from a KubeVela application or specific component" + command: "vela logs {{ app_name }} -n {{ namespace }}{% if component %} -c {{ component }}{% endif %}{% if pod %} --pod {{ pod }}{% endif %} --tail {{ tail | default(500) }} -y" + + - name: "vela_port_forward" + description: "Check port-forward capability for debugging (informational only, doesn't create actual port-forward)" + command: "echo 'Port-forward available with: vela port-forward {{ app_name }} -n {{ namespace }}{% if port %} {{ port }}{% endif %}'" + + - name: "vela_component_list" + description: "List available component definitions in the cluster" + command: "vela components" + + - name: "vela_trait_list" + description: "List available trait definitions (like ingress, autoscaling, etc.)" + command: "vela traits" + + - name: "vela_workflow_list" + description: "List workflow definitions available in the cluster" + command: "vela workflow list" + + - name: "vela_workflow_status" + description: "Get the status of a workflow execution for an application" + command: "vela workflow status {{ app_name }} -n {{ namespace }}" + + - name: "vela_workflow_logs" + description: "Get logs from a workflow execution" + command: "vela workflow logs {{ app_name }} -n {{ namespace }} --tail {{ tail | default(500) }} -y" + + - name: "vela_addon_list" + description: "List installed KubeVela addons" + command: "vela addon list" + + - name: "vela_addon_status" + description: "Get detailed status of a specific addon" + command: "vela addon status {{ addon_name }}" + + - name: "vela_definition_show" + description: "Show details of a component, trait, or workflow definition" + command: "vela def get {{ definition_name }}{% if type %} --type {{ type }}{% endif %}" + + - name: "vela_top" + description: "Show resource usage (CPU/Memory) for application pods" + command: "kubectl top pods -l app.oam.dev/name={{ app_name }} -n {{ namespace }}" + + - name: "vela_dry_run" + description: "Preview the Kubernetes resources that would be created by an application spec" + command: "vela dry-run -f {{ file_path }}" + + - name: "vela_live_diff" + description: "Show difference between local spec and running application" + command: "vela live-diff -f {{ file_path }} -n {{ namespace }}" diff --git a/tests/llm/fixtures/test_ask_holmes/212_kubevela_app_diagnosis/test_case.yaml b/tests/llm/fixtures/test_ask_holmes/212_kubevela_app_diagnosis/test_case.yaml new file mode 100644 index 0000000000..901b05a820 --- /dev/null +++ b/tests/llm/fixtures/test_ask_holmes/212_kubevela_app_diagnosis/test_case.yaml @@ -0,0 +1,122 @@ +# Test that Holmes can diagnose KubeVela application deployment issues +user_prompt: "My payment-service application in the app-212 namespace is not working properly. What's wrong with it and what components does it have?" + +expected_output: + - "Must identify that the payment-service application exists" + - "Must report that the application has an 'Unhealthy' or failed status" + - "Must mention the webservice component" + - "Must identify the issue with the container image (using nonexistent-image tag)" + +tags: + - question-answer + - kubernetes + +include_tool_calls: true + +before_test: | + set -e + + NAMESPACE="app-212" + APP_NAME="payment-service" + + echo "Creating namespace $NAMESPACE..." + kubectl create namespace $NAMESPACE || true + + echo "" + echo "Installing KubeVela core..." + # Check if vela-system namespace exists + if ! kubectl get namespace vela-system >/dev/null 2>&1; then + echo "Installing KubeVela..." + vela install --version v1.10.4 + else + echo "KubeVela already installed" + fi + + echo "" + echo "Waiting for KubeVela controller to be ready..." + kubectl wait --for=condition=available --timeout=120s deployment/vela-core -n vela-system + + echo "" + echo "Creating a KubeVela application with an issue..." + cat </dev/null 2>&1; then + echo "Application resource created" + APP_CREATED=true + break + fi + echo "Attempt $i/30: Waiting for application to be created..." + sleep 2 + done + + if [ "$APP_CREATED" = false ]; then + echo "Application failed to be created after 60 seconds" + echo "" + echo "=== KubeVela controller logs (last 50 lines) ===" + kubectl logs -n vela-system -l app.kubernetes.io/name=vela-core --tail=50 || echo "No controller logs found" + exit 1 + fi + + echo "" + echo "Verifying application is accessible via vela CLI..." + VELA_APP_VISIBLE=false + for i in {1..30}; do + if vela ls -n $NAMESPACE 2>&1 | grep -q "$APP_NAME"; then + echo "Application visible via vela CLI" + VELA_APP_VISIBLE=true + break + fi + echo "Attempt $i/30: Waiting for app to be visible in vela ls..." + sleep 2 + done + + if [ "$VELA_APP_VISIBLE" = false ]; then + echo "Application not visible in vela ls after 60 seconds" + echo "" + echo "=== Application status ===" + kubectl get application $APP_NAME -n $NAMESPACE -o yaml || true + echo "" + echo "=== vela ls output ===" + vela ls -n $NAMESPACE || true + exit 1 + fi + + echo "" + echo "Application status:" + vela status $APP_NAME -n $NAMESPACE || true + + echo "" + echo "Test setup completed - application deployed with intentional issue" + +after_test: | + kubectl delete application payment-service -n app-212 || true + kubectl delete namespace app-212 || true diff --git a/tests/llm/fixtures/test_ask_holmes/212_kubevela_app_diagnosis/toolsets.yaml b/tests/llm/fixtures/test_ask_holmes/212_kubevela_app_diagnosis/toolsets.yaml new file mode 100644 index 0000000000..3d671e633d --- /dev/null +++ b/tests/llm/fixtures/test_ask_holmes/212_kubevela_app_diagnosis/toolsets.yaml @@ -0,0 +1,5 @@ +toolsets: + kubevela/core: + enabled: true + kubernetes/core: + enabled: true