> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/rtk-ai/rtk/llms.txt
> Use this file to discover all available pages before exploring further.

# rtk kubectl

> Kubernetes commands with compact output

## Overview

Proxy for `kubectl` with token-optimized output. Compacts pod lists, service tables, and log output.

## Syntax

```bash theme={null}
rtk kubectl <SUBCOMMAND> [OPTIONS]
```

## Subcommands

### rtk kubectl pods

List pods with compact status.

```bash theme={null}
rtk kubectl pods [OPTIONS]
```

**-n, --namespace \<name>** `string`

Kubernetes namespace

**-A, --all-namespaces** `flag`

List pods across all namespaces

**Output:**

```
8 pods in default:
✅ web-deploy-abc123 (2/2) [Running 5h]
✅ api-deploy-def456 (1/1) [Running 5h]
🔄 worker-xyz789 (0/1) [CrashLoopBackOff]
... +5 more
```

**Token savings: 75%**

### rtk kubectl services

List services with compact networking info.

```bash theme={null}
rtk kubectl services [OPTIONS]
```

**Output:**

```
3 services:
web-svc        LoadBalancer  :80 → nodes:30080
api-svc        ClusterIP     :3000
db-svc         ClusterIP     :5432
```

**Token savings: 70%**

### rtk kubectl logs

Deduplicated pod logs.

```bash theme={null}
rtk kubectl logs <POD> [OPTIONS]
```

**-c, --container \<name>** `string`

Container name (for multi-container pods)

**-f, --follow** `flag`

Follow log output

**--tail \<n>** `number`

Number of lines to show

**Features:**

* Deduplicates repeated messages
* Groups similar log patterns
* Strips k8s metadata

**Token savings: 80%**

## Examples

### List Pods in Namespace

```bash theme={null}
rtk kubectl pods -n production
```

### View Pod Logs

```bash theme={null}
rtk kubectl logs web-deploy-abc123 --tail 100
```

### List All Services

```bash theme={null}
rtk kubectl services --all-namespaces
```

## Implementation

Source: `src/container.rs`

### Optimizations

* **Status icons**: `✅` Running, `🔄` Pending/CrashLoop, `⏹️` Terminated
* **Container ratios**: `(2/2)` instead of full Ready/Total columns
* **Age formatting**: `5h` instead of verbose duration
* **Port compaction**: `:80→30080` instead of full notation

## Related Commands

* [rtk docker](/api/docker.md) - Docker operations
* [rtk log](/api/log) - Log filtering

## Token Savings Summary

| Command | Standard | RTK | Savings |
| - | - | - | - |
| `pods` | \~800 tokens | \~200 tokens | 75% |
| `services` | \~500 tokens | \~150 tokens | 70% |
| `logs` | \~2000 tokens | \~400 tokens | 80% |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.