Xbus deployment¶
This section provides information on how to deploy Xbus. It is aimed at sys admins.
Components¶
PostgreSQL¶
Xbus uses a PostgreSQL database to serialize configuration and events. Deployment of a PostgreSQL server is out of the scope of this documentation; but a default setup will lead to the 5432 port being open.
Xbus server¶
To run an Xbus server:
xbusd serve
Add --help
to see available settings.
By default, Xbus listens on the 4222 port (may be changed with the
--nats-port
setting).
Note the database.dsn
setting that allows configuring the PostgreSQL
server and database to connect to.
Building the binary: Xbus requires Go 1.7; check the README section of this documentation for details on how to build Xbus.
Xbus connectors¶
Programs that connect to Xbus (emitters / workers / consumers) connect to the Xbus server on the port mentioned above. These connectors do not need to expose any port.
Administration¶
xbusctl¶
Xbus is to be administered via the xbusctl
program; see
the xbusctl section of this documentation for details.
Docker¶
Build¶
make build
Create docker image¶
./docker_build
Edit config file¶
Use ./etc/xbusd_sample.yaml to create a configuration file called xbusd.yaml. Assuming that the configuration file xbusd.yaml is in the /var/data/xbus/etc directory:
- Set the database host reachable from the docker, db name, db user and db password.
- Add option to disable database ssl mode.
- Set the nats host and port.
Requirements¶
- Create a directory certs in /var/data/xbus/etc directory.
Init xbus db¶
Run xbusd init command from the docker to initialize the database:
docker run --rm -p 4222:4222 -v /var/data/xbus/etc:/etc/xbusd xbusd init --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs/
Generate xbus certificates¶
Generate keys:
docker run --rm -p 4222:4222 -v /var/data/xbus/etc:/etc/xbusd xbusd key generate --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs/
Generate certificates:
The –host-defs option defines the host for which the server-ca is generated. It can be a host name, an IP or a domain.
docker run --rm -p 4222:4222 -v /var/data/xbus/etc:/etc/xbusd xbusd cert generate server-ca --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs/ --host-defs <HOST DEFS>
docker run --rm -p 4222:4222 -v /var/data/xbus/etc:/etc/xbusd xbusd cert generate client-ca --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs/
Register xbusctl¶
Use ./etc/xbusctl_sample.yaml to create a configuration file called xbusctl.yaml. Assuming that the configuration file xbusctl.yaml is in the /var/data/xbus/etc directory:
Run xbusd serve:
docker run --rm -d --restart always -t -p 4222:4222 --name xbus -v /var/data/xbus/etc:/etc/xbusd xbusd serve --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs/
Generate keys:
docker run --rm -v /var/data/xbus/etc:/etc/xbusctl xbusctl --account-name xbusctl_name key generate --config /etc/xbusctl/xbusctl.yaml
Register:
docker run --rm -v /var/data/xbus/etc:/etc/xbusctl xbusctl register --config /etc/xbusctl/xbusctl.yaml
Accept account:
docker exec -ti xbus xbusd account list --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs
docker exec -ti xbus xbusd account accept "<FINGERPRINT>" --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs/
Register again:
docker run --rm -v /var/data/xbus/etc:/etc/xbusctl xbusctl register --config /etc/xbusctl/xbusctl.yaml
Run docker¶
docker run --rm -p 4222:4222 --name xbus -v /var/data/xbus/etc:/etc/xbusd xbusd serve --config /etc/xbusd/xbusd.yaml --cert-dir /etc/xbusd/certs/
Stop docker¶
docker stop xbus