# Terminal & Logs

Source: https://docs.ops0.com/docs/kubernetes/terminal

Access a live terminal and stream real-time logs from your pods directly in the browser — no `kubectl` installation or local kubeconfig required.

## Pod Logs

### Streaming Logs

Open any pod from **Kubernetes → Pods**, then click the **Logs** tab. Logs stream in real time from the pod's stdout/stderr.

| Option | Description |
|--------|-------------|
| **Container** | Select which container to tail (for multi-container pods) |
| **Previous** | Show logs from the previous container instance (useful after a crash) |
| **Timestamps** | Prefix each log line with its RFC3339 timestamp |
| **Lines** | Number of recent lines to load on open (default: 100) |
| **Wrap** | Toggle line wrapping for long log lines |

### Searching Logs

Use the search bar above the log output to filter lines containing a keyword. Matching lines are highlighted and non-matching lines are dimmed.

### Downloading Logs

Click **Download** to save the current log buffer as a `.log` file. For large pods, use the line count option to limit the export size.

## Pod Terminal

### Opening a Terminal Session

1. Navigate to **Kubernetes → Pods**
2. Click the pod you want to access
3. Click the **Terminal** tab
4. Select the container (for multi-container pods)
5. The terminal connects and opens a shell session

The terminal is a full PTY session — tab completion, arrow keys, and interactive programs all work normally.

### How It Works

ops0 establishes a WebSocket connection from your browser to the ops0 backend, which proxies the session to the Kubernetes API server (`exec` endpoint). No inbound ports are required on the cluster — only the existing API server connection that ops0 uses for all cluster operations.

### Supported Shells

ops0 attempts to open shells in this order:

1. `/bin/bash`
2. `/bin/sh`

Minimal containers that have neither will not support terminal sessions.

### Terminal Resize

The terminal window automatically resizes as you resize your browser panel. The PTY dimensions are updated in real time so full-screen tools like `vim`, `htop`, and `less` render correctly.

### Session Limits

| Limit | Value |
|-------|-------|
| **Idle timeout** | 10 minutes of no input |
| **Concurrent sessions** | Multiple sessions per pod supported |
| **Session logging** | All terminal activity is recorded in Audit Logs |

## Security

All terminal sessions and log access are:

- **Authenticated** — requires a valid ops0 session with cluster access
- **Authorized** — subject to IAM permissions (`kubernetes_terminal` permission)
- **Audited** — every session open, command, and close is written to the organization audit log with user identity and timestamp

Production Access

Terminal sessions on production clusters should be governed by your IAM policy. Use ops0 roles to restrict terminal access to senior engineers or on-call responders only. All sessions are audited regardless of permission level.

## Troubleshooting

Terminal tab not available

The terminal requires the `kubernetes_terminal` IAM permission. Contact your organization admin if the tab is missing or greyed out.

Connection timed out

The 10-second acknowledgment window may have been missed. Reload the terminal tab to establish a new session. If repeated, check cluster connectivity in Settings → Integrations.

Logs stop streaming

Log streams close if the pod restarts. Refresh the Logs tab to reconnect. If the pod keeps restarting, switch to the **Previous** mode to see why it crashed.
