Commit 5f4e5457 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

helm chart into deploy

parent 0140d1a2
Loading
Loading
Loading
Loading
Loading
+47
Changes for .changelog/20261015_1510_gcontroller-helm-chart.md: 47 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Example generic controller Helm chart

**Date:** 2026-10-15

## What
A new repo `org.etsi.osl.examples.gcontroller.deploy`. Its layout follows `org.etsi.osl.chronos.deploy`.

- `helm/gcontroller/` (chart `gcontroller` 0.1.0, appVersion `0.1.0-SNAPSHOT`)
  - `values.yaml`:
    - image `labs.etsi.org:5050/osl/code/addons/org.etsi.osl.examples.gcontroller:latest`
    - `javaOpts`, `logLevel`
    - `controller.category` / `version` / `planningSimulatedDeployDelayMs`
    - a free-form `config` that is merged into `SPRING_APPLICATION_JSON`
    - `extraEnv`, `resources`
    - `artemis.url` / `existingSecret` / `user` / `password`
  - `values-openslice.example.yaml`: a minimal overlay for a release named `openslice`.
  - `templates/deployment.yaml`:
    - 1 replica with the `Recreate` strategy
    - `checksum/secrets` annotation
    - non-root UID 10001, no service-account token, all capabilities dropped
    - The Artemis credentials come from the secret as `SPRING_ACTIVEMQ_USER` / `SPRING_ACTIVEMQ_PASSWORD`.
  - `templates/secrets.yaml`: `<fullname>-artemis`, created only when `artemis.existingSecret` is empty.
  - `templates/NOTES.txt`, `_helpers.tpl`
- `.gitlab-ci.yml`:
  - Every push runs `helm lint` (normal and strict) and two `helm template` renders.
  - A tag `vX.Y.Z` runs `helm package --version X.Y.Z` and uploads the chart with curl to the project's GitLab Helm registry (channel `stable`) using `CI_JOB_TOKEN`. Chronos pushes to Harbor instead; this repo lives on labs.etsi.org, so it uses that GitLab's registry.
- `README.md`, `.gitignore`

## Design notes
- No Service, Ingress or probes, because the app runs with `server.port: 0` and has no HTTP API.
- It reuses OpenSlice's `openslice-artemis` service and the `openslice-artemis-secret` (keys `username`/`password`), like chronos.
- `SPRING_APPLICATION_JSON` sets these keys:
  - `spring.activemq.brokerUrl`
  - `osl-controller.category` / `version`
  - `PLANNING_SIMULATED_DEPLOY_DELAY_MS`
  - `logging.level.root` / `org.etsi.osl.example.gc`
  
  The keys were checked against `application.yml` and the `@Value` injections in the controller code.

## Verification
- `helm lint` and `helm lint --strict -f values-openslice.example.yaml` pass, with only the INFO "icon is recommended". Tested with helm v3.16.4.
- `helm template` with the defaults renders only the Deployment. `SPRING_APPLICATION_JSON` is valid JSON with the expected keys.
- `helm template --set artemis.existingSecret= --set artemis.password=x --set config.logging.level.org\.apache\.camel=DEBUG` adds the `gcontroller-artemis` Secret, and the `config` log level merges correctly.

## Not verified
- Not installed on a cluster.
- The GitLab pipeline has not run, so the publish job and the project's Helm registry are untested.
+37
Changes for .changelog/20261025_1857_merge-helm-chart-into-repo.md: 37 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Merge the Helm chart into this repo

The Helm chart used to live in the separate repo `org.etsi.osl.examples.gcontroller.deploy`. It now
ships with the controller, following the layout of `org.etsi.osl.controllers.argocd` (`deploy/helm/<chart>`).
The files were copied in one commit; the .deploy repo's single commit ("initial deploy") is not carried over.

## What moved where

| From `.deploy` | To this repo |
|---|---|
| `helm/gcontroller/` | `deploy/helm/gcontroller/` (unchanged except the usage comment in `values-openslice.example.yaml`) |
| `README.md` | `deploy/README.md` (paths now `deploy/helm/gcontroller`, run from the repo root) |
| `.gitlab-ci.yml` (`lint`, `publish`) | `.gitlab-ci.yml` (`helm_lint`, `helm_publish`) |
| `.gitignore` | merged into `.gitignore` |
| `.changelog/20261015_1510_gcontroller-helm-chart.md` | `.changelog/` (kept as history) |

