- Go 95.9%
- Just 2.4%
- Dockerfile 1.7%
| .dockerignore | ||
| .gitignore | ||
| components.go | ||
| components_test.go | ||
| config.go | ||
| config_test.go | ||
| definition.yaml | ||
| definition_test.go | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| helm.go | ||
| Justfile | ||
| LICENSE | ||
| main.go | ||
| mise.toml | ||
| plugin.go | ||
| plugin_test.go | ||
| README.md | ||
| secrets.go | ||
| secrets_test.go | ||
Bezorgdienst (delivery-service plugin)
A Fundament plugin that runs the
bezorgdienst of Notificatie voor Burgers. One installation installs five Helm
releases from the mijn-betaaloverzicht chart repository into one namespace
(NAMESPACE, default digitale-brievenbus), in this order:
| Release | What it is |
|---|---|
delivery-db |
Postgres (CloudNativePG Cluster) and the schema migrations (post-install hook) |
delivery-service |
data access, internal |
delivery-process |
the logic: adresverklaringen and zendingen, internal |
delivery-management-process |
the overview for the management screen, internal |
delivery-management-ui |
the management screen at /delivery-management; public only with a Gateway |
The releases find each other by name (http://delivery-service), so the names
are fixed and they share a namespace.
Prerequisites
- CloudNativePG: install Fundament's
cloudnativepgplugin first. The plugin checks forclusters.postgresql.cnpg.ioand stays Degraded until it exists. - Gateway API, only to publish the management screen (
HOSTNAME+GATEWAY_NAME).
Keys and Secrets
The plugin creates these in the namespace, once, and never replaces a value that exists. They are not part of a Helm release, so uninstalling keeps them.
| Object | Contents |
|---|---|
Secret delivery-api-keys |
DELIVERY_PROCESS_API_KEY, DELIVERY_MANAGEMENT_PROCESS_API_KEY (random) |
Secret delivery-process-sleutel |
DECRYPTION_KEY: the bezorgdienst's X-Wing private key (HPKE PRIVATE KEY PEM) |
ConfigMap delivery-process-publieke-sleutel |
jwks.json: the public key as a JWK Set, kid delivery-process |
A new X-Wing key makes every adreskaart unusable, which is why it is kept. The
hosters seal adresverklaringen for the public key: give jwks.json to
mailbox-host-process as deliveryServiceKeys.
kubectl -n digitale-brievenbus get configmap delivery-process-publieke-sleutel -o jsonpath='{.data.jwks\.json}'
Configuration
Set on the install form (spec.config); every key is in definition.yaml's
configSchema and read in config.go, and definition_test.go checks they agree.
| Key | Default | |
|---|---|---|
NAMESPACE |
digitale-brievenbus |
where everything runs |
TRUSTED_HOSTERS |
empty | JWK Set of trusted hosters (mailbox-host-process); empty trusts no one |
TRUSTED_DISPATCHERS |
empty | JWK Set of trusted verzenddiensten (dispatch-process) |
DISPATCH_URL |
http://dispatch-process |
where undeliverable zendingen go back |
HOSTNAME, GATEWAY_NAME, GATEWAY_NAMESPACE, GATEWAY_LISTENER |
-, -, namespace, https |
publish the management screen |
STORAGE_CLASS, STORAGE_SIZE |
cluster default, 1Gi |
the database volume |
KEEP_DATA |
true |
keep delivery-db on uninstall |
CHART_REPOSITORY, CHART_VERSION |
Forgejo Helm registry, 0.2.0 |
where the charts come from |
Lifecycle
- Start validates the configuration (invalid:
Failed), checks the prerequisites, creates the namespace and Secrets, and runshelm upgrade --install --waitfor each release in order. A failure is retried every 30s with the cause in the plugin status (Degraded), rather than crash-looping. - Reconcile reports
Runningwhile the database cluster is Ready and the four Deployments are Available,Degradedotherwise. - Uninstall removes the releases in reverse order;
delivery-dbonly withKEEP_DATA=false. The namespace and Secrets stay.
Helm runs through helm.go rather than the SDK's helper: the trust lists are
JSON, which --set cannot carry, and the database's first bootstrap needs a
longer --timeout than Helm's 5 minutes.
Layout
| Path | What it is |
|---|---|
definition.yaml |
the plugin manifest: metadata, RBAC, configSchema |
plugin.go |
lifecycle: install, health, uninstall |
components.go |
the five releases and their values |
secrets.go |
the service keys, the X-Wing key and its public JWK Set |
config.go |
the FUNP_* configuration |
helm.go |
helm upgrade --install with a values file |
Develop
Tool versions are pinned in mise.toml. With mise
installed, mise install gets Go, just, skaffold and
kubectl at the versions this project expects. Recipes live in the
Justfile; run just --list to see them all.
go mod tidy # needs network access, or a warm module cache
just build
just test
Image builds need the docker buildx plugin (with Homebrew and Colima:
brew install docker-buildx):
just docker # linux/amd64 image, also on an Apple Silicon Mac
PLATFORM=linux/arm64 just docker # for an arm64 cluster
Hot reload
functl plugin dev runs the plugin in the Fundament plugin sandbox and rebuilds
it when you save Go or console/ source, go.mod or go.sum. Changes to
definition.yaml need a restart of functl plugin dev. Prerequisites: the sandbox cluster, docker,
skaffold, kubectl, and a functl auth login session. Set up the sandbox as described in
https://github.com/fundament-oss/fundament/blob/master/docs/developer/plugins/testing-plugins-locally.md.
functl plugin dev # deletes the dev installation on Ctrl-C
functl plugin dev --no-cleanup # keeps it after exit
functl plugin dev-down # removes a leftover dev installation
Config values for spec.config (the keys in definition.yaml's configSchema)
come from --set KEY=VALUE (repeatable) or a --config YAML file; --set wins.
functl checks them against the schema before building, including required keys.
functl plugin dev --set MY_KEY=value # MY_KEY declared in configSchema
functl plugin dev --config dev-config.yaml # MY_KEY: value
Publish
From this directory, following "Testing plugins locally" in the Fundament docs:
just docker v0.2.0
docker tag delivery-service-plugin:v0.2.0 localhost:5112/delivery-service:v0.2.0
docker push localhost:5112/delivery-service:v0.2.0
functl plugin publish definition.yaml --image=localhost:5112/delivery-service@sha256:<digest from push> --create
Versions are create-only: bump metadata.version to publish changed content.
Docs
https://github.com/fundament-oss/fundament/tree/master/docs/developer/plugins