Commit 9e02717c authored by Christos Tranoris's avatar Christos Tranoris
Browse files

Gateway API HTTPRoute and cross-namespace Keycloak secret

parent 85c47b80
Loading
Loading
Loading
Loading
Loading
+44
Changes for .changelog/20261014_0039_gateway-api-httproute.md: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Gateway API HTTPRoute and cross-namespace Keycloak secret (chart 0.2.0)

**Date:** 2026-10-14

## Why

The osl-staging cluster exposes OpenSlice through Envoy Gateway (Gateway API), not
ingress-nginx, and the Chronos addon there runs in its own `chronos` namespace. The
chart could only render ingress-nginx `Ingress` objects, and the Keycloak bootstrap Job
could only read the admin password from an existing Secret in the release namespace.

## Changes

- `templates/httproute.yaml` (new): with `httpRoute.enabled`, one
  `gateway.networking.k8s.io/v1` HTTPRoute with a rule per prefix
  (`ingress.apiPath` → backend, `ingress.uiPath` → UI when `ui.enabled`). Each rule has
  `URLRewrite` `ReplacePrefixMatch: /` and a `RequestHeaderModifier` that sets
  `X-Forwarded-Prefix`, the equivalent of the nginx annotations. Rendering fails if
  `httpRoute.parentRefs` is empty.
- `values.yaml`: new `httpRoute.{enabled,parentRefs,hostnames,annotations}` and
  `keycloak.bootstrap.adminPassword`.
- `keycloak.bootstrap.adminPassword`: when set, `secrets.yaml` creates
  `<fullname>-keycloak-admin` (key `admin-password`). The Job reads it through the new
  helpers `chronos.keycloak.adminSecret` and `chronos.keycloak.adminSecretKey`.
- `NOTES.txt` prints the URLs when either the Ingress or the HTTPRoute is enabled.
- `Chart.yaml` version `0.2.0`.
- `.gitlab-ci.yml` lint job also renders the HTTPRoute and admin-secret variant.
- README: "Gateway API (Envoy Gateway)" and "Installing in its own namespace" sections,
  install and release examples moved to 0.2.0.

## Verification

Helm 3.16.4, locally:

- `helm lint` and `helm lint --strict` with the example overlay pass.
- The existing template matrix still renders.
- With `ingress.enabled=false,httpRoute.enabled=true,parentRefs=[osl-staging/envoy]`
  there is no Ingress and one HTTPRoute with two rules: `/chronos-api` → `chronos-backend:8888`
  and `/chronos` → `chronos-ui:80`, each with both filters. With `ui.enabled=false` there is one rule.
- `httpRoute.enabled=true` without `parentRefs` fails with a clear message.
- With `bootstrap.adminPassword` set, the Job uses `chronos-keycloak-admin`; without it,
  it uses `openslice-keycloak-secret` as before.

Not yet published: tag `v0.2.0` to push the chart to Harbor.
+1
Changes for .changelog/index.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,3 +4,4 @@
|---|---|---|
| 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 |
| 2026-10-13 | [Publish the Helm chart to Harbor (OCI)](20261013_2040_helm-chart-harbor-publishing.md) | New `.gitlab-ci.yml`: lints the chart on every push; a tag `vX.Y.Z` packages chart `X.Y.Z` and runs `helm push --plain-http` to `oci://harbor.intranet.pnet/osl-staging/chronos` using the group HARBOR_* variables. README gains install-from-Harbor and Releasing sections. CI steps verified locally; pipeline not yet run |
| 2026-10-14 | [Gateway API HTTPRoute, chart 0.2.0](20261014_0039_gateway-api-httproute.md) | Optional HTTPRoute (`httpRoute.enabled`, `parentRefs`) that strips `/chronos` and `/chronos-api` and sets `X-Forwarded-Prefix`, for Envoy Gateway clusters. New `keycloak.bootstrap.adminPassword` creates a chart-managed admin secret for installs in another namespace than OpenSlice. Lint and renders verified; not yet tagged |
+3
Changes for .gitlab-ci.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ lint:
    - helm template chronos "$CHART_DIR" -f "$CHART_DIR/values-openslice.example.yaml" > /dev/null
    - helm template chronos "$CHART_DIR" --set mysql.enabled=false
      --set mysql.external.url=jdbc:mysql://db:3306/chronos > /dev/null
    - helm template chronos "$CHART_DIR" --set ingress.enabled=false --set httpRoute.enabled=true
      --set 'httpRoute.parentRefs[0].name=gw' --set keycloak.bootstrap.enabled=true
      --set keycloak.bootstrap.adminPassword=x > /dev/null

publish:
  extends: .helm
+58 −10
Changes for README.md: 58 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ helm/chronos/
    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
    ingress.yaml                  /chronos and /chronos-api on the OpenSlice host (ingress-nginx)
    httproute.yaml                the same, as a Gateway API HTTPRoute (e.g. Envoy Gateway)
    keycloak-bootstrap-job.yaml   optional: creates chronos.* roles and the UI client
