Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 38 additions & 32 deletions content/blog/sovereignty-rehydrate-demo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ images:
It is 2 a.m. when your on-call team gets an alert that a Region A datacenter is
down. The application holding customer data is unreachable, customers are
waiting, and someone in leadership is already asking for an ETA. The engineer on
duty opens the provider list and finds a healthy datacenter in Region B at the
top. If you are only looking at infrastructure health, that is where you would
send the workload next.
duty opens the agent list and finds a healthy datacenter in Region B at the top.
If you are only looking at infrastructure health, that is where you would send
the workload next.

The workload was never supposed to leave Region A. Whether the constraint comes
from GDPR, a data residency requirement, a customer contract, or an internal
Expand Down Expand Up @@ -52,8 +52,8 @@ We run the scenario on three datacenters split across two regions:
| **Region B** | `dc-demo-1` | Healthy, but off limits for this workload |

All three start healthy. Here is the twist: **Region B sorts first.** If DCM
only picked the first available provider, every new deployment would land there
by default. That is exactly the trap the sovereignty policy is meant to prevent.
only picked the first available agent, every new deployment would land there by
default. That is exactly the trap the sovereignty policy is meant to prevent.

![Two regions: Region B with dc-demo-1 (sorts first), Region A with dc-demo-2 and dc-demo-3](setup-regions.png)

Expand All @@ -76,34 +76,39 @@ If the request does not specify a target region, the policy rejects it.
Sovereignty is mandatory from day one, not something you bolt on after an audit
finding.

### Only healthy providers in the right region
### Only healthy agents in the right region

The policy asks the provider registry what is available, then filters the list.
Providers in the wrong region drop out, even if they are healthy. Providers in
the right region must also be `ready`. Region B never makes the shortlist for a
The policy asks the agent registry what is available, then filters the list.
Agents in the wrong region drop out, even if they are healthy. Agents in the
right region must also be `ready`. Region B never makes the shortlist for a
Region A workload.

### First match wins (within the region)

Among the survivors, the policy picks the first provider alphabetically. That is
Among the survivors, the policy picks the first agent alphabetically. That is
why the initial deploy lands on `dc-demo-2`, and why failover moves to
`dc-demo-3` when `dc-demo-2` fails.

{{< callout type="warning" >}} **What if an entire region goes down?**

If no healthy provider exists in the requested region, the request is rejected
with a clear error. DCM will not silently fail over across a regional boundary
to "help." That is the point. A hard failure is easier to explain to a
compliance officer than a quiet data residency violation. {{< /callout >}}
If no healthy agent exists in the requested region, the request is rejected with
a clear error. DCM will not silently fail over across a regional boundary to
"help." That is the point. A hard failure is easier to explain to a compliance
officer than a quiet data residency violation. {{< /callout >}}

> **Setup note:** Each environment agent's `environment` field must be set to
> its region code at registration time (for example `AGENT_ENVIRONMENT=region-a`
> in the compose `.env`). This is the value the policy reads to enforce
> sovereignty placement.

{{% details title="View the full Rego policy" closed="true" %}}

```rego
package provider.sovereignty
package agent.sovereignty

import rego.v1

spm_url := "http://control-plane:8080/api/v1alpha1/providers"
agents_url := "http://control-plane:8080/api/v1alpha1/agents"

main := {"rejected": true, "rejection_reason": "spec.service_type is required"} if {
not input.spec.service_type
Expand All @@ -120,30 +125,31 @@ main := result if {

response := http.send({
"method": "GET",
"url": sprintf("%s?type=%s", [spm_url, service_type]),
"url": agents_url,
"headers": {"Accept": "application/json"},
})

providers := response.body.providers
agents := response.body.agents

region_providers := [p |
some p in providers
p.health_status == "ready"
p.metadata.region_code == requested_region
region_agents := [a |
some a in agents
a.health_status == "ready"
service_type in a.service_types
a.environment == requested_region
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
Comment thread
y-first marked this conversation as resolved.
Resolved
]

result := _providers_result(region_providers, service_type, requested_region)
result := _agents_result(region_agents, service_type, requested_region)
}

_providers_result(providers, service_type, region) := {"rejected": true, "rejection_reason": msg} if {
count(providers) == 0
msg := sprintf("no ready providers in region '%s' for service type '%s'", [region, service_type])
_agents_result(agents, service_type, region) := {"rejected": true, "rejection_reason": msg} if {
count(agents) == 0
msg := sprintf("no ready agents in environment '%s' for service type '%s'", [region, service_type])
}

_providers_result(providers, _, _) := {"rejected": false, "selected_provider": provider} if {
count(providers) > 0
sorted_names := sort([p.name | some p in providers])
provider := sorted_names[0]
_agents_result(agents, _, _) := {"rejected": false, "selected_agent": agent} if {
count(agents) > 0
sorted_names := sort([a.name | some a in agents])
agent := sorted_names[0]
}
```

Expand All @@ -164,7 +170,7 @@ source of truth for everything that follows.

### 2. Simulate the outage

