Commit 11e8f257 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

helm chart

parents
Loading
Loading
Loading
Loading
+50
Changes for .changelog/20261013_0010_chronos-helm-chart.md: 50 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Chronos Helm chart (backend + UI)

**Date:** 2026-10-13

## Summary
New repository with a standalone Helm chart, `helm/chronos`, that deploys the Chronos backend and UI next to an existing OpenSlice Helm release.

## Design
- **Shared with OpenSlice:** ActiveMQ Artemis (`openslice-artemis:61616`, secret `openslice-artemis-secret`) and Keycloak (realm `openslice`).
  - The token issuer is the public URL `{rootUrl}/auth/realms/openslice`.
  - JWKS is fetched in-cluster from `openslice-keycloak:8080`.
- **Own MySQL 8.4 StatefulSet**, or an external MySQL 8 server via `mysql.external.url`.
  - OpenSlice's MySQL 5.7 lacks `FOR UPDATE NOWAIT`.
- **Ingress:** subpaths on the OpenSlice host, `/chronos` for the UI and `/chronos-api` for the API.
  - Two ingress-nginx Ingress objects use a regex rewrite and `X-Forwarded-Prefix`.
  - The backend runs with `server.forward-headers-strategy=framework`.
- **Backend:**
  - 1 replica with the `Recreate` strategy, because the scheduled jobs have no cluster lock.
  - An initContainer waits for MySQL.
  - Probes: a startup probe (5 min for Flyway) plus actuator liveness/readiness.
  - `backend.config` is merged into `SPRING_APPLICATION_JSON`. Defaults: forward headers, and CORS set to `rootUrl`.
- **UI:**
  - `CHRONOS_BASE_PATH=/chronos/`.
  - Absolute `VITE_API_BASE_URL` of `{rootUrl}/chronos-api`.
  - Keycloak URL, realm and client come from values.
- **Optional `keycloak.bootstrap` Job** (post-install/upgrade hook, `kcadm.sh`):
  - It creates the `chronos.admin/requester/auditor` realm roles and the public PKCE client `chronos-ui`.
  - It is idempotent.
- **Images:** default to Harbor `harbor.intranet.pnet/osl-staging/org.etsi.osl.chronos[.ui]:latest`.

## Files
- `helm/chronos/`:
  - `Chart.yaml`, `values.yaml`, `values-openslice.example.yaml`
  - `templates/`: `_helpers.tpl`, `backend.yaml`, `ui.yaml`, `mysql.yaml`, `secrets.yaml`, `ingress.yaml`, `keycloak-bootstrap-job.yaml`, `NOTES.txt`
- `README.md`, `.gitignore`

## Related changes
- `org.etsi.osl.chronos.ui`: runtime base-path support (`CHRONOS_BASE_PATH`) and a Harbor CI pipeline.
- `org.etsi.osl.chronos`: CI comment fix and a pointer to this repository.

## Verification
- `helm lint` passes, including `--strict` with the example overlay.
- `helm template` renders for:
  - the defaults
  - the example overlay, including the bootstrap Job
  - external MySQL + `existingSecret`
  - UI and ingress disabled
  - an inline Artemis secret with an explicit host
- The rendered env was checked against `application.yml`.
- **Not verified:** installing on a live cluster, since no cluster was available.
+5
Changes for .changelog/index.md: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Changelog

| Date | Change | Description |
|---|---|---|
| 2026-10-13 | [Chronos Helm chart (backend + UI)](20261013_0010_chronos-helm-chart.md) | Standalone chart `helm/chronos`. It reuses OpenSlice's Artemis and Keycloak, bundles MySQL 8.4 or uses an external server, serves the UI at `/chronos` and the API at `/chronos-api` on the OpenSlice host, and has an optional Keycloak bootstrap Job. Lint and template matrix pass; not yet installed on a cluster |
+11
Changes for .gitignore: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Packaged charts and local overrides
*.tgz
helm/chronos/charts/
my-values*.yaml
*.local.yaml

