Altinn / architecture-decision-log

Log for architecture decisions across Altinn teams and products
0 stars 0 forks source link

Per-app infrastructure provisioning in app clusters using Kubernetes Operators #8

Open martinothamar opened 1 month ago

martinothamar commented 1 month ago

Status

Proposed

Context

We have been working on Maskinporten automation for apps, such that scopes that are required in apps for integration with other APIs in a non-user context can be configured directly in Altinn Studio, and abstractions for requesting tokens and authorizing HTTP clients are available in the Altinn.App.Core library. In this effort we have been working to make sure the approach chosen for Maskinporten automation is generalizable to different types of infrastructure that we might want to offer service owners' apps.

At the moment, all infrastructure resources provisioned and configured on behalf of service owners are "global", so there is no support for provisioning infrastructure components per app. For Maskinporten, we need to provision 1 Maskinporten client per app.

We need a system and architectural pattern to provision infrastructure where

Decision

For use cases where we need to provision per-app infrastructure, we should use k8s Operators:

When we need to build our own operator, we should use Kubebuilder. The k8s operator pattern and controller-runtime libraries gives us APIs and a programming model where the input is desired state/configuration, and we provide the logic (the reconciliation loop) that applies the desired state to infrastructure, which in some cases is just additional k8s manifests, and in others are external resources owned by external APIs. The controller runtime has

The Kubebuilder framework brings in the controller-runtime libraries, testing setup, codegen and CLI tools to make operator development simpler.

Consequences

Diagram

The diagram below is what was agreed upon when designing the Maskinporten automation. The striped lines show how other infrastructure such as Azure Key vault and Azure PostgreSQL fit into the picture. Note that the DB in the top right corner is used as a config sync such that the infrastucture setup is not based on git.

image