Take `dc-demo-2` offline (`podman stop` on the provider containers). Region B is
Take `dc-demo-2` offline (`podman stop` on the agent containers). Region B is
still healthy and still first on the list. In a typical setup, that is where the
story ends and the compliance review begins.

Expand Down Expand Up @@ -216,7 +222,7 @@ it holds on a quiet Tuesday. The rules do not relax because the pager is loud.

The best way to get a feel for the flow is our
[interactive walkthrough](https://interact.redhat.com/share/yFwS2KKEs4Zvjc3USx5j).
Click through the DCM UI at your own pace: explore the providers, create the
Click through the DCM UI at your own pace: explore the agents, create the
policy, deploy Pet Clinic, and watch where the app lands.

The walkthrough covers almost the entire scenario in the browser, including
Expand Down
2 changes: 1 addition & 1 deletion content/docs/getting-started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Get up and running with DCM.
- **[Create Small VM Catalog Item](create-small-vm-catalog-item/)** — Define and
create a catalog item for a small virtual machine.
- **[Create Placement Policy](create-placement-policy/)** — Define a placement
policy to route instances to the KubeVirt service provider.
policy to route instances to the local environment agent.
- **[Create Instance of Small VM Catalog Item](create-small-vm-instance/)** —
Deploy a VM by creating an instance of the catalog item.
- **[Register Another Provider](register-another-provider/)** — Register a
Expand Down
66 changes: 36 additions & 30 deletions content/docs/getting-started/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ weight: 1
---

DCM (Data Center Management) is a control plane for managing infrastructure
services across multiple providers. This page gives a high-level overview of how
the components fit together.
services across multiple environment agents. This page gives a high-level
overview of how the components fit together.

## Components

Expand All @@ -18,49 +18,52 @@ graph TD
CM["Catalog Manager"]
PM["Policy Manager"]
PLM["Placement Manager"]
SPM["Service Provider Manager"]
AM["Agent Manager"]
RM["SP Resource Manager"]
end

subgraph Infrastructure
PG["PostgreSQL"]
NATS["NATS"]
end

subgraph Providers
SP1["KubeVirt SP 1"]
SP2["KubeVirt SP 2"]
subgraph Agents
EA1["Environment Agent 1"]
EA2["Environment Agent 2"]
end

User --> CP

CM --> PG
PM --> PG
PLM --> PG
SPM --> PG
AM --> PG
RM --> PG

PLM --> PM
PLM --> SPM
PLM --> AM
CM --> PLM

SPM --> NATS
SP1 --> NATS
SP2 --> NATS
SP1 -->|self-register| SPM
SP2 -->|self-register| SPM
RM --> NATS
EA1 --> NATS
EA2 --> NATS
EA1 -->|register| AM
EA2 -->|register| AM
```

## Component Responsibilities

| Component | Role |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| **Control Plane** | Single process that exposes all DCM APIs on `:8080`. Hosts the catalog, policy, placement, and service provider managers in one binary. |
| **Catalog Manager** | Manages service types, catalog items, and catalog item instances. Triggers placement when an instance is created. |
| **Policy Manager** | Stores placement policies (Rego) and evaluates them via an embedded OPA engine. |
| **Placement Manager** | Selects a service provider for a new instance by evaluating policies against available providers. |
| **Service Provider Manager** | Tracks registered service providers and their health status. |
| **PostgreSQL** | Persistent storage for the control plane. |
| **NATS** | Message bus for communication between the Service Provider Manager and service providers. |
| **Service Providers** | External systems (e.g., KubeVirt) that create and manage the actual resources (VMs, containers, etc.). |
| Component | Role |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Control Plane** | Single process that exposes all DCM APIs on `:8080`. Hosts the catalog, policy, placement, agent, and SP resource managers in one binary. |
| **Catalog Manager** | Manages service types, catalog items, and catalog item instances. Triggers placement when an instance is created. |
| **Policy Manager** | Stores placement policies (Rego) and evaluates them via an embedded OPA engine. |
| **Placement Manager** | Selects an environment agent for a new instance by evaluating policies against available agents. |
| **Agent Manager** | Tracks registered environment agents and their health status. |
| **SP Resource Manager** | Manages the lifecycle of resources on service providers through environment agents. |
| **PostgreSQL** | Persistent storage for the control plane. |
| **NATS** | Message bus for communication between the SP Resource Manager and environment agents. |
| **Environment Agents** | Agents that bridge the control plane and service providers (e.g., KubeVirt). They register with the control plane and manage the actual resources (VMs, containers, etc.). |

## Request Flow

Expand All @@ -73,22 +76,25 @@ sequenceDiagram
participant CM as Catalog Manager
participant PLM as Placement Manager
participant PM as Policy Manager
participant SPM as SP Manager
participant RM as SP Resource Manager
participant EA as Environment Agent
participant SP as KubeVirt SP

User->>CP: Create catalog item instance
CP->>CM: POST /catalog-item-instances
CM->>PLM: Request placement
PLM->>PM: Evaluate policies (embedded OPA)
PM-->>PLM: Placement decision
PLM->>SPM: Create resource on provider
SPM->>SP: Create VM
PM-->>PLM: Placement decision (selected agent)
PLM->>RM: Create resource on agent
RM->>EA: Provision via NATS
EA->>SP: Create VM
SP-->>User: VM scheduling
```

1. The **Catalog Manager** receives the request and asks the **Placement
Manager** to find a suitable provider.
Manager** to find a suitable agent.
2. The **Placement Manager** evaluates placement policies through the **Policy
Manager**, which uses an embedded OPA engine to evaluate Rego.
3. Once a provider is selected, the resource is created on that provider through
the **Service Provider Manager**.
3. Once an agent is selected, the resource is created through the **SP Resource
Manager**, which sends the request to the **environment agent** via NATS. The
agent provisions the resource on the underlying service provider.
16 changes: 10 additions & 6 deletions content/docs/getting-started/create-placement-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ type: docs
weight: 4
---

Placement policies control how DCM decides which service provider should handle
Placement policies control how DCM decides which environment agent should handle
a catalog item instance. Policies are written in
[Rego](https://www.openpolicyagent.org/docs/latest/policy-language/), the policy
language used by Open Policy Agent (OPA). Each policy can accept or reject a
placement request and optionally select a specific provider.
placement request and optionally select a specific agent.

Policies have a `priority` — lower values are evaluated first.

Expand All @@ -17,24 +17,28 @@ Policies have a `priority` — lower values are evaluated first.
Create a file called `kubevirt-policy.yaml` with the following content:

```yaml
display_name: kubevirt-provider
display_name: local-agent
policy_type: GLOBAL
priority: 1
rego_code: |
package kubevirt
package local

main := {
"rejected": false,
"selected_provider": "kubevirt-service-provider"
"selected_agent": "local-agent"
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
Comment thread
y-first marked this conversation as resolved.
Resolved
}
```

This policy:

- Has the highest priority (`1`)
- Always selects `kubevirt-service-provider` as the target service provider
- Always selects `local-agent` as the target agent
- Never rejects a request (`rejected: false`)

> **Note:** The `selected_agent` value must match the name the environment agent
> registered under. The compose stack defaults to `local-agent` (`AGENT_NAME` in
> `.env`). Verify with `curl http://localhost:8080/api/v1alpha1/agents | jq`.

## Create the Policy

```bash
Expand Down
18 changes: 16 additions & 2 deletions content/docs/getting-started/local-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,26 @@ Learn how to set up and run DCM on your local machine.
## Quick Start

Clone the [control-plane](https://github.com/dcm-project/control-plane)
repository and start the core platform (postgres, nats, control-plane, and
dcm-ui):
repository, prepare the environment file, and start the core platform (postgres,
nats, control-plane, and dcm-ui):

```bash
git clone https://github.com/dcm-project/control-plane.git
cd control-plane/deploy
cp .env.example .env
```

To use the m2 release images, add the following to your `.env` file:

```ini
CONTROL_PLANE_VERSION=m2
ENVIRONMENT_AGENT_VERSION=m2
DCM_UI_VERSION=m2
```

Then start the stack:

```bash
podman-compose up -d
```

Expand Down
12 changes: 9 additions & 3 deletions content/docs/getting-started/register-another-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ type: docs
weight: 6
---
Comment thread
gciavarrini marked this conversation as resolved.
Resolved

Comment thread
gciavarrini marked this conversation as resolved.
Resolved
> **Note:** This page describes the legacy service-provider model where
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
> providers register directly with the control plane. With the environment-agent
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
> architecture, providers register with the
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
> [environment agent](/docs/getting-started/architecture/) instead, and the
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
> control plane manages agents. A rewrite of this guide is planned.

In DCM, service providers self-register by calling the Service Provider Manager
API. When you started the KubeVirt service provider in the
[Local Setup](../local-setup/), it automatically registered itself. In this
Expand Down Expand Up @@ -58,14 +64,14 @@ rego_code: |

Comment thread
gciavarrini marked this conversation as resolved.
Resolved
import rego.v1
Comment thread
gciavarrini marked this conversation as resolved.
Resolved

Comment thread
gciavarrini marked this conversation as resolved.
Resolved
providers := ["kubevirt-service-provider", "another-kubevirt-provider"]
agents := ["kubevirt-service-provider", "another-kubevirt-provider"]
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
Comment thread
y-first marked this conversation as resolved.
Resolved

Comment thread
gciavarrini marked this conversation as resolved.
Resolved
main := {
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
"rejected": false,
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
"selected_provider": providers[idx]
"selected_agent": agents[idx]
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
}
Comment thread
gciavarrini marked this conversation as resolved.
Resolved

Comment thread
gciavarrini marked this conversation as resolved.
Resolved
idx := round(rand.intn("seed", count(providers)))
idx := round(rand.intn("seed", count(agents)))
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
```
Comment thread
gciavarrini marked this conversation as resolved.
Resolved

Comment thread
gciavarrini marked this conversation as resolved.
Resolved
This Rego policy:
Comment thread
gciavarrini marked this conversation as resolved.
Resolved
Expand Down
Loading
Loading