# Editors / OS
.idea/
.vscode/
*.swp
.DS_Store
+169
Changes for README.md: 169 added lines, 0 removed lines.
Original line number Diff line number Diff line
# org.etsi.osl.chronos.deploy

Helm chart for deploying **Chronos** (the OpenSlice resource-reservation backend,
[`org.etsi.osl.chronos`](../org.etsi.osl.chronos)) and its web UI
([`org.etsi.osl.chronos.ui`](../org.etsi.osl.chronos.ui)) on Kubernetes, next to an
existing OpenSlice Helm release.

```
helm/chronos/
  Chart.yaml
  values.yaml                     all options, with comments
  values-openslice.example.yaml   minimal overlay for a release named "openslice"
  templates/
    backend.yaml                  Deployment + Service (Spring Boot, port 8888)
    ui.yaml                       Deployment + Service (nginx SPA, port 80)
    mysql.yaml                    StatefulSet + Service (MySQL 8.4, optional)
    secrets.yaml                  DB / Artemis credentials (unless existing secrets are used)
    ingress.yaml                  /chronos and /chronos-api on the OpenSlice host
    keycloak-bootstrap-job.yaml   optional: creates chronos.* roles and the UI client
```

## What the chart deploys and what it reuses

| Component | Source |
|---|---|
| Chronos backend | deployed by this chart (`backend.image`) |
| Chronos UI | deployed by this chart (`ui.image`, `ui.enabled`) |
| MySQL 8.4 | deployed by this chart (`mysql.enabled: true`), or an external MySQL 8.x (`mysql.external.url`) |
| ActiveMQ Artemis | **reused** from OpenSlice: `tcp://openslice-artemis:61616`, secret `openslice-artemis-secret` |
| Keycloak | **reused** from OpenSlice: `{rootUrl}/auth`, realm `openslice` |

**Why a separate MySQL?** OpenSlice's chart bundles MySQL 5.7. Chronos needs
MySQL 8: its conflict check uses `SELECT … FOR UPDATE NOWAIT`, and the driver is
configured for `caching_sha2_password`. Point `mysql.external.url` at any MySQL 8.x
server if you do not want the bundled StatefulSet.

**Why reuse Artemis?** Chronos talks to OpenSlice (catalog, resource inventory,
service orders) over JMS queues, so both must use the same broker.

## URLs (subpaths on the OpenSlice host)

| URL | Target |
|---|---|
| `{rootUrl}/chronos/` | UI |
| `{rootUrl}/chronos-api/api/v1/...` | REST API |
| `{rootUrl}/chronos-api/swagger-ui.html` | Swagger UI |
| `{rootUrl}/chronos-api/actuator/health` | Health |

The chart creates two Ingress objects for the same host and class as the OpenSlice
ingress, and ingress-nginx merges them with it. Each strips its prefix
(`rewrite-target: /$2`) and sets `X-Forwarded-Prefix`, so both pods still serve
from `/`. The backend runs with `server.forward-headers-strategy=framework`, so
Swagger UI and generated links include the prefix.

The UI image is environment-neutral. At container start, `CHRONOS_BASE_PATH`
(set by the chart to `{ingress.uiPath}/`) rewrites `<base href>` in `index.html`
and becomes the router basename and the Keycloak redirect URI.

The paths can be changed with `ingress.uiPath` and `ingress.apiPath`. This needs an
**ingress-nginx** controller, because the regex rewrite annotations are
nginx-specific.

## Prerequisites

- Kubernetes 1.23+, Helm 3.8+, ingress-nginx.
- An OpenSlice release (`org.etsi.osl.main/kubernetes/helm/openslice`) in the
  same namespace. The defaults assume it is named `openslice`; otherwise override
  `artemis.url`, `artemis.existingSecret`, `keycloak.internalUrl` and
  `keycloak.bootstrap.adminSecret`.
- The Chronos images. The GitLab CI of both repos pushes them to Harbor on every
  Git tag as `${HARBOR_REGISTRY}/${HARBOR_PROJECT}/org.etsi.osl.chronos[.ui]:<tag>`
  and `:latest`. The chart defaults to
  `harbor.intranet.pnet/osl-staging/...:latest`. Set `imagePullSecrets` if the
  registry needs credentials.

