Skip to content

Commit

Permalink
finish responding to controller deploy and controller migration feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
qrkourier committed Apr 30, 2024
1 parent 9d7edb9 commit b442f33
Showing 1 changed file with 39 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,55 @@ title: Migrate a Controller Installation
sidebar_label: Migrate
---

You can generate a configuration with the `ziti create config controller` command, optionally mutating the result through command-line options or environment variables. You can also find an annotated sample config file from [the Ziti repo](https://github.com/openziti/ziti/blob/main/etc/ctrl.with.edge.yml).
Here's an example of migrating an existing controller's 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 the controller service is disabled and state is clean.

```bash
#!/bin/bash
```text
sudo systemctl disable --now ziti-controller.service
sudo systemctl clean --what=state ziti-controller.service
```

set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
1. Duplicate the controller part of the quickstart state to the working directory using the `config.yml` filename.

pushd $(mktemp -d)
```text
sudo mkdir -pv /var/lib/ziti-controller/
sudo cp -Rv ./pki ./db /var/lib/ziti-controller/
sudo cp -v ./ctrl.yaml /var/lib/ziti-controller/config.yml
```

# install controller and CLI packages
curl -sS https://get.openziti.io/install.bash \
| sudo bash -s openziti-controller
1. Correct the file paths in `config.yml`. Ensure your current working directory matches the existing controller's
working directory, e.g. `ZITI_HOME`, or substitute the old working directory for `$PWD`. After completing this step,
verify the new `config.yml` has the correct file paths.

# create state with the quickstart
timeout 10s ziti edge quickstart --home $PWD
```text
sudo sed -Ei "s|$PWD|/var/lib/ziti-controller|g" /var/lib/ziti-controller/config.yml
```

# ensure service is disabled and state is clean
sudo systemctl disable --now ziti-controller.service
sudo systemctl clean --what=state ziti-controller.service
1. Disable bootstrapping. We're migrating a complete controller configuration (PKI, configuration file, and database) so
we don't need the bootstrapping process.

# 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-controller/
sudo cp -Rv ./pki ./db /var/lib/ziti-controller/
sudo cp -v ./ctrl.yaml /var/lib/ziti-controller/config.yml
```text
sudo sed -Ei 's|(ZITI_BOOTSTRAP_.*)=.*|\1=false|g' /opt/openziti/etc/controller/service.env
```

# correct config paths
sudo sed -Ei "s|$PWD|/var/lib/ziti-controller|g" /var/lib/ziti-controller/config.yml
1. Start the service.

# disable bootstrapping
sudo sed -Ei 's|(ZITI_BOOTSTRAP_.*)=.*|\1=false|g' /opt/openziti/etc/controller/service.env
```text
sudo systemctl enable --now ziti-controller.service
sudo systemctl status ziti-controller.service
```

# start the service
sudo systemctl enable --now ziti-controller.service
sudo systemctl status ziti-controller.service
1. Verify the controller is running and listening on the expected port.

```
```text
journalctl -u ziti-controller.service
```

```text
sudo lsof -Pnp $(systemctl show -p MainPID --value ziti-controller.service) |& awk '$5~/IP/'
```

```buttonless title="Output"
ziti 2694474 ziti-controller 8u IPv6 222078013 0t0 TCP *:1280 (LISTEN)
```

0 comments on commit b442f33

Please sign in to comment.