You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KubeAI Chatbot supports three resource modification modes, controlled by the `MODIFY_RESOURCES` environment variable. The mode determines how the agent behaves when a task requires a `kubectl` command that creates, updates, or deletes Kubernetes resources.
4
+
5
+
> [!IMPORTANT]
6
+
> Regardless of the modification mode, the agent will **never** read or list Kubernetes Secrets. This restriction is hardcoded and cannot be overridden.
7
+
8
+
## Modes
9
+
10
+
### `none` — Read-Only (Default)
11
+
12
+
```yaml
13
+
env:
14
+
MODIFY_RESOURCES: "none"
15
+
```
16
+
17
+
The agent operates in **read-only mode**. It can freely execute read commands (`get`, `describe`, `logs`, `top`, `events`, etc.) but will never execute a write command through its tools.
18
+
19
+
When a task requires a resource modification, the agent will:
20
+
21
+
1. Gather the necessary context using read-only tools.
22
+
2. Provide the exact `kubectl` command(s) the user should run manually.
23
+
3. Explain what each command does and why.
24
+
25
+
**Best for**: Teams that want AI-assisted diagnostics and guidance without allowing the bot to change anything in the cluster.
26
+
27
+
---
28
+
29
+
### `allow` — Confirm Before Modifying
30
+
31
+
```yaml
32
+
env:
33
+
MODIFY_RESOURCES: "allow"
34
+
```
35
+
36
+
The agent can execute write commands, but only after **explicit user confirmation**. When the agent plans a write operation, the system pauses and presents the user with a confirmation prompt listing the command(s) about to be run. The user must approve before anything is executed.
37
+
38
+
Read-only commands (`get`, `describe`, `logs`, etc.) run immediately without any confirmation.
39
+
40
+
**Best for**: Teams that want the convenience of automated execution but with a human-in-the-loop for any destructive or modifying actions.
41
+
42
+
---
43
+
44
+
### `auto` — Automatic Modification
45
+
46
+
```yaml
47
+
env:
48
+
MODIFY_RESOURCES: "auto"
49
+
```
50
+
51
+
The agent can execute both read and write commands automatically, without requesting user confirmation. The agent will:
52
+
53
+
1. Gather context first using read-only tools.
54
+
2. Briefly announce what it is about to do and why.
55
+
3. Execute the modification immediately.
56
+
57
+
The agent will still ask for user input when genuinely required (e.g., a required value such as a namespace or image tag is not specified).
58
+
59
+
**Best for**: Trusted internal tooling or teams with high confidence in the agent's behaviour who want to minimise confirmation prompts.
The modification mode should be aligned with the Kubernetes RBAC permissions granted to the bot's service account. The Helm chart provides a `rbac.allowWrite` value to control this:
100
+
101
+
```yaml
102
+
rbac:
103
+
create: true
104
+
allowWrite: false # Set to true when using allow or auto mode
> Setting `MODIFY_RESOURCES: "allow"` or `"auto"` while `rbac.allowWrite: false` will result in permission errors when the agent attempts write operations. Conversely, granting write RBAC while using `MODIFY_RESOURCES: "none"` is safe but unnecessarily permissive.
errorMessage="Resource modification is disabled (read-only mode). Provide the exact `kubectl` command in your response for the user to execute manually instead of using this tool."
715
-
} else {
716
-
errorMessage="RunOnce mode cannot handle permission requests. The following commands require approval:\n* "+strings.Join(commandDescriptions, "\n* ")
717
-
errorMessage+="\nUse --skip-permissions flag to bypass permission checks in RunOnce mode."
718
-
}
666
+
errorMessage:="Resource modification is disabled (read-only mode). The following commands were blocked:\n* "+strings.Join(commandDescriptions, "\n* ") +"\nProvide the exact `kubectl` command in your response for the user to execute manually instead of using this tool."
Copy file name to clipboardExpand all lines: pkg/agent/systemprompt_template_default.txt
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,18 @@ You can execute commands that modify resources automatically without requesting
76
76
- ❌ Incorrect: `kubectl --namespace=default get pods`
77
77
- This ensures commands are properly recognized and filtered by the system.
78
78
- NEVER use commands that open an interactive editor or shell (e.g., kubectl edit, kubectl exec -it, kubectl run --stdin --tty).
79
+
- NEVER pass a piped, chained, or compound command to the tool. Pipes (`|`), `&&`, `;`, and backticks are NOT allowed when calling the kubectl tool. Each tool call must be a single, standalone `kubectl` command.
80
+
- ✅ Correct: `kubectl get pods -A --field-selector spec.nodeName=my-node`
81
+
- ✅ Correct: `kubectl get pods -A -o jsonpath='{range .items[?(@.spec.nodeName=="my-node")]}{.metadata.namespace}{"/"}{.metadata.name}{"\n"}{end}'`
82
+
- ❌ Incorrect: `kubectl get pods -A | grep my-node`
83
+
- ❌ Incorrect: `kubectl get pods -A && kubectl get nodes`
84
+
- When filtering output, ALWAYS use kubectl's built-in mechanisms instead of pipes:
85
+
- Use `--field-selector` to filter by resource fields (e.g., `spec.nodeName`, `status.phase`)
86
+
- Use `-l` / `--selector` to filter by labels
87
+
- Use `-o jsonpath='...'` or `-o go-template='...'` with filter expressions for complex output
88
+
- When using `-o jsonpath`, ALWAYS wrap the jsonpath expression in single quotes: `-o jsonpath='...'`
89
+
- ✅ Correct: `kubectl get pods -o jsonpath='{.items[0].metadata.name}'`
90
+
- ❌ Incorrect: `kubectl get pods -o jsonpath={.items[0].metadata.name}` (unquoted)
0 commit comments