## Install

```bash
cp helm/chronos/values-openslice.example.yaml my-values.yaml
# edit: global.rootUrl (same as OpenSlice's rooturl), image tags, MySQL passwords

helm install chronos ./helm/chronos -n openslice -f my-values.yaml
kubectl -n openslice rollout status deploy/chronos-backend
curl {rootUrl}/chronos-api/actuator/health
```

The first boot runs the Flyway migrations. The startup probe allows up to
5 minutes (`backend.startupProbe`).

Upgrade with `helm upgrade chronos ./helm/chronos -n openslice -f my-values.yaml`.
Uninstall with `helm uninstall chronos -n openslice`. The MySQL PVC
(`data-chronos-mysql-0`) is kept and must be deleted by hand.

### Common overrides

```yaml
backend:
  # Any Spring/chronos.* property, merged into SPRING_APPLICATION_JSON.
  config:
    chronos:
      timezone: Europe/Athens
      hold:
        expiry-minutes: 120
  extraEnv:
    - name: SOME_VAR
      value: "x"

mysql:
  enabled: false
  external:
    url: jdbc:mysql://mysql8.db.svc:3306/chronos
  existingSecret: chronos-db    # keys: username, password

ingress:
  host: openslice.example.org
  tls:
    - secretName: openslice-tls
      hosts: [openslice.example.org]
```

## Keycloak

Chronos validates tokens from the OpenSlice realm:

- **Issuer:** `keycloak.issuerUri`, default `{rootUrl}/auth/realms/openslice`. This
  must equal the `iss` claim, i.e. the public URL the browser logs in through.
- **Signing keys:** `keycloak.jwkSetUri`, fetched in-cluster from `keycloak.internalUrl`.

Authorization uses the realm roles `chronos.admin`, `chronos.requester` and
`chronos.auditor`. The UI logs in through a public client, `chronos-ui` by default.
The OpenSlice realm export contains neither the roles nor the client, so they have
to be created once.

**Option 1: bootstrap Job.** Set `keycloak.bootstrap.enabled: true`, as the example
overlay does. A post-install/post-upgrade hook runs `kcadm.sh` with the admin
password from `openslice-keycloak-secret`. It creates any missing roles and the
client. An existing client is left unchanged.

**Option 2: by hand,** in the Keycloak admin console, realm `openslice`:

1. *Realm roles*: add `chronos.admin`, `chronos.requester`, `chronos.auditor`.
2. *Clients → Create*: client ID `chronos-ui`, public (access type `public`),
   standard flow on, direct access grants off.
   - Valid redirect URIs: `{rootUrl}/chronos/*`
   - Web origins: `{rootUrl}`
   - Advanced settings: PKCE code challenge method `S256`.

Either way, **assign the roles to users** (or to a group) in Keycloak. A user
without a `chronos.*` role can log in but is denied by the API.

## Operational notes

- **Single replica.** The backend runs scheduled jobs (reconciliation, hold expiry,
  overdue alerts, resource-spec registration) without a cluster lock. The
  Deployment is therefore fixed at 1 replica with the `Recreate` strategy. Do not
  scale it.
- **Secrets.** The DB and (optionally) Artemis secrets are created from inline
  values unless `mysql.existingSecret` / `artemis.existingSecret` are set. Do not
  commit real passwords to a values file. The backend restarts automatically when the
  chart-managed secrets change.
- **CORS.** `chronos.security.allowed-origins` defaults to `[global.rootUrl]`.

## Validating the chart

```bash
helm lint helm/chronos
helm lint --strict helm/chronos -f helm/chronos/values-openslice.example.yaml
helm template chronos helm/chronos -f helm/chronos/values-openslice.example.yaml
```
+11
Changes for helm/chronos/.helmignore: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
.DS_Store
.git/
.gitignore
*.swp
*.bak
*.tmp
*.orig
*~
.idea/
.vscode/
values-*.example.yaml
Loading