- Go 80.5%
- JavaScript 16.9%
- Makefile 1.3%
- Dockerfile 0.6%
- HTML 0.5%
- Other 0.2%
| .forgejo/workflows | ||
| api/v1alpha1 | ||
| config/samples | ||
| operator | ||
| plugin | ||
| .dockerignore | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| IMPLEMENTATION_PLAN.md | ||
| LICENCE | ||
| LICENCE-NL | ||
| Makefile | ||
| README.md | ||
notification-for-citizens-plugin
The nvb-operator and its Fundament
plugin for Notificaties voor Burgers, by team Mijn Betaaloverzicht (proof of
concept). The plugin installs the operator once per cluster; every actor of
the chain is then a Party in a namespace of its own, and the operator runs
the components of that actor's role there.
Plugin (Fundament) installs the operator
├─ Party "gemeente-a" ns tnt-demo--gemeente-a role: Bronorganisatie
│ ├─ Component one per part of the role, derived by the operator
│ │ └─ Helm release of the component's chart from the Helm registry
│ └─ Component …
├─ Party "gemeente-b" ns tnt-demo--gemeente-b role: Bronorganisatie
└─ Party "bezorger" ns tnt-demo--bezorger role: Bezorgdienst
| Role | Components |
|---|---|
| Bronorganisatie | source-organization-db, -service, -process, -ui |
| Verzenddienst | dispatch-db, -service, -process, -management-process, -management-ui |
| Bezorgdienst | delivery-db, -service, -process, -management-process, -management-ui |
| Hoster | mailbox-host-db, -service, -process, -management-process, -management-ui |
| Adresregister | mock-brp-api, address-register-db, -service, -process, -management-process, -management-ui |
| AppUitgever | mailbox-app-push-gateway, mailbox-app-push-gateway-management-ui (reads the gateway's management listener; no management process), and the app configuration (no component) |
The roles are the actors of the glossary in getting-started; the rest of the API follows Kubernetes conventions.
How it works
Party(nvb.digitaledienst.overheid.nl/v1alpha1) is namespaced: it runs in the namespace it is created in, and the operator never creates namespaces. On Fundament those belong to a project (tnt-<project>--<name>). A namespace holds one Party; a second one there isFailed, because the charts render fixed object names. Its name identifies the party to the others, such as the afzender of a bronorganisatie. It holds only what differs per party: the role, the public hostname and the Secret with its keys.Componentis the internal layer. The Party controller writes one per part of the role, in the Party's namespace, owned by the Party, named after its type and carrying the chart values. The Component controller installs each as a Helm release of the same name, waits for itsdependsOn, and reports readiness from the release's Deployments and Jobs. Hand edits go inspec.overrides, which the operator never writes; the rest is overwritten.- Upgrades go in order: a Component waits until each of its
dependsOnis Ready on its current spec (and, under autoUpdate, on the newest chart), so a new version or value reaches the database (and its migration) first, then the service, then the processes and screens. - Stuck releases: a release whose latest revision has been
pending-install,pending-upgradeorpending-rollbackfor longer thanSTUCK_RELEASE_AFTER(5 minutes) is an operation that was cut off. The operator rolls it back to its newest deployed revision and reconciles again; the Component's message says so. Without a deployed revision it uninstalls the release, except a database (deletionPolicy: Retain), which it only reports asDegraded. - Shutdown: on SIGTERM the operator starts no new Helm action and lets one
in progress finish (at most 5 minutes, hooks included; the pod's
terminationGracePeriodSecondsis 420), and gives up its lease at once so the next operator takes over. - Deleting a Party deletes its Components (owner references); each
Component's finalizer then uninstalls its release, unless its
deletionPolicyisRetain(the databases). - Charts come from the Helm registry of mijn-betaaloverzicht at run time
(
CHART_REPOSITORY), resolved against its index and cached. Each component has a default version, the releaseenvironments/fundament/versionspins (operator/internal/components/versions.go;make check-versionsfails when they differ). A Component'sspec.chartVersionoverrides it with a version or a constraint such as~0.3or*. - Updates: every Component reports the newest stable chart in the
registry (
status.latestChartVersion, looked up again every ten minutes).spec.autoUpdateon a Party makes all its Components follow that newest chart; a Component with aspec.chartVersionof its own keeps it. So: a pin on the Component wins, then the Party's autoUpdate, then the default. - Secrets: the operator generates the service keys each role's charts read
(such as
source-organization-api-keys) once and keeps them; they go with the Party. - Keys: the operator also generates the party's own private keys once, in
the Secret its chart reads by default and in the forms its components read
them (go-connect, as in getting-started):
SIGNING_KEY(ECDSA P-256) for the roles that sign,DECRYPTION_KEY(X-Wing) for the bezorgdienst, adresregister and bronorganisatie, and the pushgateway's VAPID key pair andPUSHTOKEN_KEY. A key that exists is never replaced, and the Secret has no owner, so the keys stay when the Party goes: they are the party's identity, and what was sealed for it or trusts it stays valid only with them.spec.keySecretNamebrings an existing key pair along instead; the operator then only reads that Secret, and the Party fails if it lacks a key. - Public keys:
status.publicKeysis a JWK Set with the public halves, named by the kid the other parties know the party by (a bronorganisatie's name, the fixed party name of the other roles), andstatus.publicUrlits origin: what the other parties put in their trust lists. - Publishing: on Fundament the URL belongs to the namespace, so every
party gets a Gateway of its own (
spec.publication: OwnGateway, the default), serving every public path of the role under one hostname (the screens,/bronorganisatie/v1,/hoster/v1,/adresregister/v1,/push/v1;operator/internal/components/publication.go).- The hostname is the namespace name after the project prefix
tnt-<project>--, under the cluster domain from the install form:tnt-mbo-voorbeeld--nvb-hosteris served onhttps://nvb-hoster.cluster-a.fieldlab2026.nl. A namespace without the prefix gives its whole name;spec.hostnameoverrides it. - The
public-endpointscomponent, a chart that comes with the operator, is the pattern ofenvironments/fundament/gateway: a Gateway named after the party (classistio, a public address from the MetalLB pool) with an HTTP listener that only answers the ACME challenge and redirects to HTTPS, an HTTPS listener with the party's certificate, an own ACME Issuer that solves HTTP-01 through that Gateway (a ClusterIssuer of the cluster only solves through the shared one), and a DNSEndpoint that points the hostname at the Gateway's address. The operator reads that address from the Gateway's status once it has one, so the DNS record follows the first install. The charts' HTTPRoutes attach to the HTTPS listener. The Gateway'sparametersRefpoints at a ConfigMap<party>-gateway-optionsthat gives the pod Istio generates for it theRuntimeDefaultseccomp profile: cluster-a's Kyverno policyrestrict-seccomp-strictrefuses the pod without it. The operator's own charts take over objects of the same name that exist outside their release (HelmTakeOwnershipandForceConflicts), so the ConfigMaps applied by hand on cluster-a before 0.4.3 become part of the release. publication: ExistingGatewaywithspec.gatewayRefattaches the HTTPRoutes to a Gateway listener that already servesspec.hostname.publication: Nonekeeps the party inside the cluster; switching to it removes the Gateway, certificate, DNS record and routes.
- The hostname is the namespace name after the project prefix
- Connections (
spec.connections) are the other parties a Party works with: another Party in the cluster (party: {namespace, name}) or the pasted deelbericht of a party outside it (shareMessage). Every link is explicit and one-way: a verzenddienst admits a bronorganisatie only when it lists it, and the bronorganisatie lists the verzenddienst for its own side. The operator derives the process's URLs and trust lists from them (operator/internal/components/connections.go): a Party in the cluster is called on its Services (http://<service>.<namespace>.svc), a party outside it on its public URL. Which roles connect: bronorganisatie → verzenddienst, bezorgdienst, adresregister; verzenddienst → bronorganisaties, bezorgdienst; bezorgdienst → verzenddienst, hoster; hoster → bezorgdienst, app-uitgever; adresregister → bronorganisaties (its kring); app-uitgever → hoster, adresregister, bronorganisaties, none of them required. Only bronorganisaties can be more than one, because each has its own kid; the other roles share one. A connected Party without keys yet makes the Party wait (Pending); a deelbericht the components could not use, or a role it does not work with, fails it. Some connections are required before any component is installed, because the processes refuse to start without them: a bronorganisatie needs a verzenddienst, a bezorgdienst and an adresregister, a bezorgdienst a hoster and a hoster a bezorgdienst. Until then the Party isPendingwith what to connect ("koppel eerst een bezorgdienst"); its keys and deelbericht are there already, so the other side can connect back. - Deelbericht (
status.shareMessage,operator/internal/share): one JSON document withformaat(nvb-deelbericht/v1),uitleg(for whom it is),rol,naam,publiekeUrlandpubliekeSleutels(the JWK Set ofstatus.publicKeys). A pasted one is checked the way the components read keys: exactly the keys of its role, under the right kid, an https URL, and no private part. A bronorganisatie's carries itsoinanddoorverwijzentoo, when its Party has them (spec.oin, 20 digits;spec.doorverwijzen, app names, which need an oin). - App configuration (
status.appConfiguration, an app-uitgever's only,operator/internal/components/appconfiguration.go): the defines the mailbox-app is built with, as a JSON object for--dart-define-from-fileor mailbox-app-installer:MAILBOX_HOST_URL(the connected hoster's public URL),VERTROUWDE_AFZENDERS(the connected bronorganisaties' signing keys, with theiroinanddoorverwijzen),ADRESREGISTER_URLandADRESREGISTER_SLEUTEL(the connected adresregister's public URL and X-Wing key) andPUSHGATEWAY_URL(the app-uitgever's own public URL, for its pushgateway). A define whose connection is missing is left out, and the actor page says which connection it waits for. - Console: the actor's detail page (
plugin/console/actor.*) shows its status and deelbericht with a copy button, lists its connections, and adds one by choosing an actor in the project or pasting a deelbericht, optionally connecting the chosen actor back. An app-uitgever's page shows its app configuration with a copy button; the console iframe allows no downloads. "New actor…" on the list (plugin/console/actor-create.*) adds one: a role, a free namespace of the project, a name, a bronorganisatie's oin and doorverwijzen, and the connections: the ones the role cannot start without and optional ones (any number of bronorganisaties), each optionally connected back. "Publicatie en hostname bewerken" on the detail page (actor-edit.*) changes how it is published, its hostname and a bronorganisatie's oin and doorverwijzen; name, role and namespace stay. The Componenten page (components.*) lists per actor its components with the chart each runs, Bijwerken when the registry has a newer one, Alles bijwerken and the actor's Automatisch bijwerken switch; Bewerken (component-edit.*) sets a component's chart version and Helm values: what the operator derives and what is overridden on top, the rest of the chart's values under Geavanceerd, and Terug naar standaard. - The plugin is a thin installer: on every start it
helm upgrade --installs the vendored operator chart, and its status sums up the Parties. Uninstalling removes only the operator: the Parties, their Components, releases, keys and databases stay, and installing again (such as for a new plugin version, which Fundament does as uninstall and install) picks them up where they were. To remove everything, delete the actors first, while the plugin runs, and uninstall it after. - CRDs are chart templates marked
helm.sh/resource-policy: keep: Helm upgrades them, and uninstalling never deletes them (deleting a CRD deletes every Party with it).
apiVersion: nvb.digitaledienst.overheid.nl/v1alpha1
kind: Party
metadata:
name: gemeente-a # its afzender towards the rest of the chain
namespace: tnt-mbo-voorbeeld--nvb-bronorganisatie-a
spec:
role: Bronorganisatie # immutable
# publication: OwnGateway # the default; ExistingGateway (with gatewayRef) or None
connections:
- party: {namespace: tnt-mbo-voorbeeld--nvb-verzenddienst, name: verzender}
- party: {namespace: tnt-mbo-voorbeeld--nvb-bezorgdienst, name: bezorger}
- shareMessage: '{"formaat": "nvb-deelbericht/v1", "rol": "Adresregister", …}'
status:
phase: Ready
publicUrl: https://nvb-bronorganisatie-a.cluster-a.fieldlab2026.nl
gatewayAddress: 203.0.113.7
publicKeys:
keys:
- {kty: EC, crv: P-256, kid: gemeente-a, use: sig, x: …, y: …}
- {kty: OKP, crv: X-ML-KEM-768, kid: gemeente-a, use: enc, x: …}
components:
- name: source-organization-db
type: source-organization-db
phase: Ready
Layout
| Path | What |
|---|---|
api/v1alpha1 |
API types; make generate writes deepcopy code and the CRDs |
operator/cmd |
operator entry point |
operator/internal/components |
the component registry: components, order and values per role |
operator/internal/controller |
Party and Component reconcilers, key Secrets |
operator/internal/keys |
generates private keys, derives their public JWKs and checks pasted ones |
operator/internal/share |
the deelbericht: made from a Party, read from a paste |
operator/internal/helm |
Helm v4 SDK wrapper |
operator/internal/chartrepo |
fetches component charts from the Helm registry |
operator/charts |
charts that come with the operator: public-endpoints |
operator/chart |
the operator's own chart; files/crds is generated |
plugin |
Fundament plugin: lifecycle, definition.yaml and the console pages |
Development
make test
make lint
make generate # after changing api/
make run-operator # operator against $KUBECONFIG; waits while an operator in the cluster holds the lease (apply `make crds | kubectl apply --server-side -f -` first)
Adding a component
- Add its
Definitionto its role inoperator/internal/components/roles.go, and its default chart version toversions.go. - Add the type to the
ComponentTypeenum inapi/v1alpha1and runmake generate. - Add the kinds its chart renders to
operator/chart/templates/rbac.yaml.
On the local k3d cluster of getting-started
The release images are built for amd64 only, so on an arm64 Mac a component
needs the image make build in getting-started pushed to the cluster's local
registry: set spec.overrides.image.tag on the Component to the tag in
getting-started/.build/image-tags. Creating each Component beforehand with
that override and dependsOn: [wacht-op-de-party] keeps it from installing
the amd64 image first; the Party then takes it over. Without published routes
yet, port-forward the public Services and set the bronorganisatie's
config.publicBaseUrl override to the forwarded address, so the test burger
retrieves the bericht there.
Fundament sandbox
Publishing and installing the plugin locally needs the whole local Fundament
platform next to its sandbox cluster: in the Fundament repository
just cluster-start, just dev-hotreload, just plugin-sandbox-kubeconfig
and just plugins sandbox-catalog (see its "Getting started" and "Testing
plugins locally"). Keep functl for it in a config directory of its own, so a
local login never replaces the key of fundament-poc.nl:
export FUNCTL_CONFIG_DIR=~/.config/fundament-local # config.yaml: url: https://fundament.localhost:8443
make operator-push # localhost:5112/nvb-operator:<version>
make publish FLAGS=--create # a draft of the organisation, installable without review
The sandbox needs what cluster-a has: Gateway API, Istio, cert-manager, a
self-signed ClusterIssuer, CloudNativePG, and MetalLB with an L2 pool in the
k3d Docker network (k3d's own load balancer gives a second Gateway no
address). Install the plugin with a PluginInstallation that sets
OPERATOR_IMAGE to the pushed image, CLUSTER_DOMAIN=nvb.localhost,
CLUSTER_ISSUER=selfsigned, DNS_ENDPOINTS=false and ADDRESS_POOL to the
MetalLB pool. Add namespaces with functl namespace create --project=<id>
and the Parties in them. The component releases are amd64 only, so on a Mac
the sandbox runs the images make build of getting-started made, imported
with k3d image import and set as spec.overrides.image.tag on each
Component.
On Fundament
make release VERSION=X.Y.Z writes the version into the definition, the
operator chart and the operator's default image, and tags it; pushing the tag
(git push --follow-tags) builds both images for amd64 and arm64 and prints
the digest to publish:
functl plugin publish plugin/definition.yaml --create \
--image code.digitaledienst.overheid.nl/mijn-betaaloverzicht/notification-for-citizens-plugin/nvb-plugin@sha256:<digest>
Without --submit the version is a draft of your own organisation; it
installs from the console without review.
Without Fundament
make install-operator OPERATOR_IMAGE=<image>
kubectl apply -f config/samples/bronorganisatie.yaml
Known limits
- One Party per namespace, and the charts render fixed object names.
- A party outside the cluster is reached on its public URL, but the APIs between parties (verzenddienst, bezorgdienst, the hoster's bezorgingen, the bronorganisatie's retours and adreskaartleveringen) have no public route: a pasted deelbericht brings the keys, and the calls work once those APIs are published.
- One verzenddienst, bezorgdienst, hoster, adresregister and app-uitgever per party, because every party of those roles carries the same kid.