Commit c54207ed authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

Merge branch 'refactor/helm-2.0' into 'develop'

Refacto helm deployment

See merge request !15
parents 0a6667c9 faf02dd8
Loading
Loading
Loading
Loading

LICENSE

0 → 100644
+201 −0
Changes for LICENSE: 201 added lines, 0 removed lines.
Original line number Diff line number Diff line
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
+144 −38
Changes for README.md: 144 added lines, 38 removed lines.
Original line number Diff line number Diff line
@@ -9,17 +9,31 @@ Intended for local development, integration testing, and demos. **Not for produc

| Component | Namespace | Description |
|---|---|---|
| SRM (Service Resource Manager) | `oop` | Manages application artefacts and lifecycle |
| Artifact Manager | `oop` | Stores and serves artefacts |
| OEG (Open Exposure Gateway) | `oop` | Northbound API entry point for tenants |
| Federation Manager | `oop` | Inter-operator federation workflows |
| OEG (Open Exposure Gateway) | `oop` | Northbound API entry point for app providers (CAMARA APIs) |
| SRM (Service Resource Manager) | `oop` | Orchestrates services on edge clusters and networks through tf-sdk control paths |
| Federation Manager | `oop` | Inter-operator federation (GSMA OPG.04 E/WBI) |
| Keycloak | `oop` | OAuth2/OIDC identity provider: realm `oop` (portal users, app providers, OEG tokens) and realm `federation` (FM partners) |
| PostgreSQL | `oop` | Shared instance; one database and role per component |
| NATS | `oop` | Message bus between OEG, SRM and FM; JetStream on, used only by FM |
| AI2 MCP | `oop` | MCP server exposing CAMARA-compliant tools |
| AI2 AI Agent | `oop` | Natural language interface backed by Groq |
| Portal | `oop` | Developer portal: web UI and its backend (login, OEG and AI2 proxy, API clients) |
| Data Lab | `oop` | Dataspace metadata catalogue: piveau hub and search, Virtuoso, Elasticsearch, the Data Lab UI and API. Off by default, see [Data Lab](#data-lab) |

Each of OEG, SRM, Federation Manager and AI2 has its own chart README with all its values:
[OEG](oop-platform-chart/charts/oeg/README.md), [SRM](oop-platform-chart/charts/srm/README.md),
[Federation Manager](oop-platform-chart/charts/federation-manager/README.md),
[AI2](oop-platform-chart/charts/ai2/README.md).

### Architecture

App providers use the Portal or call OEG directly. **OEG** checks their Keycloak token and hands
the work to **SRM**, which deploys applications and drives the network through its tf-sdk
adapters. When a request involves another operator, OEG or SRM asks **Federation Manager**, which
talks to the partner's platform. OEG, SRM and FM also send each other events over **NATS**. OEG,
SRM, FM, Keycloak and the Portal each keep their data in their own database on the shared
**PostgreSQL**. AI2's MCP server calls OEG too.

---

## Prerequisites
@@ -61,18 +75,49 @@ Read a generated value back with, for example:
kubectl -n oop get secret postgres-credentials -o jsonpath='{.data.postgres-password}' | base64 -d
```

### Encryption keys (OEG and Federation Manager)

OEG and Federation Manager each encrypt secrets they store in their database, with a key the
chart generates on first install and keeps across upgrades and `helm uninstall`:

| Component | Secret → key | Encrypts |
|---|---|---|
| OEG | `oegcontroller-keys` → `callback-secret-key` | Webhook credentials app providers give OEG |
| Federation Manager | `federation-manager-keys` → `partner-secret-key` | Partner client secrets entered through FM's API |

**Back them up together with the database, and never change them**: data encrypted with the old
key can't be read with a new one. To read one:

```bash
kubectl -n oop get secret oegcontroller-keys -o jsonpath='{.data.callback-secret-key}' | base64 -d; echo
kubectl -n oop get secret federation-manager-keys -o jsonpath='{.data.partner-secret-key}' | base64 -d; echo
```

To use a key you already have, see "Using your own key Secret" in the
[OEG](oop-platform-chart/charts/oeg/README.md#using-your-own-key-secret) and
[Federation Manager](oop-platform-chart/charts/federation-manager/README.md#partner-secret-key) READMEs.

---

## PostgreSQL

A single shared instance (`charts/postgresql`) with one database and role per component. Not a replacement for a managed database or an operator such as CloudNativePG.

| Database / role | Used by | Password in `postgres-credentials` |
|---|---|---|
| `keycloak` | Keycloak | `keycloak-password` |
| `portal` | Portal | `portal-password` |
| `oeg` | OEG | `oeg-password` |
| `srm` | SRM | `srm-password` |
| `fm` | Federation Manager | `fm-password` |

Pick the volume size and storage class (`postgresql.persistence`) before the first install: they
come from a StatefulSet claim template, which Kubernetes does not change in place.

Give a component a database: add an entry to `postgresql.databases`, read its password from
`postgres-credentials` → `<user>-password`, and let its pods through the NetworkPolicy by labelling
them `postgres-client: "true"` or adding a selector to `postgresql.networkPolicy.allowFrom`.
them `<global.postgresql.host>-client: "true"` (`postgres-client` by default; every platform chart
does this) or adding a selector to `postgresql.networkPolicy.allowFrom`.

---

@@ -96,8 +141,8 @@ Keycloak (`charts/keycloak`) runs as a platform service in `oop`, backed by the
  through the portal; the portal checks `platform-admin` on its user pages.
- Keycloak's public URL is `http://<global.publicHost>:30081` (kind sets `publicHost: localhost`; other
  clusters detect it at install). Every token carries `iss=<public URL>/realms/<realm>`, even when a pod
  fetches it from `http://keycloak:8080`. Services only know the in-cluster URL: they read the issuer
  from Keycloak's discovery document and fetch signing keys there, so no public URL is configured in them.
  fetches it from `http://keycloak:8080`. OEG and Federation Manager expect that public issuer, built
  from the same `global.*` values, but fetch Keycloak's signing keys from the in-cluster URL.
