Commit 85c47b80 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

helm ci

parent 11e8f257
Loading
Loading
Loading
Loading
+31
Changes for .changelog/20261013_2040_helm-chart-harbor-publishing.md: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Publish the Helm chart to Harbor (OCI) from GitLab CI

**Date:** 2026-10-13

## Summary
New `.gitlab-ci.yml`:
- **Every push:** lints the chart.
- **Git tag `vX.Y.Z`:** packages the chart as version `X.Y.Z` and pushes it as an OCI artifact to `oci://${HARBOR_REGISTRY}/${HARBOR_PROJECT}/chronos`, i.e. `harbor.intranet.pnet/osl-staging/chronos:X.Y.Z`, next to the Chronos images.

## Details
- **Jobs** (both use the `alpine/helm:3.16.4` image):
  - `lint`: `helm lint`, `helm lint --strict` with the example overlay, and two `helm template` renders (example overlay; external MySQL).
  - `publish`: tag pipelines only. The chart version comes from the tag with any leading `v` stripped, so `Chart.yaml` cannot drift from the release. A non-SemVer tag fails `helm package`.
- **Credentials:** the group-level variables `HARBOR_REGISTRY`, `HARBOR_PROJECT`, `HARBOR_ROBOT_USER` and `HARBOR_ROBOT_TOKEN`, the same as the image pipelines.
  - The registry auth file is written by hand, like the Kaniko jobs do (`HELM_REGISTRY_CONFIG`). This avoids `helm registry login` against the plain-HTTP Harbor.
  - The push uses `--plain-http`.
- **Project setting needed:** protect the `v*` tag pattern, because the robot variables are Protected.
- **README:**
  - New "From Harbor" install section (`helm show values` / `helm install oci://… --plain-http`).
  - New "Releasing" section.
  - Prerequisites now say Helm 3.13+, needed for `--plain-http`.
- **`.gitignore`:** `dist/` and `.helm-registry.json`.

## Verification
- Ran locally with Helm 3.16.4:
  - The `lint` script lines all pass.
  - `helm package --version 0.1.0` produces `chronos-0.1.0.tgz` (name chronos, version 0.1.0, appVersion 1.0.0-SNAPSHOT).
  - A non-SemVer version fails with "Invalid Semantic Version".
  - `helm push` supports `--plain-http`.
  - The generated auth JSON parses and decodes back to `user:token`, including a `robot$…` username.
- **Not verified:** the actual GitLab pipeline run and the push to Harbor. These need the tag pipeline.
+1
Changes for .changelog/index.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,3 +3,4 @@
| 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 |
| 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 |
+2
Changes for .gitignore: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Packaged charts and local overrides
*.tgz
dist/
.helm-registry.json
helm/chronos/charts/
my-values*.yaml
*.local.yaml
+53
Changes for .gitlab-ci.yml: 53 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Lints the Helm chart on every push. On a Git tag "vX.Y.Z" it packages the chart
# as version X.Y.Z and pushes it to Harbor as an OCI artifact:
#   oci://${HARBOR_REGISTRY}/${HARBOR_PROJECT}/chronos:X.Y.Z
#
# Uses the same group-level CI/CD variables as the image pipelines
# (HARBOR_REGISTRY, HARBOR_PROJECT, HARBOR_ROBOT_USER, HARBOR_ROBOT_TOKEN).
# Protect the "v*" tag pattern (Settings > Repository > Protected tags) so the
# Protected robot variables reach the tag pipeline.
#
# harbor.intranet.pnet serves plain HTTP only, hence --plain-http. The robot
# credentials cross the network unencrypted, which is acceptable only on the
# trusted intranet segment. Drop --plain-http once Harbor is behind TLS.

stages:
  - lint
  - publish

variables:
  CHART_DIR: helm/chronos

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

lint:
  extends: .helm
  stage: lint
  script:
    - helm lint "$CHART_DIR"
    - helm lint --strict "$CHART_DIR" -f "$CHART_DIR/values-openslice.example.yaml"
    - 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

publish:
  extends: .helm
  stage: publish
  rules:
    - if: '$CI_COMMIT_TAG'
  script:
    # helm package rejects a non-SemVer version, which fails the job.
    - VERSION="${CI_COMMIT_TAG#v}"
    - echo "Publishing chart chronos:${VERSION}"
    # Same registry auth file as the Kaniko jobs; avoids `helm registry login` over plain HTTP.
    - export HELM_REGISTRY_CONFIG="${CI_PROJECT_DIR}/.helm-registry.json"
    - >-
      echo "{\"auths\":{\"${HARBOR_REGISTRY}\":{\"auth\":\"$(printf '%s:%s' "${HARBOR_ROBOT_USER}" "${HARBOR_ROBOT_TOKEN}" | base64 | tr -d '\n')\"}}}" > "$HELM_REGISTRY_CONFIG"
    - helm package "$CHART_DIR" --version "$VERSION" -d dist
    - helm push "dist/chronos-${VERSION}.tgz" "oci://${HARBOR_REGISTRY}/${HARBOR_PROJECT}" --plain-http
  artifacts:
    paths:
      - dist/*.tgz
+39 −1
Changes for README.md: 39 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ nginx-specific.

## Prerequisites

- Kubernetes 1.23+, Helm 3.8+, ingress-nginx.
- Kubernetes 1.23+, Helm 3.13+ (for `--plain-http` with the Harbor registry), 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
@@ -75,6 +75,27 @@ nginx-specific.

## Install

### From Harbor (released chart)

Each Git tag `vX.Y.Z` of this repo publishes the chart as an OCI artifact,
`oci://harbor.intranet.pnet/osl-staging/chronos:X.Y.Z` (see [Releasing](#releasing)).
Harbor serves plain HTTP, so every command needs `--plain-http`.

```bash
# 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
# 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 \
  --plain-http -n openslice -f my-values.yaml
```

Upgrade the same way with `helm upgrade`, using the new `--version`.

### From a checkout

```bash
cp helm/chronos/values-openslice.example.yaml my-values.yaml
# edit: global.rootUrl (same as OpenSlice's rooturl), image tags, MySQL passwords
@@ -167,3 +188,20 @@ 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
```

## Releasing

The GitLab pipeline (`.gitlab-ci.yml`) lints the chart on every push. A Git tag
`vX.Y.Z` (or `X.Y.Z`) packages it as chart version `X.Y.Z` and pushes it to
`oci://${HARBOR_REGISTRY}/${HARBOR_PROJECT}/chronos`. The tag sets the version,
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`

The pipeline uses the `openslice` group variables `HARBOR_REGISTRY`,
`HARBOR_PROJECT`, `HARBOR_ROBOT_USER` and `HARBOR_ROBOT_TOKEN`, the same as the
image pipelines. The robot variables are Protected, so the `v*` tag pattern must be
protected in this project (Settings → Repository → Protected tags). Re-pushing
the same version overwrites the artifact in Harbor.