# K9s 🐶 Integration

Gonzo integrates seamlessly with [k9s](https://github.com/derailed/k9s) (via the k9s plugin framework) to provide real-time log analysis with visual charts, AI-powered pattern detection, and severity tracking — all in the same familiar terminal UI you already use for cluster management. Instead of just scrolling through text, you get instant insights into error spikes, word frequencies, and anomalies.

### Plugin Configuration

Add this to your `$XDG_CONFIG_HOME/k9s/plugins.yaml` file:

```yaml
plugins:
  gonzo:
    shortCut: Ctrl-L
    description: "Gonzo log analysis"
    scopes:
      - po
    command: sh
    background: false
    args:
      - -c
      - "kubectl logs -f --tail=0 $NAME -n $NAMESPACE --context $CONTEXT | gonzo"
```

> **Note for macOS users:** Although not required, defining `XDG_CONFIG_HOME=~/.config` is recommended to maintain consistency with Linux configuration practices.

### Usage

1. Launch k9s and navigate to pods (`:pods` or `:po`)
2. Select a pod
3. Press `Ctrl-L`
4. Gonzo opens with live log streaming and analysis

### Available k9s Variables

The following environment variables are available in k9s plugins:

* `$NAME` - Pod name
* `$NAMESPACE` - Pod namespace
* `$CONTEXT` - Current cluster context
* `$CLUSTER` - Cluster name

### Verify Plugin Location

Check where k9s expects your plugins file:

```bash
k9s info
```

Look for the `Plugins:` line in the output.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.controltheory.com/controltheory-documentation/gonzo-docs/integration-examples/container-environments/kubernetes/k9s-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
