Skip to content
Registry StackDocsv0.49.0

Package and run a Registry Discovery index

View as Markdown

If you run the index that applications search, you maintain one project directory, package each revision of it into a new directory, and restart Discovery on that package. You need the discovery-project directory and the running discovery from Publish and consume a Registry Discovery index, and a second shell at the checkout root for the commands that run beside it.

From v0.44.0, each release publishes discovery and discoveryctl for Linux amd64, Linux arm64, and macOS arm64, with an installer. Choose a tag, normally the latest release, and authenticate the assets with the verification guide. Linux assets are executables named <binary>-<tag>-linux-<arch>. macOS assets are .tar.gz bundles that carry the executable, its AWS-LC-FIPS libraries, and notices. Install the pair from one tag with the release-pinned installer:

Terminal window
tag="vX.Y.Z"
bash "discovery-${tag:?set tag to the release tag}-install.sh"
"${DISCOVERY_INSTALL_DIR:-$HOME/.local/bin}/discovery" --version
"${DISCOVERY_INSTALL_DIR:-$HOME/.local/bin}/discoveryctl" --version

The installer puts both binaries in ~/.local/bin. Set DISCOVERY_INSTALL_DIR to change that. The version checks run the binaries by that path, so they work before the directory is on your PATH. Neither path needs a Rust toolchain.

The release also publishes the image ghcr.io/registrystack/discovery:<tag> for linux/amd64. Deploy it by the digest the release manifest records, not by the tag. It runs discovery as a nonroot user and reads /etc/registry-discovery/runtime.yaml. Mount that file and the package directory read-only. Discovery writes nothing.

A provider gives you the HTTPS URL of its public description out of band. Check the project the way production does, with --production:

Terminal window
discoveryctl check --project discovery-project --production
discoveryctl check refused the input.
error[discovery.posture.loopback-catalog-url] discovery-project/origins.yaml:5:17 /origins/tutorial-evidence/catalogUrl
the index advertises an address on the reader's own machine; it is accepted only when the process declares development
next: Publish HTTPS URLs on non-loopback hosts. For a laptop or test run, start it with `rstack dev`, or declare development with REGISTRY_STACK_POSTURE=development or --posture development.
1 error, 0 warnings in 3 files

In production, write the provider’s URL as catalogUrl, one entry per provider, keyed by its own id. The steps below keep the local origin so that you can package again on your machine.

Add a file under discovery-project/mappings/ for each requirement applications resolve. A mapping may list several alternatives; the types inside one alternative are required together, and the application chooses one alternative. jurisdiction is optional, and a resolve request must match it exactly when it is set.

Stop the running discovery with Ctrl+C. In the second shell, start the publication server again:

Terminal window
python3 products/discovery/tutorial/publication_server.py \
--descriptions products/discovery/fixtures/descriptions

A package is never replaced in place. In the shell where discovery ran, packaging into the existing directory is refused:

Terminal window
discoveryctl package \
--project discovery-project \
--output discovery-project/package \
--posture development
discovery-project/package already exists; `discoveryctl package` writes a package into a new directory

Package into a new directory, and record your own revision label with it:

Terminal window
discoveryctl package \
--project discovery-project \
--output discovery-project/package-2 \
--posture development \
--revision 2
packaged packageDigest=sha256:<package-digest> catalogRevision=sha256:7e0799f2c5fd24957e4d1372f757c40abef694110eb70fc260a0abdc312ca963 mappingRevision=sha256:332004ca3920c498539180946e8f2637e9998ba7e49cd98f31e19d6f818857ac
warning[discovery.posture.loopback-catalog-url] discovery-project/package-2/discovery-index.json /origins/0/catalogUrl
the index advertises an address on the reader's own machine; production refuses it
next: Publish HTTPS URLs on non-loopback hosts.
warning[discovery.posture.loopback-catalog-url] discovery-project/package-2/discovery-index.json /services/0/originUrl
the index advertises an address on the reader's own machine; production refuses it
next: Publish HTTPS URLs on non-loopback hosts.

The two revisions are unchanged, because the descriptions and mappings mean the same. The package digest is new: it is the SHA-256 of the package’s SHA256SUMS file, which covers the index, its fetch times, and the REVISION file. A failed run leaves no directory behind. Stop the publication server with Ctrl+C.

Check the index on its own, as Discovery will read it:

Terminal window
discoveryctl check --posture development --index discovery-project/package-2/discovery-index.json
valid index origins=1 services=1 mappings=1 catalogRevision=sha256:7e0799f2c5fd24957e4d1372f757c40abef694110eb70fc260a0abdc312ca963 mappingRevision=sha256:332004ca3920c498539180946e8f2637e9998ba7e49cd98f31e19d6f818857ac
warning[discovery.posture.loopback-catalog-url] discovery-project/package-2/discovery-index.json /origins/0/catalogUrl
the index advertises an address on the reader's own machine; production refuses it
next: Publish HTTPS URLs on non-loopback hosts.
warning[discovery.posture.loopback-catalog-url] discovery-project/package-2/discovery-index.json /services/0/originUrl
the index advertises an address on the reader's own machine; production refuses it
next: Publish HTTPS URLs on non-loopback hosts.
0 errors, 2 warnings in 1 file

Pin the package you reviewed, so that Discovery refuses any other. Add the pin to discovery-project/runtime.yaml:

discovery-project/runtime.yaml
package:
root: ${DISCOVERY_PACKAGE_ROOT}
expectedDigest: ${DISCOVERY_PACKAGE_DIGEST}

