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

# Usage

LocalOps CLI `ops` can be used to get shell access to the underlying Kubernetes cluster of an environment.

```sh theme={null}
LocalOps CLI

Usage:
  ops [command]

Available Commands:
  completion        Generate the autocompletion script for the specified shell
  help              Help about any command
  login             Login to LocalOps Account
  logout            Logout of LocalOps Account
  update-kubeconfig Update current context to environment Kubernetes cluster
  version           LocalOps CLI Version

Flags:
  -h, --help   help for ops

Use "ops [command] --help" for more information about a command.
```

To get shell access, you need to

1. Login to your LocalOps account
2. Use `ops` CLI to set Kubernetes context of `kubectl` CLI to point at the environment's Kubernetes cluster.
3. Then use `kubectl` to inspect the cluster.

### Login to LocalOps

Login to LocalOps account using your email address.

```sh theme={null}
ops login
```

### Set kubernetes context

Use this commnd updates your local current context to point at the environment's kubernetes cluster.

```sh theme={null}
ops update-kubeconfig -e env-id
```

To get `env-id`, visit your environment dashboard and see "Shell" tab.

### Use Kubectl

After `update-kubeconfig` command succeeds, you can use any kubectl command to inspect pods, deployments, jobs and
everything else running in your LocalOps environment.

All your services are deployed in the `app-services` namespace. To see only your service pods:

```sh theme={null}
kubectl get pods -n app-services
```

To see all cluster resources across all namespaces:

```sh theme={null}
kubectl get all --all-namespaces
```

### Monitor pods with k9s

[k9s](https://k9scli.io/) is a terminal-based UI that makes it easy to monitor and manage Kubernetes resources. After
setting up your kubeconfig with `ops update-kubeconfig`, simply launch k9s:

```sh theme={null}
k9s
```

k9s will automatically use the current Kubernetes context set by `ops update-kubeconfig`. To launch k9s directly in the
`app-services` namespace where your services run:

```sh theme={null}
k9s -n app-services
```

From the k9s interface you can:

* View all pods and their status in real time
* Watch logs by selecting a pod and pressing `l`
* Filter resources by namespace using `/` to search
* Delete, describe, or edit resources interactively

<Tip>
  Install k9s via Homebrew with `brew install derailed/k9s/k9s` on macOS, or see the [k9s installation
  guide](https://k9scli.io/topics/install/) for other platforms.
</Tip>

### Shell into a pod

To get a shell inside a running pod, first identify the pod name in the `app-services` namespace:

```sh theme={null}
kubectl get pods -n app-services
```

Then exec into the pod:

```sh theme={null}
kubectl exec -it <pod-name> -n app-services -- /bin/sh
```

<Note>
  Some containers may use `/bin/bash` instead of `/bin/sh`. If `/bin/sh` fails, try `/bin/bash`.
</Note>

You can also use k9s to get a shell — select a pod and press `s` to open a shell session directly.