## CI

- `helm_lint` runs in stage `test` on every pipeline (`needs: []`, so it does not wait for Maven).
- `helm_publish` runs in stage `post`, on tags only. It packages chart `X.Y.Z` from tag `vX.Y.Z` and uploads
  it to this project's Helm registry (channel `stable`) with the job token.
- The file declares no `stages:`, because that would override the stages of
  `org.etsi.osl.main/ci-templates/default.yml` (`.pre, build, test, post, security`).
- A tag now builds the image (tag `vX.Y.Z`, shared `docker_build`) and the chart in the same pipeline.
- The image build is unaffected: `.dockerignore` admits only the jar, so `deploy/` is not in the context.

## Registry URL

The README used project ID `522`, which is the old .deploy project. It now addresses this project by its
URL-encoded path:
`https://labs.etsi.org/rep/api/v4/projects/osl%2Fcode%2Faddons%2Forg.etsi.osl.examples.gcontroller/packages/helm/stable`.
The .deploy repo had no tags, so no chart had been published that consumers might rely on.

## Follow-up

The `org.etsi.osl.examples.gcontroller.deploy` repo is now obsolete and should be archived. It was left untouched,
including its uncommitted README change.
+2
Changes for .changelog/index.md: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

| Doc | Description |
|---|---|
| [20261025_1857_merge-helm-chart-into-repo.md](20261025_1857_merge-helm-chart-into-repo.md) | Merged the Helm chart from `org.etsi.osl.examples.gcontroller.deploy` into `deploy/helm/gcontroller` (docs in `deploy/README.md`). The CI gains `helm_lint` (every push) and `helm_publish` (tags, to this project's Helm registry) and reuses the shared template stages. The registry URL now uses this project's path. The .deploy repo is obsolete. |
| [20261022_2345_kubernetes-cluster-long-running-deployment.md](20261022_2345_kubernetes-cluster-long-running-deployment.md) | `KubernetesCluster` in production accepts the create request at once with the cluster HELD, and a background report marks it UP in the catalogue 60 s later (`osl-controller.kubernetes-cluster.provisioning-seconds`). A new `onTeardown` hook drops a pending report when the cluster is deleted. Simulation is unchanged. 124 tests pass. |
| [20261016_0011_presentation-osl-template.md](20261016_0011_presentation-osl-template.md) | Restyled `docs/creating-an-openslice-controller.pptx` to the OpenSlice promo template (`osl.promo/overview/Template.pptx`): photos with the curved edge on title and section slides, the OpenSlice logo on every layout, Cambria and Calibri fonts, the OSL blue and amber palette, and cards with a soft shadow. Same 29 slides and notes, checked in PowerPoint. No code changed. |
| [20261015_2354_controller-guide-presentation.md](20261015_2354_controller-guide-presentation.md) | New `docs/creating-an-openslice-controller.pptx`: a 29-slide deck with speaker notes generated from the generic controller guide (overview, Part 1 adapting resources, Part 2 supporting simulation, appendices). Built with pptxgenjs and checked by rendering in PowerPoint. No code changed. |
@@ -9,6 +10,7 @@
| [20261015_2332_generic-controller-guide.md](20261015_2332_generic-controller-guide.md) | New `docs/creating-an-openslice-controller.md`: language-agnostic controller contract in two parts — (1) adapting the resources of a category (OSOM routing, queues/headers, RSpec registration, health reporting, replies) and (2) supporting simulation (`/PLANNING` queues, no side effects, planning callback, HELD → UP, estimates, `estimateOnly`, timeouts). Linked from the existing guide. No code changed. |
| [20261015_1605_fix-executable-jar.md](20261015_1605_fix-executable-jar.md) | Bind `spring-boot-maven-plugin` `repackage` in `pom.xml`. With no Spring Boot parent it never ran, so the image jar had no `Main-Class` ("no main manifest attribute" on osl-staging). 119 tests pass; the jar starts locally |
| [20261015_1530_restore-weakened-test-assertions.md](20261015_1530_restore-weakened-test-assertions.md) | Re-enable the X.731 header assertions in `ResourceRepoServiceHealthTest` (without `resourceStatus`), drop the vacuous `supersedesAnEarlierConditionVerdict`, re-pin KubernetesCluster's default `operationCostPerHour` and fix its stale javadoc. 119 tests pass. |
| [20261015_1510_gcontroller-helm-chart.md](20261015_1510_gcontroller-helm-chart.md) | (Written in `org.etsi.osl.examples.gcontroller.deploy`, merged here on 2026-10-25.) Standalone chart `helm/gcontroller`, modelled on `org.etsi.osl.chronos.deploy`. One controller Deployment that reuses OpenSlice's Artemis and secret. CI lints on push and publishes tagged releases to the GitLab Helm registry. |
| [20261015_1500_dockerfile.md](20261015_1500_dockerfile.md) | Add a runtime-only `Dockerfile` (temurin 17 JRE, non-root) that packages the prebuilt jar, matching the CI `maven_build` → `docker_build` flow, plus a `.dockerignore`. |
| [20261015_1430_why-tests-fail.md](20261015_1430_why-tests-fail.md) | Diagnosis of 25 failing tests: specs stopped declaring `resourceStatus` (20), planning callback no longer sends the `org.etsi.osl.resourceStatus` header (3), and KubernetesCluster cost coefficients were recalibrated without updating its tests (2). No code changed. |
| [20261003_1734_report-held-before-up-on-create.md](20261003_1734_report-held-before-up-on-create.md) | A real (non-simulation) `createResource` now writes a partial `HELD` update to the catalog before running the spec's `resourceLogic`, so the resource goes `PENDING -> HELD -> UP` like the planning path instead of jumping straight from `PENDING` to `UP`. |
+6
Changes for .gitignore: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,3 +2,9 @@
/.apt_generated/
/.apt_generated_tests/
/.factorypath
# Helm: packaged charts, chart dependencies and local value overrides
/dist/
*.tgz
/deploy/helm/gcontroller/charts/
my-values*.yaml
*.local.yaml
+49
Changes for .gitlab-ci.yml: 49 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,22 @@ include:
    rules:
      - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_PROTECTED == "false"'

# Helm chart (deploy/helm/gcontroller). `helm_lint` lints and renders it on every push.
# On a Git tag "vX.Y.Z", `helm_publish` packages it as version X.Y.Z and uploads it to
# this project's GitLab Helm package registry (channel "stable"):
#   ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/stable
# The upload authenticates with the job token, so no extra CI/CD variables are needed.
# The jobs reuse the stages of ci-templates/default.yml; do not declare `stages:` here.

variables:
  CHART_DIR: deploy/helm/gcontroller
  HELM_CHANNEL: stable

.helm:
  image:
    name: alpine/helm:3.16.4
    entrypoint: [""]

maven_build:
  extends: .maven_build

@@ -38,3 +54,36 @@ docker_build:
  extends: .docker_build
  needs:
    - maven_build

helm_lint:
  extends: .helm
  stage: test
  needs: []
  script:
    - helm lint "$CHART_DIR"
    - helm lint --strict "$CHART_DIR" -f "$CHART_DIR/values-openslice.example.yaml"
    - helm template gcontroller "$CHART_DIR" -f "$CHART_DIR/values-openslice.example.yaml" > /dev/null
    - helm template gcontroller "$CHART_DIR" --set artemis.existingSecret=
      --set artemis.password=x --set 'config.logging.level.org\.apache\.camel=DEBUG' > /dev/null

helm_publish:
  extends: .helm
  stage: post
  needs:
    - helm_lint
  rules:
    - if: '$CI_COMMIT_TAG'
  script:
    - apk add --no-cache curl
    # helm package rejects a non-SemVer version, which fails the job.
    - VERSION="${CI_COMMIT_TAG#v}"
    - echo "Publishing chart gcontroller:${VERSION}"
    - helm package "$CHART_DIR" --version "$VERSION" -d dist
    - >-
      curl --fail-with-body --request POST
      --user "gitlab-ci-token:${CI_JOB_TOKEN}"
      --form "chart=@dist/gcontroller-${VERSION}.tgz"
      "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/${HELM_CHANNEL}/charts"
  artifacts:
    paths:
      - dist/*.tgz
Loading