Skip to main content
Glama

ako_ingress_diagnose

Read-onlyIdempotent

Identify why an Ingress lacks a corresponding Virtual Service by examining annotations, TLS configuration, service endpoints, and AKO logs for errors.

Instructions

[READ] Diagnose why a specific Ingress has no corresponding Virtual Service.

Checks annotations, TLS config, service endpoints, and AKO logs for errors.

Args: name: Ingress resource name. namespace: K8s namespace (default 'default'). context: K8s context name (optional).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
namespaceNodefault
contextNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function `diagnose_ingress()` that executes the ingress diagnosis logic: fetches the Ingress resource, checks annotations, IngressClass, TLS secrets, and backend service endpoints, then prints issues and suggestions.
    def diagnose_ingress(
        name: str, namespace: str = "default", context: str | None = None
    ) -> None:
        """Deep diagnosis of a specific Ingress."""
        cfg = load_config()
        k8s = K8sConnectionManager(cfg)
    
        from kubernetes.client import NetworkingV1Api
    
        net_v1 = NetworkingV1Api(k8s.get_client(context))
    
        try:
            ing = net_v1.read_namespaced_ingress(name, namespace)
        except Exception:
            console.print(f"[red]Ingress '{name}' not found in namespace '{namespace}'.[/red]")
            raise SystemExit(1)
    
        console.print(f"\n[bold]Diagnosing Ingress: {namespace}/{name}[/bold]\n")
    
        annotations = ing.metadata.annotations or {}
        console.print("[bold]Annotations:[/bold]")
        for k, v in annotations.items():
            console.print(f"  {k}: {v}")
    
        issues: list[str] = []
        suggestions: list[str] = []
    
        # Check IngressClass
        ingress_class = ing.spec.ingress_class_name or annotations.get(
            "kubernetes.io/ingress.class", ""
        )
        if not ingress_class:
            issues.append("No IngressClass specified")
            suggestions.append("Add spec.ingressClassName: 'avi-lb' or annotation kubernetes.io/ingress.class: 'avi'")
        elif ingress_class not in ("avi", "avi-lb"):
            issues.append(f"IngressClass '{ingress_class}' is not AKO")
            suggestions.append(f"Change to 'avi' or 'avi-lb'")
    
        # Check TLS secrets
        if ing.spec.tls:
            for tls in ing.spec.tls:
                if tls.secret_name:
                    try:
                        k8s.core_v1(context).read_namespaced_secret(tls.secret_name, namespace)
                    except Exception as exc:
                        err_msg = str(exc)
                        if "404" in err_msg or "Not Found" in err_msg:
                            issues.append(f"TLS secret '{tls.secret_name}' missing")
                            suggestions.append(f"Create secret: kubectl create secret tls {tls.secret_name} ...")
                        else:
                            issues.append(f"TLS secret '{tls.secret_name}' check failed: {err_msg[:100]}")
    
        # Check backend services exist
        if ing.spec.rules:
            for rule in ing.spec.rules:
                if rule.http and rule.http.paths:
                    for path in rule.http.paths:
                        if not path.backend or not path.backend.service or not path.backend.service.name:
                            issues.append("Path has no backend service configured")
                            continue
                        svc_name = path.backend.service.name
                        try:
                            k8s.core_v1(context).read_namespaced_service(svc_name, namespace)
                        except Exception:
                            issues.append(f"Backend service '{svc_name}' not found")
                            suggestions.append(f"Verify service '{svc_name}' exists in namespace '{namespace}'")
    
        if issues:
            console.print(f"\n[red]Issues Found ({len(issues)}):[/red]")
            for i, issue in enumerate(issues, 1):
                console.print(f"  {i}. {issue}")
            console.print(f"\n[yellow]Suggestions:[/yellow]")
            for i, sug in enumerate(suggestions, 1):
                console.print(f"  {i}. {sug}")
        else:
            console.print("\n[green]No issues found with Ingress configuration.[/green]")
            console.print("If VS is still not created, check AKO logs and sync status:")
            console.print("  vmware-avi ako logs --since 5m")
            console.print("  vmware-avi ako sync status")
        console.print()
  • MCP tool definition with input schema: parameters `name` (str, required), `namespace` (str, default 'default'), `context` (str, optional). Decorated with @mcp.tool and @vmware_tool(risk_level='low').
    @mcp.tool(annotations={"readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True})
    @vmware_tool(risk_level="low")
    def ako_ingress_diagnose(name: str, namespace: str = "default", context: str | None = None) -> str:
        """[READ] Diagnose why a specific Ingress has no corresponding Virtual Service.
    
        Checks annotations, TLS config, service endpoints, and AKO logs for errors.
    
        Args:
            name: Ingress resource name.
            namespace: K8s namespace (default 'default').
            context: K8s context name (optional).
        """
        from vmware_avi.ops.ako_ingress import diagnose_ingress
        return _capture_output(diagnose_ingress, name, namespace, context)
  • Tool registered via @mcp.tool decorator on the `ako_ingress_diagnose` function in the MCP server.
    @mcp.tool(annotations={"readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True})
    @vmware_tool(risk_level="low")
    def ako_ingress_diagnose(name: str, namespace: str = "default", context: str | None = None) -> str:
        """[READ] Diagnose why a specific Ingress has no corresponding Virtual Service.
    
        Checks annotations, TLS config, service endpoints, and AKO logs for errors.
    
        Args:
            name: Ingress resource name.
            namespace: K8s namespace (default 'default').
            context: K8s context name (optional).
        """
        from vmware_avi.ops.ako_ingress import diagnose_ingress
        return _capture_output(diagnose_ingress, name, namespace, context)
  • The `_capture_output()` helper captures Rich console output from the handler function and returns it as a string for MCP response.
    def _capture_output(func, *args, **kwargs) -> str:
        """Run a function and capture its Rich console output as plain text."""
        import importlib  # noqa: F401 — used via sys.modules lookup
        import sys
    
        buf = StringIO()
        from rich.console import Console
        capture_console = Console(file=buf, force_terminal=False, width=120)
    
        mod_name = func.__module__
        mod = sys.modules.get(mod_name)
        original_console = getattr(mod, "console", None) if mod else None
    
        if mod and original_console is not None:
            mod.console = capture_console
    
        try:
            func(*args, **kwargs)
        except SystemExit:
            pass
        finally:
            if mod and original_console is not None:
                mod.console = original_console
    
        return buf.getvalue()
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare read-only and non-destructive behavior. The description adds specific checks (annotations, TLS, service endpoints, AKO logs), providing beyond-annotation context. No contradictions found.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise: a purpose line followed by a clear bullet list of arguments. No extraneous text; every sentence holds value. Information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the diagnostic scope and parameters. An output schema exists (not shown), so the absence of return value details is acceptable. It could mention limitations (e.g., only for missing VS), but overall adequate given sibling tools cover other scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates by explaining each parameter's purpose (name as Ingress resource name, namespace with default, context as optional K8s context). This adds value beyond the schema titles.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool diagnoses why an Ingress has no corresponding Virtual Service. It specifies the exact problem and lists checks (annotations, TLS, service endpoints, AKO logs), making it distinct from sibling tools like ako_ingress_check or ako_ingress_fix_suggest.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for diagnosing missing Virtual Services but does not explicitly state when to use it over alternatives. No exclusions or comparisons with siblings are provided, leaving the agent to infer context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zw008/VMware-AVI'

If you have feedback or need assistance with the MCP directory API, please join our Discord server