Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: update to balena device <subcommand> #3129

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions pages/learn/develop/local-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ To use local mode on a device:

## Scan the network and find your device

Before you can get your app running on your device in local mode, you have to find your device. You can find the `short-uuid` and local IP address of the device from the device dashboard or by scanning the network. To perform a scan, login to the {{ $names.company.lower }} CLI and use `{{ $names.company.short }} scan` to find any local {{ $names.os.lower }} devices. All {{ $names.os.lower }} devices advertise themselves on the network using [Avahi][avahi]. The names take the form `<short-uuid>.local`, where the `short-uuid` is the UUID you see on your device dashboard.
Before you can get your app running on your device in local mode, you have to find your device. You can find the `short-uuid` and local IP address of the device from the device dashboard or by scanning the network. To perform a scan, login to the {{ $names.company.lower }} CLI and use `{{ $names.company.short }} device detect` to find any local {{ $names.os.lower }} devices. All {{ $names.os.lower }} devices advertise themselves on the network using [Avahi][avahi]. The names take the form `<short-uuid>.local`, where the `short-uuid` is the UUID you see on your device dashboard.

__Note:__ You may need administrator privileges to run `{{ $names.company.short }} scan` as it requires access to all network interfaces.
__Note:__ You may need administrator privileges to run `{{ $names.company.short }} device detect` as it requires access to all network interfaces.

**Command**

```bash
sudo {{ $names.company.short }} scan
sudo {{ $names.company.short }} device detect
```

**Output**
Expand Down Expand Up @@ -66,7 +66,7 @@ Reporting scan results

## Push over a new project

When local mode has been activated, {{ $names.company.lower }} CLI can push code directly to the local device instead of going via the {{ $names.cloud.lower }} builders. As code is built on the device and then executed, this can significantly speed up development when requiring frequent changes. To do this, we use the `{{ $names.company.lower }} push` command providing either the local IP address or `<short-uuid>.local`, obtained from the preceding `{{ $names.company.short }} scan` command.
When local mode has been activated, {{ $names.company.lower }} CLI can push code directly to the local device instead of going via the {{ $names.cloud.lower }} builders. As code is built on the device and then executed, this can significantly speed up development when requiring frequent changes. To do this, we use the `{{ $names.company.lower }} push` command providing either the local IP address or `<short-uuid>.local`, obtained from the preceding `{{ $names.company.short }} device detect` command.

__Note:__ By default `{{ $names.company.short }} push` will build from the current working directory, but it is also possible to specify the project directory via the `--source` option.