```

@@ -56,17 +57,42 @@ 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.
The paths can be changed with `ingress.uiPath` and `ingress.apiPath`. The Ingress
objects need an **ingress-nginx** controller, because the regex rewrite
annotations are nginx-specific.

### Gateway API (Envoy Gateway)

On clusters exposed through the Gateway API instead of ingress-nginx, disable the
Ingress and render an HTTPRoute:

```yaml
ingress:
  enabled: false
httpRoute:
  enabled: true
  parentRefs:
    - name: osl-staging      # the Gateway the OpenSlice routes attach to
      namespace: envoy
```

The route has one rule per prefix (same `ingress.uiPath` / `ingress.apiPath`).
Each rule strips the prefix with a `URLRewrite` (`ReplacePrefixMatch: /`) and sets
`X-Forwarded-Prefix`. `PathPrefix` matches whole path segments and the longest
prefix wins, so `/chronos` and `/chronos-api` take precedence over an OpenSlice
route on `/`, and `/chronos` does not capture `/chronos-api`. If the Gateway lives
in another namespace, its listener must allow routes from Chronos's namespace
(`allowedRoutes.namespaces`).

## Prerequisites

- Kubernetes 1.23+, Helm 3.13+ (for `--plain-http` with the Harbor registry), ingress-nginx.
- Kubernetes 1.23+, Helm 3.13+ (for `--plain-http` with the Harbor registry),
  ingress-nginx or a Gateway API implementation.
- 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`.
  `keycloak.bootstrap.adminSecret`. For an install in **another namespace** see
  [Installing in its own namespace](#installing-in-its-own-namespace).
- 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
@@ -85,10 +111,10 @@ Harbor serves plain HTTP, so every command needs `--plain-http`.
# Only if the Harbor project is private:
helm registry login harbor.intranet.pnet --insecure -u <user>

helm show values oci://harbor.intranet.pnet/osl-staging/chronos --version 0.1.0 --plain-http > my-values.yaml
helm show values oci://harbor.intranet.pnet/osl-staging/chronos --version 0.2.0 --plain-http > my-values.yaml
# edit: global.rootUrl (same as OpenSlice's rooturl), image tags, MySQL passwords

helm install chronos oci://harbor.intranet.pnet/osl-staging/chronos --version 0.1.0 \
helm install chronos oci://harbor.intranet.pnet/osl-staging/chronos --version 0.2.0 \
  --plain-http -n openslice -f my-values.yaml
```

@@ -139,6 +165,25 @@ ingress:
      hosts: [openslice.example.org]
```

### Installing in its own namespace

Chronos can run in a namespace other than OpenSlice's. Services resolve across
namespaces by their FQDN, but Secrets cannot be referenced, so let the chart
create its own copies:

```yaml
artemis:
  url: tcp://openslice-artemis.openslice.svc.cluster.local:61616
  existingSecret: ""        # create <fullname>-artemis from user/password
  user: artemis
  password: artemis         # = OpenSlice oscreds.activemq.password
keycloak:
  internalUrl: http://openslice-keycloak.openslice.svc.cluster.local:8080/auth
  bootstrap:
    enabled: true
    adminPassword: <OpenSlice Keycloak admin password>   # creates <fullname>-keycloak-admin
```

## Keycloak

Chronos validates tokens from the OpenSlice realm:
@@ -154,7 +199,8 @@ 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
password from `openslice-keycloak-secret` (or from `keycloak.bootstrap.adminPassword`,
when set). 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`:
@@ -187,6 +233,8 @@ without a `chronos.*` role can log in but is denied by the API.
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
helm template chronos helm/chronos --set ingress.enabled=false --set httpRoute.enabled=true \
  --set 'httpRoute.parentRefs[0].name=osl-staging' --set 'httpRoute.parentRefs[0].namespace=envoy'
```

## Releasing
@@ -198,7 +246,7 @@ so `Chart.yaml`'s `version` is only used for local builds.

1. Bump `appVersion` in `Chart.yaml` if the chart should now describe a newer
   Chronos release, and `version` to match the tag you are about to create.
2. `git tag v0.1.0 && git push origin v0.1.0`
2. `git tag v0.2.0 && git push origin v0.2.0`

The pipeline uses the `openslice` group variables `HARBOR_REGISTRY`,
`HARBOR_PROJECT`, `HARBOR_ROBOT_USER` and `HARBOR_ROBOT_TOKEN`, the same as the
+1 −1
Changes for helm/chronos/Chart.yaml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ description: >-
  deployed alongside an existing OpenSlice release.
type: application
# Chart version. Bump on every change to the chart or its templates (SemVer).
version: 0.1.0
version: 0.2.0
# Default image tag for the backend and the UI when no explicit tag is set.
appVersion: "1.0.0-SNAPSHOT"
home: https://osl.etsi.org
Loading