Skip to content

Architecture Deployment

Mohammad Rasoul Kazemi edited this page Dec 2, 2026 · 9 revisions

Architecture Deployment

Chapter 7 of the arc42 structure (Architecture): what is built, where it runs and which ports and files it uses. The installation steps are on Installing and Packaging and Cluster Setup; this page is the structure.

Artifacts

All artifacts are made by one build recipe from a clean snapshot of a product branch. The major is read from the source tree and never typed a second time. Target: Ubuntu 24.04, amd64. Every check of the packaging runs on a developer machine; no CI workflow of the project exists.

Artifact Name Notes
Staged tree /opt/kingres Server of the built major, client programs, all contrib modules, the five extensions, kingresd, kingres-watchdog, kingres-verify, share/BUILD-INFO
Debian package kingres_<version>+pg18-<revision>_amd64.deb or kingres_<version>+pg19-<revision>_amd64.deb One package name, the major in the version; only one can be installed on a system. The preinst script refuses to install the other major over an installed one or over a data directory of the other major
RPM package (from 0.2.0; 0.1.0 and 0.1.1 have none) kingres-pg18-<version>-<revision>.<dist>.x86_64.rpm or kingres-pg19-... with <dist> el9, el10, fc44 or fc45 One file per system (RHEL 9 and 10 families, Fedora 44 and 45), each built in a container of that system; tested on AlmaLinux 9 and 10 and Fedora 44 and 45 only. The major is in the package name and the two conflict. Contains kingres-cli and its man page. See Installing and Packaging
Container image kingres:<version>-pg18 or kingres:<version>-pg19 Minimal Ubuntu 24.04, non-root user kingres (uid and gid 10001), tini then an entry point that starts kingresd, starts uninitialized. kingres:<version> without a suffix is not produced
Development cluster docker/compose.yaml Three nodes of one image, network kingres-net, panels on 127.0.0.1:8091 to 8093, databases on 127.0.0.1:5432 to 5434

The current build (release 0.2.2, published on 2026-12-02; tags kingres-0.2.2-pg18 and kingres-0.2.2-pg19) carries kingres_shard 0.10, kingres_ledger 0.3, kingres_sketch 1.0, kingres_timepart 0.4 and kingres_columnar 0.2, on PostgreSQL 18.7 and PostgreSQL 19.0. The first release, 0.1.0, was published on 2026-11-28. The packages and images themselves are not signed, there is no apt or dnf repository and no SBOM; the images of the releases are on Docker Hub (kingres/kingres), and the product checksums (kingres-SHA256SUMS) are signed with the release key. There are RPM packages since 0.2.0; no arm64.

Deployment diagram

flowchart TB
    subgraph s1["Server 1: package or container"]
        kd1["kingresd<br/>8091 REST and console<br/>8092 internal API"]
        pg1[("PostgreSQL instance<br/>5432<br/>map group primary")]
        w1["kingres-watchdog"]
    end
    subgraph s2["Server 2"]
        kd2["kingresd"]
        pg2[("PostgreSQL instance")]
    end
    subgraph s3["Server 3"]
        kd3["kingresd"]
        pg3[("PostgreSQL instance")]
    end
    admin["Browser or REST client"]
    app["SQL client"]
    kd1 <-->|"mutual TLS, port 8092"| kd2
    kd1 <-->|"mutual TLS, port 8092"| kd3
    pg1 <-->|"PostgreSQL protocol, port 5432"| pg2
    pg1 <-->|"PostgreSQL protocol, port 5432"| pg3
    admin -->|"8091"| kd1
    app -->|"5432"| pg1
    kd1 --> pg1
    kd1 -.-> w1
Loading

The picture shows three servers as in the development cluster. A cluster has as many servers as the administrator adds; which server holds the map group primary, and so the manager leader, can change.

Ports

Port Setting Default Use
REST API and console listen 127.0.0.1:8091 (package and image: 0.0.0.0:8091 in the image) Browser, scripts. The address a server is known by in the contract
Internal API internal-listen off; it must be the port above the REST port (8092 for 8091), because a server is known to the others by its REST address and kingresd warns otherwise TLS 1.3 with mutual TLS between servers. Required to join, add or remove servers and for forwarding
PostgreSQL pg-port, pg-listen 5432, 127.0.0.1 (image: 0.0.0.0) Clients and the other servers. In a cluster pg-listen must include the address the other servers reach
Client entry point client-listen, client-standby-listen off Optional forwarding to the primary of the group, or to a local standby for reads that tolerate lag
Publication ledger-publication-listen (with optional TLS files) off Serves the published ledger to anybody, with no authentication

Between servers, open the internal API port (8092) and the PostgreSQL port (5432); the REST port is only for the console and clients. Container note: the image listens on 0.0.0.0:8091 over plain HTTP and accepts setup from other machines (KINGRES_ALLOW_REMOTE_SETUP=true), guarded only by the setup token, and its database port 5432 listens on 0.0.0.0 too. Publish both ports on 127.0.0.1 (as the compose file does) or on a private network only, or put TLS in front; the generated pg_hba.conf accepts no network login until you add rules on the network access page. Every server name must resolve, from every other server, to the address its instance listens on.

Files and directories (Debian package)

Path Content
/opt/kingres/{bin,lib,share} The product
/usr/bin/kingres-psql, kingres-pg_dump, kingres-pg_dumpall, kingres-pg_restore, kingres-pg_basebackup, kingres-pg_isready, kingres-pg_config, kingresd, kingres-verify Links into /opt/kingres/bin; the clients carry a kingres- prefix so they cannot collide with the distribution's PostgreSQL packages
/usr/lib/systemd/system/kingres.service The one service of the node
/etc/kingres/kingresd.json Settings: listen, data-dir, pg-bin-dir, socket-dir, pg-port, pg-listen, log format and level
/etc/kingres/kingresd.env Environment and secrets (mode 0600, root), for example KINGRES_METRICS_TOKEN, TLS file names
/var/lib/kingres Node state: node-state.json, setup-token (only while uninitialized), audit.jsonl, pki/, service-credentials, instances/1/pgdata
/var/lib/kingres/instances/1/pgdata/log/ PostgreSQL server log; the log of kingresd is in the journal (journalctl -u kingres)
/run/kingres/1 Unix socket of the instance

In the container image the settings are environment variables (the image has no config file) and everything the node is lives in one volume at /var/lib/kingres. Health check: GET /api/v1/readyz. The image runs with --read-only, --tmpfs /tmp, all capabilities dropped and no-new-privileges in the tests.

The service

kingres.service is Type=notify and runs as user kingres. kingresd starts the PostgreSQL instance as an independent process and leaves it running when it exits, so there are two kinds of restart: the manager only (systemctl kill --kill-whom=main --signal=SIGTERM kingres; the database keeps running and is adopted again) and everything (systemctl restart kingres, which stops the instance with a fast shutdown first). KillMode=process, Restart=always, TimeoutStopSec=120s. In a container the entry point forwards SIGTERM, then runs kingresd -stop-instances; give docker stop 120 seconds.

Sources

Clone this wiki locally