Expand Down Expand Up @@ -167,48 +167,48 @@ By default, when pushing code to a device in local mode using the {{ $names.comp
{{ $names.company.short }} push 63ec46c.local --detached
```

When detached, the services continue to run on the device, and you can access the logs using the `{{ $names.company.short }} logs` command, again passing the local IP address or `<short-uuid>.local`.
When detached, the services continue to run on the device, and you can access the logs using the `{{ $names.company.short }} device logs` command, again passing the local IP address or `<short-uuid>.local`.

```shell
{{ $names.company.short }} logs 63ec46c.local
{{ $names.company.short }} device logs 63ec46c.local
```

This command will output logs for the system and all running services. You may optionally filter the output to include only system or specific service logs using the available `--system` (`-S`) and `--service` (`-s`) options. For example, to output only the system logs:

```bash
{{ $names.company.short }} logs 63ec46c.local --system
{{ $names.company.short }} device logs 63ec46c.local --system
```

To filter logs by a service, use the `--service` option. You may specify this option multiple times to output logs from multiple services.

```bash
{{ $names.company.short }} logs 63ec46c.local --service main
{{ $names.company.short }} logs 63ec46c.local --service first --service second
{{ $names.company.short }} device logs 63ec46c.local --service main
{{ $names.company.short }} device logs 63ec46c.local --service first --service second
```

These options can be combined to output system and selected service logs e.g.

```bash
{{ $names.company.short }} logs 827b231.local --system --service first --service second
{{ $names.company.short }} device logs 827b231.local --system --service first --service second
```

__Note:__ You may also specify the `--service` and `--system` options using the `{{ $names.company.short }} push` command to filter the log output.

## SSH into the running app container or host OS

To access the local device over [SSH][ssh], use the `{{ $names.company.short }} ssh` command specifying the device IP address or `<short-uuid>.local`. By default, SSH access is routed into the host OS shell and, from there, we can check system logs and [perform other troubleshooting tasks][troubleshooting]:
To access the local device over [SSH][ssh], use the `{{ $names.company.short }} device ssh` command specifying the device IP address or `<short-uuid>.local`. By default, SSH access is routed into the host OS shell and, from there, we can check system logs and [perform other troubleshooting tasks][troubleshooting]:

```bash
{{ $names.company.short }} ssh 192.168.86.45
{{ $names.company.short }} device ssh 192.168.86.45
```

To connect to a container, we can specify the service name e.g.

```bash
sudo {{ $names.company.short }} ssh 63ec46c.local my-service
sudo {{ $names.company.short }} device ssh 63ec46c.local my-service
```

__Note:__ If an IP address or a `.local` hostname is used (instead of a fleet name or device UUID), `{{ $names.company.short }} ssh` establishes a direct connection to the device on port `22222` that does not rely on cloudlink.
__Note:__ If an IP address or a `.local` hostname is used (instead of a fleet name or device UUID), `{{ $names.company.short }} device ssh` establishes a direct connection to the device on port `22222` that does not rely on cloudlink.

## Using a Private Docker Registry

Expand Down
22 changes: 11 additions & 11 deletions shared/general/container-ssh.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ A terminal session should be initiated for you in a second or two. If you would

__Note:__ To copy and paste in the terminal window, you cannot use the normal Ctrl + C and Ctrl + V shortcuts. You can either select Copy and Paste from a menu, or use Ctrl + Insert for copy and Shift + Insert for Paste. For MacOS users, ⌘ + C and ⌘ + V work as expected.

## Using `{{ $names.company.short }} ssh` from the CLI
## Using `{{ $names.company.short }} device ssh` from the CLI

To use the CLI, first [install it][cli-install] and [add an SSH key to {{ $names.cloud.lower }}][add-ssh-key]. Then run the following command on your development machine's terminal:

```shell
$ {{ $names.company.short }} ssh <device-uuid>
$ {{ $names.company.short }} device ssh <device-uuid>
```

`<device-uuid>` is the unique identifier for the device you want to access, which can be found via the dashboard or in the output of the `{{ $names.company.short }} devices` CLI command. By default, SSH access is routed into the host OS shell. However, you can SSH into a service by specifying its name as part of the command:
`<device-uuid>` is the unique identifier for the device you want to access, which can be found via the dashboard or in the output of the `{{ $names.company.short }} device list` CLI command. By default, SSH access is routed into the host OS shell. However, you can SSH into a service by specifying its name as part of the command:

```shell
$ {{ $names.company.short }} ssh <device-uuid> main
$ {{ $names.company.short }} device ssh <device-uuid> main
```

This also works in multicontainer fleets; simply pass the name of the appropriate service (as defined in docker-compose.yml) instead of `main`.

__Note:__ To run a command in a non-interactive way, you can pipe commands to the CLI's stdin. For example, `echo "uptime; exit;" | balena ssh <device-uuid>`.
__Note:__ To run a command in a non-interactive way, you can pipe commands to the CLI's stdin. For example, `echo "uptime; exit;" | balena device ssh <device-uuid>`.

When a fleet name or device UUID is used as above, `{{ $names.company.short }}` ssh uses Cloudlink to create a secure tunnel to the device and then forward SSH traffic between the device and your development machine.

If an IP address or a .local hostname is used (instead of a fleet name or device UUID), `{{ $names.company.short }}` ssh establishes a direct connection that does not rely on Cloudlink:

```shell
$ balena ssh 192.168.1.23
$ balena ssh <device-uuid>.local
$ balena device ssh 192.168.1.23
$ balena device ssh <device-uuid>.local
```

When used with a [production variant of {{ $names.os.lower }}][development-image], this
Expand Down Expand Up @@ -70,19 +70,19 @@ Development variants of {{ $names.os.lower }} allow unauthenticated access and s
directly exposed to the public internet.

The IP address will typically be a private IP address of a local network. For remote devices,
see [{{ $names.company.short }} tunnel][balena-tunnel].
see [{{ $names.company.short }} device tunnel][balena-tunnel].

## {{ $names.company.short }} tunnel
## {{ $names.company.short }} device tunnel

The SSH server of a {{ $names.os.lower }} device (host OS) listens on TCP port `22222`.
This port is not blocked by any firewall on the device itself, but external firewalls or NAT
routers will often block access at the network level. To get around this, you can use the
`{{$names.company.short }} tunnel` command of the {{ $names.cli.lower }}, which tunnels a
`{{$names.company.short }} device tunnel` command of the {{ $names.cli.lower }}, which tunnels a
TCP connection between a localhost port and a port on the device. For example, the following
command maps local port `4321` to remote port `22222` on the device:

```shell
$ balena tunnel <device-uuid> -p 22222:4321
$ balena device tunnel <device-uuid> -p 22222:4321
```

The device can then be accessed on local port `4321` with a standalone SSH client:
Expand Down
Loading