Installing a Node: from a bare host to a first config running
The whole install path in the order the scripts run, for the first Node of a site and for each Node added
after it. Every command in a block below that can run on a test machine is run by
tests/test_integrator_walkthrough_doc.py, in order, against a clean home directory, and the output
shown under a block is checked against what the command prints. The commands that need the real
system (installing packages, systemd, a running service, your configuration repository) are checked
for an existing script, its place in the order, and arguments the script accepts, using the script's own
argument parsing.
Contents: Before you start · On the workstation · On the Node · Adding another Node · Changing the config later · Pitfalls · Rehearsing a whole site on one host
Before you start
Two machines play two roles. The workstation is your own machine or a provisioning host: it holds the
site's certificate authority. The Node is the appliance, a bare Ubuntu 24.04 host with a checkout of
this repository. Run every Node step as the one ordinary user the Node will run as (the service user, a
user that can sudo; the service user says how to make it), never as root: the
commands that need root say sudo, and the scripts that must not run as root refuse to.
You need:
- a Git repository for the site's configuration, holding the Node's config at a path you choose. It may be
encrypted with
sopsfor your age key, which this walkthrough assumes (an encrypted config is the one that can carry credentials); - the address of the inference endpoint the Node will use;
- the Node Type to run (
MES,ERP,Production SchedulingorPLC / Generic Device, spelled as shown) and an instance id for it. Any other Node Type has no process entry point and the install refuses it by name; - a correct clock, and a way to keep it correct (see A correct clock below);
- a config written for production. The example configs under
node-types/are plain HTTP, for development, and a Node on a provisioned appliance refuses them at start: step 7 says what to add.
A correct clock
Certificate validity, the Activity Log's timestamps and the correlation of events between Nodes all depend on every appliance having a correct clock. A plant network often has no internet path, so Ubuntu's default time pool is unreachable and a clock with nothing to follow drifts. Give each appliance one of:
- a time source it can reach on UDP 123: the site's own NTP server or domain controller, a GPS-fed source, or one Node designated to serve the others;
- or a hypervisor that supplies the guest's time (the guest then often has no time client of its own).
Each appliance on its own free-running clock is unsupported for a site with more than one Node. Nothing
in Kindred enforces this: provision_node.sh never refuses a host over its time, because a guest's time may
come from a hypervisor it cannot see into. It reports what it found, doctor and GET /v1/status show the
same facts for monitoring (the client and whether it is synchronized, the virtualization type and the host's
UTC time), and comparing the host times of three or more Nodes shows which one is the outlier. Firewalling
UDP 123 from the segment the appliance sits on is yours to open.
To have provisioning write the source for you, put it in the environment of step 2 as
KINDRED_TIME_SOURCE=<host name or address> (one entry). It is written to systemd-timesyncd's
configuration only if it would change something, and the client is restarted only then.
All commands run from the root of the checkout. The examples run both roles on one machine so they can be
tested: where a real site moves files from the workstation to the Node (scp, a USB drive), the examples
read them in place. Certificates live under ~/.kindred-pki on the workstation and ~/.kindred-node-pki
on the Node, the defaults throughout; Pitfalls covers a different directory.
On the workstation
Create the site's certificate authority once, for the whole site: every further Node reuses it (see
Adding another Node). The site name becomes part of every Node's identity. The CA
key stays on the workstation: back it up offline and never copy it to a Node. The details are in
site-pki.md.
deployment/create_site_ca.sh plant1
Issue the Node's certificate, naming the Node by its instance id and giving it the name and address the site reaches it by:
deployment/issue_node_certificate.sh plant1 line-1 --dns node1.plant.local --ip 10.0.0.21
Issued urn:kindred:plant1:line-1 in ~/.kindred-pki/plant1/nodes/line-1 (valid 365 days).
That directory now holds node.crt, node.key and trust-bundle.pem. Copy those three files to the
Node, into a directory only the service user can enter (mode 0700, since one of them is the key), made
before the copy. Write down the CA's fingerprint; the broker step below asks you to compare it:
openssl x509 -in ~/.kindred-pki/plant1/ca.crt -noout -fingerprint -sha256
sha256 Fingerprint=…
On the Node
The service user
Every Node step runs as one ordinary user, the service user. Create it first unless the host already has one. It must be:
- an ordinary login account with a home directory and a shell, not root and not a system account. The
Node runs unprivileged, and
install_node_service.shrefuses root; - in the
sudogroup. The scripts callsudothemselves for the steps that need root, andsudoasks for this account's password; - the same account throughout. The
sudoscripts default to the user who ransudo, so log in as the service user, or pass--service-user NAMEto each of them.
create_service_user.sh makes such an account. Run it once, as root or with sudo from an administrator's login.
- Where it runs from. Any checkout of this repository will do. It needs only itself and
pki_common.sh, which it sources from its own directory. On a host with no checkout yet, copy those two files together. - The password. It is typed at the prompt of
passwd, which the script starts and does not watch. The script never sees, stores or prints it. It needs a terminal to ask on, which a command run throughssh host 'command'does not have. --ssh-key-filelets a public key log in as the account.--passwordless-sudo(with a key) is for lab and test hosts only. It lets the account runsudowithout a password, and is the way to run the script where there is no terminal.- Running it again on an existing account changes neither its password nor its shell.
sudo deployment/create_service_user.sh --user kindred --ssh-key-file ~/node-admin.pub
Then log in as the service user and do the rest from a checkout it owns.
1. Your own age key
The key that decrypts the site's configuration is yours, and is placed by hand: distribute_age_key.sh
copies one existing shared key onto a new appliance and is not for an integrator's per-site key. Generate the key on the Node, so the
private half never travels, and put its public half (the age1… line) in the .sops.yaml of your
configuration repository so configs are encrypted to it.
Do this before provisioning. The provisioning step generates a key only when none exists, and a key it
generated is not the one your configs are encrypted for. Install age first (the package the provisioning
step installs):
sudo apt-get install -y age
(umask 077 && mkdir -p ~/.config/sops/age && age-keygen -o ~/.config/sops/age/keys.txt)
chmod 600 ~/.config/sops/age/keys.txt
Public key: age1…
doctor (the last step) checks the key file is present and readable by you only: mode 0600.
2. Provision the host
provision_node.sh installs everything a Node needs, in order, and writes the appliance's .env. It takes
no arguments; the one thing it needs is the inference endpoint, in the environment. It is idempotent and
takes a while the first time (it builds the OPC UA library from source). It also reports the host's time
synchronization on a time: line, as described in A correct clock; read that line.
OLLAMA_BASE_URL=http://inference.plant.example:11434 deployment/provision_node.sh
With no certificate yet, the broker is configured with its local socket listener only.
3. Install the certificate
Install the three files the workstation made. The Node validates them first and replaces nothing if any check fails:
deployment/install_node_certificate.sh plant1 line-1 \
--cert ~/.kindred-pki/plant1/nodes/line-1/node.crt \
--key ~/.kindred-pki/plant1/nodes/line-1/node.key \
--ca-bundle ~/.kindred-pki/plant1/nodes/line-1/trust-bundle.pem
OK urn:kindred:plant1:line-1
Installed the certificate files for urn:kindred:plant1:line-1 in ~/.kindred-node-pki.
After those two lines the script runs the certificate reload hooks and prints a line for each. On a host with no Node running they say there was nothing to reload, which is expected at this point.
4. Tell the broker which CA to trust
The broker's trust anchor is set only by an administrator naming its hash, so a user who can write the Node's files cannot move it. Print the CAs the Node's bundle holds, and the hash that accepts them:
sudo deployment/configure_mosquitto.sh --print-trust-bundle-sha256
the node's trust bundle holds these CAs:
subject=CN=Kindred Site CA (plant1) sha256 Fingerprint=…
trust-bundle-sha256: …
Check the fingerprint against the one you wrote down on the workstation. If they match, run the script
again with the hash it printed (here HASH stands for that value). This adds the TLS network listener on
port 8883:
sudo deployment/configure_mosquitto.sh --trust-bundle-sha256 HASH
When the checkout is owned by the service user, as it is here, configure_mosquitto.sh warns that helper
scripts it installs for root "can be modified by a non-root user", and prints the sha256 of the helper it is
installing. That is expected for this layout. On a site that cares, check the helper against that hash, or
run the script from a root-owned copy of the repository.
5. Install the management API
The management API is how a config reaches the Node: it fetches the config from your repository, checks it
and stages it. Name the repository and the file in it. The URL is https:// or file://, with no password in
it; a file:// URL names a repository on the Node itself, which suits a test host with no server to fetch from. A private repository's credentials go in a file you
create (--repo-credentials-file), never in the URL. The service starts once it has a token.
sudo deployment/install_management_api.sh \
--repo-url https://git.example.com/plant1/kindred-config.git --repo-path config.enc.json
Installed …/kindred-management.service
Add --mint-operator-token to this command to have the install mint the first token for you (the operator
token of step 6, saved to the same file) and start the service; step 6 then begins at the reviewer's token. Left
off, step 6 does it by hand.
management-api.md describes the service, its scopes and its routes.
6. Make a token and start the service
Mint a token as the service user (not root) and save it where kindred_management.sh looks for it (skip this
mint and the restart below if step 5 was run with --mint-operator-token). The
script stores only the token's hash for the service, and shows the plaintext once. Each mint is written to
the Activity Log first and is refused if the log cannot be reached, so the database settings must be in
.env and the provisioning of the earlier steps done. A token must also be given an expiry, here 90 days
(--expires-in); the longest the node allows is MANAGEMENT_TOKEN_MAX_LIFETIME_DAYS, 180 by default:
deployment/mint_management_token.sh --id operator --scope read --scope sync \
--expires-in 90d --save-to ~/.config/kindred/management-token
The service's own file of hashes is management-token-hashes.json in the same directory. It will not start
without it, so start it now:
sudo systemctl restart kindred-management
Anyone who will approve or reject the records the Node drafts needs a token of their own. A decision is
recorded against the id of the token that made it, so mint one per person, with the signoff scope, and
hand that person the plaintext, which is shown once. Save it to a file of its own (--save-to ~/ada.tok) and name
that file in KINDRED_MANAGEMENT_TOKEN_FILE when running kindred_management.sh:
deployment/mint_management_token.sh --id rev-ada --scope signoff --expires-in 90d --save-to ~/ada.tok
The running service reads its token file again whenever it changes, so a token minted now works on its next request, with no restart. To see which tokens exist (ids, scopes and expiries, never a hash) and to remove one:
deployment/management_tokens.sh list
ID SCOPES EXPIRES
operator read, sync …
rev-ada signoff …
deployment/management_tokens.sh revoke --id NAME removes a token and retires its id (mint will not issue
it again), and the service refuses the token from its next request. That is on this node only; to revoke the id on every node of the site, use the
cascade. When a person leaves, follow
the runbook.
management-api.md says what a recorded reviewer does and does not establish.
7. Sync the config
A sync fetches the config from the repository, decrypts it with your age key, validates it and stages it. It does not start or change the running Node.
The config must be written for production first. provision_node.sh sets PRODUCTION_MODE, and in
that mode a Node refuses to start its Communication Interface without mutual TLS. The sync and the
offline check accept a config without it; the Node does not, and says so only when
it starts (step 8). The example configs under node-types/ have no tls section and no peer identity,
so they are not enough. Add both to the config's communication_interface, in the config repository:
tls, three paths, written out in full (a config file does not expand~): the files step 3 installed in the Node's PKI directory. For the service userkindredthey are/home/kindred/.kindred-node-pki/node.crt,…/node.keyand…/trust-bundle.pem. Paths only: key material never goes in the repository.identityon each peer: theurn:kindred:<site>:<instance id>in that peer's certificate, which for the ERP Node added below isurn:kindred:plant1:erp-1.listen_hostset to an address this host has. The examples carry a placeholder (10.0.0.10); a Node started with an address its host lacks stops withCannot assign requested address.- a data source the Node can reach. A MES config carries exactly one of
opcua,mqttordatabase_log, and the example'sopcuasource points at127.0.0.1:4840. With nothing listening there the reader gives up after five attempts and the Node exits; systemd then starts it again, over and over. The example'sdeviation_flagging,costing_varianceandmaterial_consumptionsections name an OPC UA node, so they go with theopcuasource; beside another source each names a field of the mapping instead, as what is allowed beside which source says.
communication-interface.md has the whole
fragment. A Node with no peers still needs tls.
A PLC / Generic Device Node has none of this. Its schema has no communication_interface, so a config that
names one is refused, and it has no listener, peers or tls to set. Its config is the opcua or the mqtt
section, and optionally deviation_rules. A PLC Node with deviation_rules needs the database and OLLAMA_BASE_URL in its
settings (a provisioned appliance has both), and the inference endpoint as well for case summaries (an
inference section in its config); one without rules needs none of these (see the PLC runtime
document). It reads no certificate, so
step 3 can be left out for it while the management API stays on loopback (its default; a management API
listening on another address serves the Node's certificate, so that case needs step 3 whatever the Node Type).
Once a config is synced or the Node has run, doctor knows the Node Type and notes that no certificate is used
instead of failing the check.
deployment/kindred_management.sh sync
The reply names the commit and hash staged. A refusal (HTTP 422) says why, and changes nothing: fix the
config in the repository and sync again. To judge a config before it goes into the repository, see
offline-check.md.
8. Install the Node's service
This installs one kindred-node.service per appliance, for the Node Type and instance id you give it.
--encrypted says the staged config is the encrypted one (leave it off for a plain config.json). The
config is already staged, so the service is started as it is installed:
sudo deployment/install_node_service.sh --node-type MES --node-instance-id line-1 --encrypted
Installed /etc/systemd/system/kindred-node.service
Started kindred-node.service
Node service installed: MES instance line-1, reading /var/lib/kindred-management/staged/config.enc.json.
Had nothing been staged, the script would say Not started and the service would stay down (a boot skips
it quietly) until you synced and ran sudo systemctl start kindred-node.
If the script says did not stay running, the Node refused the config and systemd is retrying it. Read why
with journalctl -u kindred-node.service -n 30. The usual cause on a first install is the production
settings of step 7: communication_interface has no tls section, or peers that name no identity. Fix the
config in the repository, sync, and sudo systemctl restart kindred-node.
A Node that cannot reach its data source is not caught here. The script prints Started and the Node stays up
through the reader's retries, so the exit comes some seconds later. After an install, read the log of the
current boot (journalctl -b -u kindred-node.service) and the restart count
(systemctl show kindred-node -p NRestarts), which should be 0.
9. Check the host
doctor.sh runs as the service user, needs no token, changes nothing and prints no secret. It checks, each
under its own name: services, database, broker-socket, broker-tls, sidecar, age-key,
env-file, staged-config, tokens and certificates. The tokens check names the scopes the tokens
carry, notes when none has signoff (because then no one can review), counts the revoked ids on file, and warns
of Activity Log entries for token actions that could not be written yet. It exits 0 healthy, 1 if a check failed (each is named),
2 if it could not run or could not finish a check, and 3 if the appliance is not configured yet (nothing staged, the Node never run, and no sync, bundle or draft stage recorded in the Activity Log).
deployment/doctor.sh
Healthy.
A fresh appliance exits 3 until a config has been synced: nothing is staged, the Node unit is not installed
or not started, the Node has never run here and no sync has ever staged a config, so services and
staged-config read pending rather than FAILED, and the last line says to sync a config and then install
the Node unit. That is not a fault, and a failed check (1) or one that could not finish (2) still takes
precedence over it. Nothing staged on an appliance that has run a Node, or had a config staged before, is a
failure (staged-config), since that is a damaged appliance and not a new one. Run it last, after the sync,
and expect Healthy. as above. If it names a failure, the message says what to change.
An appliance whose broker was configured before doctor read its listeners from a summary file shows
broker-tls as skipped, with the command to run: configure_mosquitto.sh again, with the options it was
first run with. That is not a failure; the check runs once the summary exists.
Adding another Node
One appliance runs one Node. For each further Node, repeat the Node steps on its own host with its own instance id; the site CA already exists, so on the workstation you only issue the new Node's certificate (the CA is left unchanged):
deployment/create_site_ca.sh plant1
deployment/issue_node_certificate.sh plant1 erp-1 --dns erp1.plant.local --ip 10.0.0.22
Site CA for 'plant1' already exists at ~/.kindred-pki/plant1; leaving it unchanged.
Issued urn:kindred:plant1:erp-1 in ~/.kindred-pki/plant1/nodes/erp-1 (valid 365 days).
The new Node needs its own age key (or a copy of one you already hold, if it will read the same encrypted
configs), its own token, and its own config path in the repository. Use --node-type ERP in step 8 for an
ERP Node, and likewise "Production Scheduling" or "PLC / Generic Device" for those. The broker's
hash in step 4 is the same on every Node of a site, because the trust bundle is the same.
Changing the config later
Commit the new config to the repository, sync, then restart the Node: a sync stages a config and never
changes the one running. To have every config checked before it is merged, see
config-repo-ci.md. To write the config in VS Code, with its rule and field names
completed and the checks a menu away, see editor-kit.md.
deployment/kindred_management.sh sync
sudo systemctl restart kindred-node
Pitfalls
- A different Node PKI directory. The default
~/.kindred-node-pkineeds nothing said. For another directory, each script learns it its own way:install_node_certificate.sh,generate_node_csr.sh,create_lab_certificate.shandlink_node_reload_hook.sh(whichprovision_node.shruns) read onlyKINDRED_NODE_PKI_DIRin their environment;configure_mosquitto.shtakes--node-pki-dirand does not read the environment (provision_node.shcalls it without one, so run it again yourself, as in step 4, with the option);install_management_api.sh --pki-dirwrites it to.env, andinstall_node_service.shand the Node's unit then use it. None of the certificate scripts read.env. - A management API on another address. The default bind is
127.0.0.1over plain HTTP, andkindred_management.shdefaults to that address. Once the service listens on the host's own address (over TLS, with the Node's certificate) the helper run on the host fails with curl exit 7, and with exit 60 if it has the address but not the CA. Give itKINDRED_MANAGEMENT_URL=https://ADDRESS:8470and setCURL_CA_BUNDLEto the site'strust-bundle.pem;doctor.shneeds neither.management-api.mddescribes the bind. - Run order matters. The management API installer needs the provisioned checkout; the Node service installer needs the state directory the management installer creates. Each says which step to run when it refuses.
- The service user, not root.
provision_node.sh, the token script anddoctor.shrun as the service user and callsudothemselves where they need it.--service-useron thesudoscripts defaults to the user who ransudo. If you reachedsudofrom a different admin account, that default names the admin, not the Node's user: pass--service-user NAME(the Node's user) toconfigure_mosquitto.sh,install_management_api.shandinstall_node_service.sh, ordoctor.shwill later refuse because the Node's unit runs as another user. - The config repository's key. A config encrypted for a different age key is staged only if this Node
can decrypt it; a sync that cannot decrypt is refused and
doctorreports the key. Put the public key from step 1 in the repository's.sops.yamlbefore the first sync. - The sync accepts a config the Node then refuses. Neither the sync nor the offline check applies the
production-mode transport rules. A config with no
communication_interface.tls, or with a peer that names noidentity, is staged, and the Node refuses it at start (step 7). --encryptedhas to match the staged file. The Node's unit reads exactly one ofconfig.jsonandconfig.enc.json; the install is refused if the other is the staged one, or if both are.- A replaced CA. After a CA replacement, run step 4 again: the broker moves its trust anchor only when an administrator names the new hash.
Before the plant is reachable
To write and check a config while the plant's servers cannot be reached, or to find the ids a connector needs, see the fixture kit. Trying a config against a stand-in target system runs the steps in order, with their output.
Rehearsing a whole site on one host
To see three Nodes, their peers and an order's trail before you install anything, make a practice site on one host. It is invented data on throwaway Nodes, not an appliance: it does not install the Node's service and says nothing about provisioning, hardening or backup. Re-run it yourself says what the host needs, the six commands, how long they take and what a run costs in model calls. Each of these then breaks the site on purpose, one question to a page:
- One late order across a site: the trail, two asks and a drafted narrative.
- A Node stopped and started: a trail that names who is missing and completes by itself.
- Two Nodes that disagree: a disagreement the trail reports and does not settle, and a record that waits for a person.
- A certificate that fails: a certificate renewed, refused, lost and replaced. Its last case ends the site.
- Answers the site will not invent: a question the documents do not answer, and a draft that stays a draft until a person decides it.
- Tampering with the Activity Log: an edit made by someone who turned the guard off, and what the check reports.
Release: v0.11.0