- Tokens from `oop-portal` carry `aud: oeg` and, when the user has one, an `organization` claim.
- **Tenancy.** The user attribute `organization` is the tenant OEG scopes data by; a user without one
  is a tenant of their own (`sub`). Only administrators see or set it (lowercase letters, digits and
@@ -197,22 +242,26 @@ The scripts can also be run individually from any directory.

**`scripts/kind-bootstrap.sh`** (run once per cluster):
1. Checks prerequisites
2. Creates host storage directories at `/tmp/kind-oop/`
3. Creates the `oop-cluster` kind cluster from `environments/kind/cluster.yaml`
4. Creates namespaces (`oop`, `federation-manager`), a `oop-user` service account, and a `cluster-admin` binding
2. Creates the `oop-cluster` kind cluster from `environments/kind/cluster.yaml`
3. Waits for the node and creates the `oop` namespace

**`scripts/helm-deploy.sh`** (re-runnable):
1. Generates a short-lived token for `oop-user`
2. `helm upgrade --install oop-platform ./oop-platform-chart -n oop -f environments/kind/values.yaml`
3. `helm upgrade --install federation-manager ./oop-platform-chart/charts/federation-manager -n federation-manager -f environments/kind/values.fm.yaml`
1. Loads `environments/kind/secrets.values.yaml` if it exists
2. Updates the chart dependencies (downloads the NATS chart)
3. `helm upgrade --install oop-platform ./oop-platform-chart -n oop -f environments/kind/values.yaml`
4. Prints the [access URLs](#access-urls-after-deployment)

On kind, SRM gets a ready-made setup from `environments/kind/values.yaml`: one Kubernetes control
path `k8s-local` that deploys into namespace `oop-apps` of the kind cluster itself, and a matching
bootstrap topology with one zone.

---

## Install on another cluster

No values are required: passwords and client secrets are generated, and the public address is
detected at install time from the first node (its ExternalIP, else its InternalIP). If that is not
the address users reach, pass it once:
No values are required: passwords, client secrets and encryption keys are generated, and the public
address is detected at install time from the first node (its ExternalIP, else its InternalIP). If
that is not the address users reach, pass it once:

```bash
helm upgrade --install oop-platform ./oop-platform-chart -n oop --create-namespace \
@@ -220,49 +269,99 @@ helm upgrade --install oop-platform ./oop-platform-chart -n oop --create-namespa
```

Keycloak is then at `http://<publicHost>:30081`, and the portal's login redirects go to
`http://<publicHost>:30082`. Services inside the cluster only use `http://keycloak:8080` and read
the issuer from Keycloak's discovery document, so nothing else needs the address.
`http://<publicHost>:30082`. OEG and Federation Manager expect tokens issued by that public URL, so
the same `global.publicHost` covers them; they fetch signing keys from `http://keycloak:8080`.

- Detection reads the cluster, so it only works with `helm upgrade --install`; with `helm template` or
  GitOps tools such as Argo CD, set `global.publicHost`.
- Changing the address later does not update the redirect URLs already stored in the `oop` realm
  (realm import only runs for a new realm); update the `oop-portal` client in the admin console.
- `scripts/helm-deploy.sh` also passes SRM a token for the cluster's API, which a bare `helm` command
  does not.
- Only Keycloak and the Portal get NodePorts by default. To reach OEG, SRM or Federation Manager from
  outside, set their `service.type` and `service.nodePort` (as `environments/kind/values.yaml` does).
- SRM has no control paths or topology by default, so it can't deploy anything until you set
  `srm.controlPaths`, `topology` and `workloads.namespaces`; see the
  [SRM README](oop-platform-chart/charts/srm/README.md).
- Federation partners must reach FM's callback links: set
  `federation-manager.publicUrl`; see the
  [Federation Manager README](oop-platform-chart/charts/federation-manager/README.md#callback-links).

---

## Access URLs (after deployment)

On kind, as printed by `scripts/helm-deploy.sh`:

| Service | URL |
|---|---|
| SRM Dashboard | http://localhost:32415 |
| Artifact Manager | http://localhost:30080 |
| OEG API (Swagger) | http://localhost:32263/oeg/1.0.0/docs/ |
| SRM API | http://localhost:32415 |
| OEG API (Swagger) | http://localhost:32263/docs |
| Keycloak | http://localhost:30081 |
| Keycloak Admin | http://localhost:30081/admin — user `admin`, password in Secret `keycloak-credentials` (see [Identity](#identity-keycloak)) |
| OIDC discovery (realm `oop`) | http://localhost:30081/realms/oop/.well-known/openid-configuration |
| Federation Manager | http://localhost:30989 |
| AI2 MCP | http://localhost:32004 |
| AI2 AI Agent | http://localhost:32013 |
| Portal | http://localhost:30082 |
| Data Lab (when enabled) | http://localhost:30083 |

Inside the cluster: `http://oeg`, `http://srm:8080`, `http://federation-manager:8082` (E/WBI),
`http://federation-manager-internal:8083` (FM internal API),
`http://keycloak:8080`, `nats://oop-nats:4222`, `postgres:5432`.

---

## Upgrade

Re-run `scripts/helm-deploy.sh`, or:

```bash
# Upgrade core platform (SRM + OEG)
helm upgrade oop-platform ./oop-platform-chart \
  -n oop \
  -f environments/kind/values.yaml \
  --set srm.srmcontroller.env.kubernetesMasterToken="$(kubectl -n oop create token oop-user)"

# Upgrade Federation Manager
helm upgrade federation-manager ./oop-platform-chart/charts/federation-manager \
  -n federation-manager \
  -f environments/kind/values.fm.yaml
helm upgrade oop-platform ./oop-platform-chart -n oop -f environments/kind/values.yaml
```

Generated passwords, client secrets and encryption keys are read back from their Secrets and kept.

---

## Upgrading from 1.x

Upgrading a 1.x installation in place is **not supported**. 1.x kept OEG, SRM and Federation
Manager data in MongoDB; 2.0 uses PostgreSQL, and the old data is **not migrated**. Install 2.0
fresh:

1. Save anything you still need from the 1.x MongoDB databases.
2. Uninstall the 1.x release:

   ```bash
   helm uninstall oop-platform -n oop
   ```

3. Check that no MongoDB volume or claim is left (the 1.x charts created them, so `helm uninstall`
   normally deletes them; the data itself stays in the volumes' host directories), and delete any
   that remain:

   ```bash
   kubectl get pvc -n oop
   kubectl delete pvc -n oop <each MongoDB claim>
   kubectl get pv
   kubectl delete pv <each MongoDB volume>
   ```

4. If the 1.x bootstrap script ran on this cluster, delete the ServiceAccount it created for SRM's
   token and its cluster-admin binding; 2.0 no longer uses them:

   ```bash
   kubectl delete clusterrolebinding oop-user-binding
   kubectl -n oop delete serviceaccount oop-user
   ```

5. Install 2.0 as described above.

On kind it's simpler to start over, since `environments/kind/cluster.yaml` changed too (no MongoDB
mounts, no Artifact Manager port):

```bash
kind delete cluster --name oop-cluster
sudo rm -rf /tmp/kind-oop        # 1.x MongoDB data on the host
./deploy-on-kind.sh
```

---
@@ -271,10 +370,18 @@ helm upgrade federation-manager ./oop-platform-chart/charts/federation-manager \

```bash
helm uninstall oop-platform -n oop
helm uninstall federation-manager -n federation-manager
kind delete cluster --name oop-cluster
```

`helm uninstall` keeps some things on purpose, so a reinstall finds them again: the PostgreSQL
volume, the Secrets `postgres-credentials`, `keycloak-credentials`, `portal-credentials`,
`oegcontroller-keys` and `federation-manager-keys`, and SRM's workload namespaces (e.g. `oop-apps`).
To remove everything on a cluster you keep, also delete those, or the namespaces:

```bash
kubectl delete namespace oop oop-apps
```

---

## Configuration files
@@ -282,9 +389,9 @@ kind delete cluster --name oop-cluster
| File | Purpose |
|---|---|
| `oop-platform-chart/values.yaml` | Base defaults for all components |
| `environments/kind/values.yaml` | kind overrides (NodePorts, hostPath, storageClass, pullPolicy) |
| `environments/kind/values.yaml` | kind overrides (NodePorts, `publicHost: localhost`, SRM control path and topology, sample users) |
| `environments/kind/secrets.values.yaml` | **Gitignored.** Per-environment secrets (see [Secrets](#secrets)) |
| `environments/kind/cluster.yaml` | kind cluster definition (port mappings, host mounts) |
| `environments/kind/cluster.yaml` | kind cluster definition (port mappings) |

---

@@ -292,7 +399,6 @@ kind delete cluster --name oop-cluster

```bash
kubectl get pods -n oop
kubectl get pods -n federation-manager

# Inspect a failing pod
kubectl describe pod <pod-name> -n oop
+1 −13

File changed.

Preview size limit exceeded, changes collapsed.

+55 −47

File changed.

Preview size limit exceeded, changes collapsed.

+7 −7

File changed.

Preview size limit exceeded, changes collapsed.

Loading