Skip to content

Commit

Permalink
refine linux router guide
Browse files Browse the repository at this point in the history
  • Loading branch information
qrkourier committed May 13, 2024
1 parent d40485d commit f0d5991
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ hide_table_of_contents: false
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

This article expands on the [Linux and Docker router deployment](/guides/deployments/10-linux/20-router/10-deploy.mdx) article with configuration concepts and examples. [Kubernetes is covered separately](/guides/deployments/30-kubernetes//kubernetes-router.mdx).
This article expands on the [Linux router deployment](/guides/deployments/10-linux/20-router/10-deploy.mdx) article with configuration concepts and examples.

## Config Management

You may create or edit the configuration file manually or run `ziti create config router` to generate one. The generator aims to accelerate developing a working configuration with the most relevant options. The output can be influenced with arguments and variables. Run `ziti create config environment` for descriptions of the available environment variables.
Edit the generated configuration YAML file or run `ziti create config router` to generate one from scratch. Run `ziti create config environment` for descriptions of the environment variables that influence the generated output.

## Identity

Expand All @@ -28,7 +28,7 @@ identity:

### Private Key

The shape of the [`identity`](/reference/30-configuration/conventions.md#identity) section is conventional for routers and controllers, but the `key` sub-property behaves differently for routers. If a private key exists in the path, then it will be used to sign router enrollment certificate requests. If it does not exist, then a private key will be locally generated and stored in that path.
The [`identity`](/reference/30-configuration/conventions.md#identity) configuration section is conventional for routers and controllers, but the `key` sub-property behaves differently for routers. If a private key exists in the path, then it will be used to sign router enrollment certificate requests. If it does not exist, then a private key will be locally generated and stored in that path.

If present, the `server_key` signs the router's server certificate request. Otherwise, the `key` sub-property is used for both client and server certificate.

Expand Down Expand Up @@ -100,16 +100,13 @@ link:
outQueueSize: 4
listeners:
# bindings of edge and tunnel requires an "edge" section below
- binding: edge
address: tls:0.0.0.0:3022
options:
advertise: router1.ziti.example.org:3022
connectTimeoutMs: 5000
getSessionTimeout: 60
edge:
csr:
country: US
Expand Down Expand Up @@ -186,7 +183,6 @@ link:
- binding: transport
listeners:
# bindings of edge and tunnel requires an "edge" section below
- binding: edge
address: tls:0.0.0.0:3022
options:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,38 @@ title: Migrate a Router Installation
sidebar_label: Migrate
---

You can generate a configuration with the `ziti create config router` command, optionally mutating the generated config with a combination of command-line args and environment variables. Find an annotated sample config file from [the Ziti repo](https://github.com/openziti/ziti/blob/main/etc/edge.router.yml).
Here's an example of migrating an existing router configuration to the Linux service's working directory.

Here's an example BASH script for migrating an existing controller state to the Linux service's working directory.
1. Ensure service is disabled and state is clean.

```text
sudo systemctl disable --now ziti-router.service
sudo systemctl clean --what=state ziti-router.service
```

```bash
#!/bin/bash
1. Duplicate the router-related parts of the configuration to the service's working directory.

set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
```text
sudo mkdir -pv /var/lib/ziti-router/
sudo cp -v ./quickstart-router.* /var/lib/ziti-router/
sudo mv -v /var/lib/ziti-router/{quickstart-router.yaml,config.yml}
```

pushd $(mktemp -d)
1. Correct paths in the configuration YAML file.

# install router and CLI packages
curl -sS https://get.openziti.io/install.bash \
| sudo bash -s openziti-router
```text
sudo sed -Ei "s|$PWD|/var/lib/ziti-router|g" /var/lib/ziti-router/config.yml
```

# create state with the quickstart
timeout 10s ziti edge quickstart --home $PWD
1. Disable bootstrapping. It's unnecessary because we are migrating, not generating, a complete router configuration.

# ensure service is disabled and state is clean
sudo systemctl disable --now ziti-router.service
sudo systemctl clean --what=state ziti-router.service
```text
sudo sed -Ei 's|(ZITI_BOOTSTRAP_.*)=.*|\1=false|g' /opt/openziti/etc/router/service.env
```

# duplicate the controller part of the quickstart state to the service working directory using the config.yml filename
# expected by the controller service
sudo mkdir -pv /var/lib/ziti-router/
sudo cp -v ./quickstart-router.* /var/lib/ziti-router/
sudo mv -v /var/lib/ziti-router/{quickstart-router.yaml,config.yml}

# correct config paths
sudo sed -Ei "s|$PWD|/var/lib/ziti-router|g" /var/lib/ziti-router/config.yml

# disable bootstrapping
sudo sed -Ei 's|(ZITI_BOOTSTRAP_.*)=.*|\1=false|g' /opt/openziti/etc/router/service.env

# run only the controller in the background using the quickstart state so the enrolled router can check in
nohup ziti controller run ctrl.yaml &

# start the service
sudo systemctl enable --now ziti-router.service
sudo systemctl status ziti-router.service
```
1. Start the service.

```text
sudo systemctl enable --now ziti-router.service
sudo systemctl status ziti-router.service
```

0 comments on commit f0d5991

Please sign in to comment.