Set both values. In production, copy the digest from the packaged line; here, compute it from the same file (shasum -a 256 on macOS, sha256sum on Linux):

Terminal window
export DISCOVERY_PACKAGE_ROOT="$PWD/discovery-project/package-2"
export DISCOVERY_PACKAGE_DIGEST="sha256:$(shasum -a 256 "$DISCOVERY_PACKAGE_ROOT/SHA256SUMS" | cut -d ' ' -f 1)"

Check the runtime file and its package under development:

Terminal window
discoveryctl check --runtime-config "$PWD/discovery-project/runtime.yaml" --environment --posture development
warning[discovery.posture.loopback-catalog-url] <package-index> /origins/0/catalogUrl
the index advertises an address on the reader's own machine; production refuses it
next: Publish HTTPS URLs on non-loopback hosts.
warning[discovery.posture.loopback-catalog-url] <package-index> /services/0/originUrl
the index advertises an address on the reader's own machine; production refuses it
next: Publish HTTPS URLs on non-loopback hosts.
0 errors, 2 warnings in 1 file

The check verifies the package and reports the loopback catalog and origin URL warnings. A package that fails verification is reported as discovery.runtime.package-refused at /package/root and exits 1. A package file the check cannot read exits 3. If the package root lookup fails, both check and startup report discovery.runtime.package-refused at /package/root. Offline check skips a missing package directory so you can check the runtime before building the package. Startup requires the package. Without --environment, the check reads the file without filling its ${NAME} expressions.

Discovery checks the pin before it listens. Started on the old package, it refuses:

Terminal window
DISCOVERY_PACKAGE_ROOT="$PWD/discovery-project/package" \
discovery --runtime-config "$PWD/discovery-project/runtime.yaml" --posture development
discovery: package.expectedDigest is sha256:<pinned-digest> but the package at package.root is sha256:<deployed-digest>; deploy the pinned package or update package.expectedDigest

Start it on the pinned package:

Terminal window
discovery --runtime-config "$PWD/discovery-project/runtime.yaml" --posture development

In the second shell:

Terminal window
curl -s http://127.0.0.1:38080/ready
{"developmentSettings":[{"code":"discovery.posture.loopback-catalog-url","pointer":"/origins/0/catalogUrl"},{"code":"discovery.posture.loopback-catalog-url","pointer":"/services/0/originUrl"}],"posture":"development","status":"ready"}

Before it listens, Discovery recomputes every SHA256SUMS entry and refuses a changed, missing, or extra file by name. It serves that index until it stops; a new revision always means a new package and a restart.

Discovery defaults to production and refuses loopback catalog, endpoint and origin URLs in a production package. Choose one posture across your stack. Production peers refuse responses marked as development. Discovery has no audit journal. Its declared posture appears in startup logs and /ready, and development responses carry Registry-Posture: development.

The runtime file is the whole runtime configuration: the listener, the package root and pin, the limits, and the log level. It holds no origin, mapping, credential, or trust setting. Discovery serves plain HTTP without authentication on whatever address listener.bind names, the example being 127.0.0.1:38080, so terminate TLS in front of it. Keep both paths absolute and free of symbolic links.

WhoKeepsActs whenBy
ProviderIts public descriptionIts endpoint, profile, or Evidence types changePublishing the new bytes at the approved URL
Operatororigins.yaml, mappings, runtime.yaml, the deployed packageAn origin or mapping changes, or a provider republishesCheck, package into a new directory, pin, restart
ApplicationIts saved selections and its own Evidence trustA saved selection’s service, endpoint, roles, jurisdictions, capability, mapping, or origin changes; a new catalogue revision or originContentDigest alone does notRe-deciding trust, then calling the provider directly

A republish that changes only formatting moves originContentDigest but leaves catalogRevision and every record identity alone. A change to an endpoint or a type changes the binding. originContentDigest is the SHA-256 of the exact bytes the package build fetched, so it lets anyone compare the index with what the provider publishes now. It is not a signature: it records which bytes were fetched, not who wrote them. An index that changed in place would be one nobody reviewed, so a revision always means a new package.

Discovery never trusts a provider for the application. The Registry Discovery overview explains that boundary.

SymptomCauseFix
discoveryctl check refuses a fileIt does not match its closed formatMake the edit each finding names at its line and column
Packaging cannot fetch an originThe description is unavailable or the URL breaks the fetch policyRestore the approved publication, then package into a new directory
Startup reports a digest mismatchThe package is incomplete, changed, or not the pinned oneDeploy the complete pinned package, or update package.expectedDigest
Startup says the index predates apiVersion and kindThe package was built by an older discoveryctlPackage it again, then update the pin
Startup says the package contains a retired Relay serviceThe published registry-discovery-v1alpha1 profile still validates Relay descriptions, but the current runtime serves Evidence providers onlyRemove Relay origins, package it again, then update the pin
Search returns no itemsNo indexed description matches every filterReview the indexed descriptions and the identifiers you sent

Every file Registry Discovery reads has a command that checks it offline. Each prints the diagnostics, JSON output, and exit codes that Check a file before you deploy it describes.

Format and filesCheck command
Discovery approved origins
  • origins.yaml
discoveryctl check --project <project>
Discovery Evidence mapping
  • mappings/*.yaml
discoveryctl check --project <project>
Discovery runtime configuration
  • runtime.yaml
discoveryctl check --runtime-config <file>

Stop Discovery with Ctrl+C, then remove the project and its packages:

Terminal window
rm -r discovery-project