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

# mogenius CLI

> Manage your mogenius clusters, resources, and workloads from the terminal with mocli

With `mocli`, you can manage your mogenius clusters, browse Kubernetes resources, stream logs, and set up port-forwarding — all from your terminal.

The CLI includes an interactive Terminal UI (TUI) that provides k9s-style navigation without requiring a local kubeconfig. Authentication is handled through the mogenius platform, giving you secure access to any connected cluster from anywhere.

## Installation

### Mac, Linux

Use [homebrew](https://brew.sh) to install `mocli`:

```bash theme={null}
brew tap mogenius/mocli
brew install mocli
```

<Note>
  On Linux with a headless machine, `mocli` requires a browser for the initial login. After the first login, your session persists locally.
</Note>

### Windows

```bash theme={null}
scoop bucket add mocli https://github.com/mogenius/homebrew-mocli
scoop install mocli
```

## Getting Started

You need a mogenius account to use `mocli`. If you don't have one yet, [sign up here](https://app.mogenius.com).

### Login

Run the following command to authenticate. Your browser will open automatically to complete the login:

```bash theme={null}
mocli login
```

Your session is stored locally, so you only need to log in once per machine.

## Terminal UI

Launch the interactive TUI to browse and manage your resources:

```bash theme={null}
mocli
```

The TUI provides a visual interface for navigating your mogenius organization, clusters, and Kubernetes resources. All keybindings are displayed at the bottom of each screen.

### Navigation

The TUI follows a hierarchical navigation pattern:

**Organization → Cluster → Namespace → Resources**

| Key        | Action                               |
| ---------- | ------------------------------------ |
| Arrow keys | Move up/down                         |
| `Enter`    | Select / drill down                  |
| `Esc`      | Go back                              |
| `q`        | Quit                                 |
| `/`        | Filter list                          |
| `:`        | Command mode (switch resource types) |

### Browsing Resources

Once you select a namespace, you'll see a list of Pods by default. Use command mode (`:`) to switch between resource types:

* `:pods` or `:po` — Pods
* `:deployments` or `:deploy` — Deployments
* `:services` or `:svc` — Services
* `:statefulsets` or `:sts` — StatefulSets
* `:daemonsets` or `:ds` — DaemonSets
* `:jobs` — Jobs
* `:cronjobs` or `:cj` — CronJobs
* `:configmaps` or `:cm` — ConfigMaps
* `:secrets` — Secrets
* `:ingresses` or `:ing` — Ingresses

The TUI also supports custom resources (CRDs) — type the resource name in command mode to browse any resource type available in your cluster.

### Viewing Logs

Select a Pod and press `Enter` to view its logs in real-time. If the Pod has multiple containers, you'll be prompted to select one.

| Key             | Action                  |
| --------------- | ----------------------- |
| `PgUp` / `PgDn` | Scroll through logs     |
| `s`             | Toggle autoscroll       |
| `w`             | Toggle word wrap        |
| `Esc`           | Return to resource list |

### Port Forwarding

From the logs view or resource list, press `t` to create a port-forward tunnel to the selected Pod. Enter the port mapping (e.g., `8080:80`) and the tunnel will be established.

Active tunnels persist while the TUI is running. Press `Esc` from the port-forward view to return to browsing while keeping tunnels open.

## CLI Commands

In addition to the TUI, `mocli` provides direct CLI commands:

```bash theme={null}
# Authentication
mocli login
mocli logout

# Cluster management
mocli cluster connect    # Install the mogenius operator on a cluster
mocli cluster list       # List connected clusters

# Port forwarding
mocli portforward        # Manage port-forward sessions

# Version info
mocli version
```

## Connecting a Cluster

You can use the CLI to install the mogenius operator on your Kubernetes cluster:

1. In the mogenius UI, add a new cluster
2. Run the connect command:
   ```bash theme={null}
   mocli cluster connect
   ```
3. Select the cluster from the list that matches your current kube context
4. Confirm to deploy the operator

The operator will be deployed to your cluster. Verify the connection with `mocli cluster list` or through the mogenius UI.

## Port Forwarding (CLI)

Use the CLI to create secure TCP tunnels to Kubernetes services without direct cluster access:

```bash theme={null}
mocli port-forward --namespace <namespace> --service <service-name> --port <local>:<remote>
```

For example, to connect to a PostgreSQL database:

```bash theme={null}
mocli port-forward --namespace production --service postgres --port 5432:5432
```

The tunnel remains active while the CLI process runs. Press `Ctrl+C` to terminate.

For detailed usage and options, see [Tunnels](/workspaces/tunnels).
