diff --git a/README.md b/README.md index 17d19eb1c..189b36876 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,13 @@ Join us on the [#solr-operator](https://kubernetes.slack.com/messages/solr-opera Please visit the following pages for documentation on using and developing the Solr Operator: - [Local Tutorial](https://solr.apache.org/guide/operator/latest/getting-started/local-tutorial.html) -- [Helm Instructions via Artifact Hub](https://artifacthub.io/packages/helm/apache-solr/solr-operator) +- **Helm Chart Installation**, from either [chart source](https://solr.apache.org/guide/operator/latest/upgrade-notes/upgrade-notes.html#where-the-helm-charts-are-published): + - **OCI Charts** + - **Solr Operator**: `helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version ` + - **Solr Cloud**: `helm install solr oci://ghcr.io/apache/solr-operator/helm/solr --version ` + - **Charts Repo** (Helm 3.8+), after `helm repo add apache-solr https://solr.apache.org/charts` + - **Solr Operator**: `helm install solr-operator apache-solr/solr-operator --version ` + - **Solr Cloud**: `helm install solr apache-solr/solr --version ` - The released helm charts and their instructions should be used for all safe and stable deployments. The charts found in `helm/` are not guaranteed to be compatible with the last stable release, and should only be used for development purposes. - [Running the Solr Operator](https://solr.apache.org/guide/operator/latest/getting-started/running-the-operator.html) diff --git a/dev-docs/helm-repository.md b/dev-docs/helm-repository.md new file mode 100644 index 000000000..87290961e --- /dev/null +++ b/dev-docs/helm-repository.md @@ -0,0 +1,78 @@ +# The Helm Repository + +The Solr Operator Helm charts are distributed as OCI artifacts on the GitHub Container Registry: + +- `oci://ghcr.io/apache/solr-operator/helm/solr-operator` +- `oci://ghcr.io/apache/solr-operator/helm/solr` + +The classic Helm repository, `helm repo add apache-solr https://solr.apache.org/charts`, is kept +as well. It is an `index.yaml` checked into the [solr-site](https://github.com/apache/solr-site) +repository, at `content/charts/index.yaml`. Its entries point at the OCI copies of the charts +rather than at tarballs, so no charts are hosted on the website: + +```yaml +entries: + solr-operator: + - version: 0.10.0 + urls: + - oci://ghcr.io/apache/solr-operator/helm/solr-operator:0.10.0 + digest: + ... +``` + +The signed chart tarballs on dist.apache.org / archive.apache.org remain the official release +artifacts. The OCI copies are byte-identical to them, which is why the `digest` in the index +matches both, and why provenance (`--verify`) works through the index. + +## Helm version support + +An index with `oci://` chart urls needs Helm 3.8 or later. +[`test_oci_index.sh`](../hack/release/smoke_test/test_oci_index.sh) checks every way of consuming +the index (repo add/update, search, show, pull with and without `--verify`, install-style chart +resolution, and `helm dependency update` with a repository url or an `@alias`). It runs against +Helm 3.8.2, 3.19.0 and 4.3.1 by default. Run it locally when changing the index tooling: + +```bash +make yq +./hack/release/smoke_test/test_oci_index.sh # or -H "" to test others +``` + +It needs Docker, since the registry, the index server and each Helm version run in containers. + +## Updating the index + +[`update_helm_index.sh`](../hack/release/upload/update_helm_index.sh) adds a release to the index. +It downloads the released charts, verifies their checksums and GPG signatures, writes entries +pointing at the OCI registry, and signs the index. It never commits or uploads anything. + +A release does this in the release wizard's `website_update_helm_index` step, after the charts are +published to the OCI registry (`publish_helm_charts_oci`), and the website change is published with +the rest of the release's website updates. + +If a version is already in the index, its entry is replaced in place, keeping its original +`created` timestamp. The script refuses to do this if the chart's digest has changed, since the +OCI copy must be byte-identical to the released chart. + +## Backfilling older releases + +Releases from before the switch to OCI are listed in the index with relative tarball urls, which +the website redirects to nightlies.apache.org. To move one of them to OCI: + +1. Publish it to the OCI registry, by running the + [Publish Helm Charts to OCI Registry](https://github.com/apache/solr-operator/actions/workflows/publish-helm-oci.yaml) + workflow with its archive.apache.org chart urls, e.g. + `https://archive.apache.org/dist/solr/solr-operator/v0.9.1/helm-charts/solr-operator-0.9.1.tgz`. + Use a dry run first. +2. Rewrite its index entries, in a solr-site checkout: + ```bash + ./hack/release/upload/update_helm_index.sh \ + -r https://archive.apache.org/dist/solr/solr-operator/v0.9.1 \ + -i ../solr-site/content/charts/index.yaml + ``` +3. Commit the updated `index.yaml`, `index.yaml.asc` and `index.yaml.sha512` in solr-site. + +Versions from before the donation to Apache (`v0.2.x`) have no archive.apache.org copy, so they +are left as they are. + +Once every entry points at OCI, the `/charts/*.tgz` redirect to nightlies in solr-site's +`themes/solr/templates/htaccess.template` can be removed. diff --git a/docs/modules/getting-started/pages/local-tutorial.adoc b/docs/modules/getting-started/pages/local-tutorial.adoc index 49ff3f8b3..ee9683ccc 100644 --- a/docs/modules/getting-started/pages/local-tutorial.adoc +++ b/docs/modules/getting-started/pages/local-tutorial.adoc @@ -1,4 +1,5 @@ = Solr on Kubernetes on local Mac +:tabs-sync-option: // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information @@ -79,24 +80,43 @@ You can follow along here, or follow the instructions in the https://artifacthub Now that we have the prerequisites setup, let us install Solr Operator which will let us easily manage a large Solr cluster: -Now add the Solr Operator Helm repository. (You should only need to do this once) +First install the Solr & Zookeeper CRDs: -[source,bash] +[source,bash,subs="verbatim,attributes"] ---- -$ helm repo add apache-solr https://solr.apache.org/charts -$ helm repo update +$ kubectl create -f https://solr.apache.org/operator/downloads/crds/v{operator-version}/all-with-dependencies.yaml ---- -Next, install the Solr Operator chart. Note this is using Helm v3, in order to use Helm v2 please consult the https://hub.helm.sh/charts/solr-operator/solr-operator[Helm Chart documentation]. +Then install the Solr Operator chart. This will install the https://github.com/pravega/zookeeper-operator[Zookeeper Operator] by default. +The charts are published to the GitHub Container Registry as OCI artifacts, and are also listed in the Helm repository at `https://solr.apache.org/charts`. +Pick either, the rest of the tutorial follows your choice. +See xref:upgrade-notes:upgrade-notes.adoc#where-the-helm-charts-are-published[Where the Helm charts are published] for more. + +[tabs#install-solr-operator] +====== +OCI Charts:: ++ +==== +[source,bash,subs="verbatim,attributes"] +---- +$ helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version {operator-version} +---- +==== + +Charts Repo:: ++ +==== +Add the Helm repository once, which requires Helm `v3.8` or later: [source,bash,subs="verbatim,attributes"] ---- -# Install the Solr & Zookeeper CRDs -$ kubectl create -f https://solr.apache.org/operator/downloads/crds/v{operator-version}/all-with-dependencies.yaml -# Install the Solr operator and Zookeeper Operator +$ helm repo add apache-solr https://solr.apache.org/charts +$ helm repo update $ helm install solr-operator apache-solr/solr-operator --version {operator-version} ---- +==== +====== _Note that the Helm chart version does not contain a `v` prefix, which the downloads version does. The Helm chart version is the only part of the Solr Operator release that does not use the `v` prefix._ @@ -125,9 +145,30 @@ After inspecting the status of you Kube cluster, you should see a deployment for To start a Solr Cloud cluster, we will create a yaml that will tell the Solr Operator what version of Solr Cloud to run, and how many nodes, with how much memory etc. +Create a 3-node cluster v9.10.0 with 300m Heap each: + +[tabs#install-solr] +====== +OCI Charts:: ++ +==== +[source,bash,subs="verbatim,attributes"] +---- +helm install example-solr oci://ghcr.io/apache/solr-operator/helm/solr --version {operator-version} \ + --set image.tag=9.10.0 \ + --set solrOptions.javaMemory="-Xms300m -Xmx300m" \ + --set addressability.external.method=Ingress \ + --set addressability.external.domainName="ing.local.domain" \ + --set addressability.external.useExternalAddress="true" \ + --set ingressOptions.ingressClassName="nginx" +---- +==== + +Charts Repo:: ++ +==== [source,bash,subs="verbatim,attributes"] ---- -# Create a 3-node cluster v9.10.0 with 300m Heap each: helm install example-solr apache-solr/solr --version {operator-version} \ --set image.tag=9.10.0 \ --set solrOptions.javaMemory="-Xms300m -Xmx300m" \ @@ -135,7 +176,12 @@ helm install example-solr apache-solr/solr --version {operator-version} \ --set addressability.external.domainName="ing.local.domain" \ --set addressability.external.useExternalAddress="true" \ --set ingressOptions.ingressClassName="nginx" +---- +==== +====== +[source,bash,subs="verbatim,attributes"] +---- # The solr-operator has created a new resource type 'solrclouds' which we can query # Check the status live as the deploy happens kubectl get solrclouds -w @@ -222,12 +268,37 @@ So we wish to upgrade to a newer Solr version: ---- # Take note of the current version curl -s http://default-example-solrcloud.ing.local.domain/solr/admin/info/system | grep solr-i +---- + +Update the solrCloud configuration with the new version, keeping all previous settings and the number of nodes set by the autoscaler: -# Update the solrCloud configuration with the new version, keeping all previous settings and the number of nodes set by the autoscaler. +[tabs#upgrade-solr] +====== +OCI Charts:: ++ +==== +[source,bash,subs="verbatim,attributes"] +---- +helm upgrade example-solr oci://ghcr.io/apache/solr-operator/helm/solr --version {operator-version} \ + --reuse-values \ + --set image.tag=9.11.0 +---- +==== + +Charts Repo:: ++ +==== +[source,bash,subs="verbatim,attributes"] +---- helm upgrade example-solr apache-solr/solr --version {operator-version} \ --reuse-values \ --set image.tag=9.11.0 +---- +==== +====== +[source,bash,subs="verbatim,attributes"] +---- # Click the 'Show all details" button in Admin UI and start hitting the "Refresh" button # See how the operator upgrades one pod at a time. Solr version is in the 'node' column # You can also watch the status with the 'kubectl get solrclouds' command diff --git a/docs/modules/getting-started/pages/running-the-operator.adoc b/docs/modules/getting-started/pages/running-the-operator.adoc index 93fc388a4..dc29b6a8c 100644 --- a/docs/modules/getting-started/pages/running-the-operator.adoc +++ b/docs/modules/getting-started/pages/running-the-operator.adoc @@ -18,30 +18,54 @@ == Using the Solr Operator Helm Chart -The easiest way to run the Solr Operator is via the https://artifacthub.io/packages/helm/apache-solr/solr-operator[provided Helm Chart]. +The easiest way to run the Solr Operator is via the provided Helm Chart. The helm chart provides abstractions over the Input Arguments described below, and should work with any official images in docker hub. === How to install via Helm -The official documentation for installing the Solr Operator Helm chart can be found on https://artifacthub.io/packages/helm/apache-solr/solr-operator[Artifact Hub]. +The chart's values and changelog are listed on https://artifacthub.io/packages/helm/apache-solr/solr-operator[Artifact Hub]. -The first step is to add the Solr Operator helm repository. +First install the CRDs. This step is the same whichever chart source you use, and it is required: +the chart installs the https://github.com/pravega/zookeeper-operator[Zookeeper Operator] by default, +but does not create its `ZookeeperCluster` CRD. -[source,bash] +[source,bash,subs="verbatim,attributes"] ---- -$ helm repo add apache-solr https://solr.apache.org/charts -$ helm repo update +$ kubectl create -f https://solr.apache.org/operator/downloads/crds/v{operator-version}/all-with-dependencies.yaml ---- -Next, install the Solr Operator chart. Note this is using Helm v3, use the official Helm chart documentation linked to above. -This will install the https://github.com/pravega/zookeeper-operator[Zookeeper Operator] by default. +Then install the Solr Operator chart. +The chart is published to the GitHub Container Registry as an OCI artifact, and the Helm repository at `https://solr.apache.org/charts` lists the same chart. +Both are supported, see xref:upgrade-notes:upgrade-notes.adoc#where-the-helm-charts-are-published[Where the Helm charts are published]. +The charts are signed, and can be verified when installing, see xref:upgrade-notes:upgrade-notes.adoc#verifying-the-helm-charts[Verifying the Helm charts]. + +[tabs#install-solr-operator] +====== +OCI Charts:: ++ +==== +Nothing needs to be added or configured first, and no credentials are required. [source,bash,subs="verbatim,attributes"] ---- -$ kubectl create -f https://solr.apache.org/operator/downloads/crds/v{operator-version}/all-with-dependencies.yaml +$ helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version {operator-version} +---- +==== + +Charts Repo:: ++ +==== +This requires Helm `v3.8` or later. + +[source,bash,subs="verbatim,attributes"] +---- +$ helm repo add apache-solr https://solr.apache.org/charts +$ helm repo update $ helm install solr-operator apache-solr/solr-operator --version {operator-version} ---- +==== +====== _Note that the Helm chart version does not contain a `v` prefix, which the downloads version does. The Helm chart version is the only part of the Solr Operator release that does not use the `v` prefix._ @@ -73,9 +97,9 @@ Helm 3 automatically installs the Solr CRDs in the /crds directory, so no furthe If you have solr operator installations in multiple namespaces that are managed separately, you will likely want to skip installing CRDs when installing the chart. This can be done with the `--skip-crds` helm option. -[source,bash] +[source,bash,subs="verbatim,attributes"] ---- -helm install solr-operator apache-solr/solr-operator --skip-crds --namespace solr +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version {operator-version} --skip-crds --namespace solr ---- *Helm will not upgrade CRDs once they have been installed. diff --git a/docs/modules/upgrade-notes/pages/upgrade-notes.adoc b/docs/modules/upgrade-notes/pages/upgrade-notes.adoc index 0f1fa7778..ff746fcda 100644 --- a/docs/modules/upgrade-notes/pages/upgrade-notes.adoc +++ b/docs/modules/upgrade-notes/pages/upgrade-notes.adoc @@ -98,6 +98,92 @@ It is always encouraged to upgrade to the latest patch version of the minor and There is no need to upgrade one patch version at a time (e.g. `v0.2.5` -> `v0.2.6` -> `v0.2.7` -> `v0.2.8`), instead you can leap to the latest patch version (e.g. `v0.2.5` -> `v0.2.8`). +[#where-the-helm-charts-are-published] +== Where the Helm charts are published + +The Solr Operator and Solr Helm charts are published as OCI artifacts to the GitHub Container Registry, at `oci://ghcr.io/apache/solr-operator/helm`. +They can be installed either straight from the registry, or through the Helm repository at `https://solr.apache.org/charts`, which lists the same charts. +Both are supported. + +[tabs#helm-chart-source] +====== +OCI Charts:: ++ +==== +Installing from the OCI registry needs no `helm repo add`, and no credentials. + +[source,bash,subs="verbatim,attributes"] +---- +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version {operator-version} +helm install example oci://ghcr.io/apache/solr-operator/helm/solr --version {operator-version} +---- +==== + +Charts Repo:: ++ +==== +The Helm repository's entries point at the OCI registry, so it serves exactly the same charts. +It requires Helm `v3.8` or later, and keeps existing `helm repo add` setups and chart dependencies on `https://solr.apache.org/charts` working. + +[source,bash,subs="verbatim,attributes"] +---- +helm repo add apache-solr https://solr.apache.org/charts +helm repo update +helm install solr-operator apache-solr/solr-operator --version {operator-version} +helm install example apache-solr/solr --version {operator-version} +---- +==== +====== + +The signed chart tarballs on the Apache download mirrors remain the official release artifacts. +The OCI copies are byte-identical to them, and carry the same signatures, so the charts can be verified with either source. +See <>. + +[#verifying-the-helm-charts] +=== Verifying the Helm charts + +The charts are signed with the Solr release signing keys, and Helm can check that signature when installing or upgrading, with `--verify`. + +Helm reads keys from a keyring in the legacy GnuPG format, `~/.gnupg/pubring.gpg` by default. +GnuPG 2.1 and later no longer write that file, so import the Solr keys and export them to a keyring for Helm first: + +[source,bash] +---- +curl -sL https://dist.apache.org/repos/dist/release/solr/KEYS | gpg --import +gpg --export > ~/solr-keyring.gpg +---- + +Then pass `--verify` and the keyring to `helm install` or `helm upgrade`: + +[tabs#verify-helm-charts] +====== +OCI Charts:: ++ +==== +[source,bash,subs="verbatim,attributes"] +---- +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version {operator-version} \ + --verify --keyring ~/solr-keyring.gpg +helm install example oci://ghcr.io/apache/solr-operator/helm/solr --version {operator-version} \ + --verify --keyring ~/solr-keyring.gpg +---- +==== + +Charts Repo:: ++ +==== +[source,bash,subs="verbatim,attributes"] +---- +helm install solr-operator apache-solr/solr-operator --version {operator-version} \ + --verify --keyring ~/solr-keyring.gpg +helm install example apache-solr/solr --version {operator-version} \ + --verify --keyring ~/solr-keyring.gpg +---- +==== +====== + +Helm refuses to install a chart whose signature does not verify against the keyring. + == Installing the Solr Operator vs Solr CRDs Installing the Solr Operator, especially via the https://artifacthub.io/packages/helm/apache-solr/solr-operator[Helm Chart], @@ -128,7 +214,7 @@ If you are using the Solr Helm chart to deploy the Zookeeper operator, then you ---- # Just replace the Solr CRDs and all CRDs it might depend on (e.g. ZookeeperCluster) kubectl replace -f "http://solr.apache.org/operator/downloads/crds/v{operator-version}/all-with-dependencies.yaml" -helm upgrade solr-operator apache-solr/solr-operator --version {operator-version} +helm upgrade solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version {operator-version} ---- _Note that the Helm chart version does not contain a `v` prefix, which the downloads version does. The Helm chart version is the only part of the Solr Operator release that does not use the `v` prefix._ @@ -180,6 +266,10 @@ An existing exporter Deployment keeps running when its SolrCloud is upgraded to Delete any `SolrPrometheusExporter` for a SolrCloud before upgrading that SolrCloud to Solr 10. Instead, each Solr 10 node exposes its metrics in Prometheus format at `/solr/admin/metrics`, so Prometheus can scrape the Solr pods directly (see https://github.com/apache/solr-operator/issues/820[#820]). +* The Helm charts are now published as OCI artifacts to `oci://ghcr.io/apache/solr-operator/helm`. +The Helm repository at `https://solr.apache.org/charts` keeps working, and now lists the same OCI charts, which requires Helm `v3.8` or later. +See <>. + * The default Solr version has been upgraded from `8.11` to `9.11.0`. This only affects newly created resources, since the operator writes the resolved Solr version into the resource's spec on the first reconcile, so an operator upgrade never changes the Solr version of a running cluster. Note that a Solr `>=9.10` node refuses to start if its `major.minor` version is lower than the highest version already running in the same Solr cluster, so a rolling downgrade of Solr requires setting the `SOLR_CLOUD_DOWNGRADE_ENABLED` envVar to `true` on the pods. diff --git a/hack/release/smoke_test/test_oci_index.sh b/hack/release/smoke_test/test_oci_index.sh new file mode 100755 index 000000000..090b21a55 --- /dev/null +++ b/hack/release/smoke_test/test_oci_index.sh @@ -0,0 +1,349 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +# exit immediately when a command fails +set -e +# only exit with zero if all commands of the pipeline exit successfully +set -o pipefail +# error on unset variables +set -u + +show_help() { +cat << EOF +Usage: ./hack/release/smoke_test/test_oci_index.sh [-h] [-k] [-v VERSION] [-H HELM_VERSIONS] [-p PUSH_HELM_VERSION] + +Test that a classic Helm repository index.yaml, whose entries point at oci:// urls, works for the +ways users consume the Solr Operator Helm charts: 'helm repo add', search, show, pull, provenance +verification, install-style chart resolution and 'helm dependency update'. + +Everything runs in Docker containers on a private network, so nothing is bound on the host: + - a TLS-enabled 'registry:2', standing in for ghcr.io. TLS matters: Helm only speaks plain HTTP + to a registry when given --plain-http, which cannot be passed through an index entry. + - a static file server for the index.yaml, standing in for https://solr.apache.org/charts + - one container per Helm version under test, using the official Helm release binaries + +The charts are packaged from this checkout and signed with a throwaway GPG key, pushed with their +.prov files (as the publish-helm-oci.yaml workflow does), and indexed with +hack/release/upload/update_helm_index.sh. + + -h Display this help and exit + -v Chart version to package and test (Optional, defaults to the project version, without any + prerelease suffix, so that the default 'helm search' behaviour is exercised) + -H Space-separated Helm versions to test (Optional, defaults to "${DEFAULT_HELM_VERSIONS}") + -p Helm version used to push the charts (Optional, defaults to ${DEFAULT_PUSH_HELM_VERSION}, + the version publish-helm-oci.yaml pins) + -k Keep the containers, network and working directory after the run, for debugging + +Requires: docker, openssl, gpg, curl, helm (to package the charts) and bin/yq ('make yq'). +EOF +} + +# 3.8 is the first Helm release with OCI support out of experimental. 4.3.1 matches the +# version publish-helm-oci.yaml pins. Pass -H to test others, e.g. the latest 3.x. +DEFAULT_HELM_VERSIONS="3.8.2 3.19.0 4.3.1" +DEFAULT_PUSH_HELM_VERSION="4.3.1" + +OPTIND=1 +while getopts hkv:H:p: opt; do + case $opt in + h) + show_help + exit 0 + ;; + k) KEEP=true + ;; + v) VERSION=$OPTARG + ;; + H) HELM_VERSIONS=$OPTARG + ;; + p) PUSH_HELM_VERSION=$OPTARG + ;; + *) + show_help >&2 + exit 1 + ;; + esac +done +shift "$((OPTIND-1))" # Discard the options and sentinel -- + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" +cd "${REPO_ROOT}" + +HELM_VERSIONS="${HELM_VERSIONS:-${DEFAULT_HELM_VERSIONS}}" +PUSH_HELM_VERSION="${PUSH_HELM_VERSION:-${DEFAULT_PUSH_HELM_VERSION}}" +if [[ -z "${VERSION:-}" ]]; then + VERSION="$(make -s version)" + VERSION="${VERSION%%-*}" +fi +CHART_VERSION="${VERSION#v}" + +for tool in docker openssl gpg curl helm; do + if ! command -v "${tool}" >/dev/null 2>&1; then + echo "${tool} is required to run this test" >&2 && exit 1 + fi +done + +RUN_ID="solr-oci-index-$$" +NETWORK="${RUN_ID}" +REGISTRY_CONTAINER="${RUN_ID}-registry" +CHARTS_CONTAINER="${RUN_ID}-charts" +# Containers reach each other by these network aliases. +REGISTRY_HOST="registry" +CHARTS_HOST="charts" +OCI_BASE="oci://${REGISTRY_HOST}:5000/helm" +REPO_URL="http://${CHARTS_HOST}:8080" +CONTAINER_IMAGE="alpine:3" + +WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/solr-operator-oci-index-test-XXXXXXXX")" +# Docker Desktop shares /var/folders and /private, but not every realpath form of TMPDIR. +WORK_DIR="$(cd "${WORK_DIR}" && pwd -P)" +HELM_BIN_CACHE="${HELM_BIN_CACHE:-${TMPDIR:-/tmp}/solr-operator-helm-binaries}" + +cleanup() { + if [[ -n "${GPG_HOME:-}" ]]; then + GNUPGHOME="${GPG_HOME}" gpgconf --kill gpg-agent >/dev/null 2>&1 || true + rm -rf "${GPG_HOME}" + fi + if [[ "${KEEP:-}" == "true" ]]; then + echo "Kept the network ${NETWORK}, containers ${REGISTRY_CONTAINER} and ${CHARTS_CONTAINER}, and ${WORK_DIR}" + return + fi + docker rm -f "${REGISTRY_CONTAINER}" "${CHARTS_CONTAINER}" >/dev/null 2>&1 || true + docker network rm "${NETWORK}" >/dev/null 2>&1 || true + rm -rf "${WORK_DIR}" +} +trap cleanup EXIT + +echo "Testing an index of oci:// chart urls, for chart version ${CHART_VERSION}, with Helm ${HELM_VERSIONS}" + +# --- Helm binaries, for the architecture of the Docker engine (not the host) ---------------- + +case "$(docker info --format '{{.Architecture}}')" in + x86_64|amd64) HELM_ARCH=amd64 ;; + aarch64|arm64) HELM_ARCH=arm64 ;; + *) echo "Unsupported Docker architecture: $(docker info --format '{{.Architecture}}')" >&2 && exit 1 ;; +esac + +fetch_helm() { + local version="$1" + local dir="${HELM_BIN_CACHE}/v${version}-linux-${HELM_ARCH}" + if [[ ! -x "${dir}/helm" ]]; then + local tarball="helm-v${version}-linux-${HELM_ARCH}.tar.gz" + mkdir -p "${dir}" + echo "Downloading Helm v${version} (linux/${HELM_ARCH})" >&2 + curl --fail --show-error --silent --location -o "${dir}/${tarball}" "https://get.helm.sh/${tarball}" + expected="$(curl --fail --show-error --silent --location "https://get.helm.sh/${tarball}.sha256sum" | awk '{print $1}')" + actual="$(openssl dgst -sha256 "${dir}/${tarball}" | awk '{print $NF}')" + if [[ "${expected}" != "${actual}" ]]; then + rm -rf "${dir}" + echo "Checksum mismatch for ${tarball}" >&2 && exit 1 + fi + tar -xzf "${dir}/${tarball}" -C "${dir}" --strip-components=1 "linux-${HELM_ARCH}/helm" + rm "${dir}/${tarball}" + fi + echo "${dir}/helm" +} + +PUSH_HELM="$(fetch_helm "${PUSH_HELM_VERSION}")" +for v in ${HELM_VERSIONS}; do + fetch_helm "${v}" >/dev/null +done + +# --- TLS for the registry ---------------------------------------------------------------------- + +TLS_DIR="${WORK_DIR}/tls" +mkdir -p "${TLS_DIR}" +( + cd "${TLS_DIR}" + openssl req -x509 -newkey rsa:2048 -nodes -days 1 -subj "/CN=Solr OCI index test CA" \ + -keyout ca.key -out ca.crt 2>/dev/null + openssl req -newkey rsa:2048 -nodes -subj "/CN=${REGISTRY_HOST}" \ + -keyout registry.key -out registry.csr 2>/dev/null + printf 'subjectAltName=DNS:%s\nextendedKeyUsage=serverAuth\n' "${REGISTRY_HOST}" > registry.ext + openssl x509 -req -in registry.csr -CA ca.crt -CAkey ca.key -CAcreateserial -days 1 \ + -extfile registry.ext -out registry.crt 2>/dev/null + chmod 644 ./* +) + +# --- Throwaway signing key ----------------------------------------------------------------------- + +GPG_DIR="${WORK_DIR}/gpg" +mkdir -p "${GPG_DIR}" +# The gpg-agent socket lives in GNUPGHOME, and a unix socket path is limited to ~104 bytes. The +# macOS TMPDIR (/var/folders/...) is too long for that, so the keyring home goes under /tmp. +GPG_HOME="$(mktemp -d /tmp/solr-gpg-XXXXXX)" +chmod 700 "${GPG_HOME}" +GPG_UID="Solr OCI Index Test " +GNUPGHOME="${GPG_HOME}" gpg --batch --quiet --pinentry-mode loopback --passphrase '' \ + --quick-gen-key "${GPG_UID}" rsa2048 sign 1d +# Helm reads the legacy keyring formats, as build_helm.sh and publish-helm-oci.yaml also rely on. +GNUPGHOME="${GPG_HOME}" gpg --batch --export-secret-keys > "${GPG_DIR}/secring.gpg" +GNUPGHOME="${GPG_HOME}" gpg --batch --export > "${GPG_DIR}/pubring.gpg" +GNUPGHOME="${GPG_HOME}" gpgconf --kill gpg-agent >/dev/null 2>&1 || true +rm -rf "${GPG_HOME}" + +# --- Package and sign the charts ----------------------------------------------------------------- + +CHARTS_DIR="${WORK_DIR}/charts" +mkdir -p "${CHARTS_DIR}" +echo "Packaging and signing the charts at version ${CHART_VERSION}" +SIGNING=(--sign --key "Solr OCI Index Test" --keyring "${GPG_DIR}/secring.gpg") +# This adds the pravega repo the zookeeper-operator dependency comes from, if it is missing. +make -s helm-dependency-build >/dev/null +helm package helm/solr-operator --app-version "v${CHART_VERSION}" --version "${CHART_VERSION}" -d "${CHARTS_DIR}" "${SIGNING[@]}" >/dev/null +helm package helm/solr --version "${CHART_VERSION}" -d "${CHARTS_DIR}" "${SIGNING[@]}" >/dev/null +ls "${CHARTS_DIR}" + +# --- Registry and index server ------------------------------------------------------------------- + +docker network create "${NETWORK}" >/dev/null +docker run -d --name "${REGISTRY_CONTAINER}" --network "${NETWORK}" --network-alias "${REGISTRY_HOST}" \ + -v "${TLS_DIR}:/certs:ro" \ + -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.crt \ + -e REGISTRY_HTTP_TLS_KEY=/certs/registry.key \ + registry:2 >/dev/null + +SITE_DIR="${WORK_DIR}/site" +mkdir -p "${SITE_DIR}" +docker run -d --name "${CHARTS_CONTAINER}" --network "${NETWORK}" --network-alias "${CHARTS_HOST}" \ + -v "${SITE_DIR}:/srv:ro" \ + busybox:stable httpd -f -p 8080 -h /srv >/dev/null + +# Runs a command with the given Helm binary, in a container on the test network. +in_helm_container() { + local helm_bin="$1"; shift + docker run --rm --network "${NETWORK}" \ + -v "${helm_bin}:/usr/local/bin/helm:ro" \ + -v "${WORK_DIR}:/work:ro" \ + -e SSL_CERT_FILE=/work/tls/ca.crt \ + -e HELM_CONFIG_HOME=/tmp/helm/config \ + -e HELM_CACHE_HOME=/tmp/helm/cache \ + -e HELM_DATA_HOME=/tmp/helm/data \ + "$@" +} + +# --- Push, the way publish-helm-oci.yaml does: the .prov next to each chart is uploaded too ------ + +echo "Pushing the charts to ${OCI_BASE} with Helm v${PUSH_HELM_VERSION}" +pushed=false +for attempt in 1 2 3 4 5 6 7 8 9 10; do + if in_helm_container "${PUSH_HELM}" "${CONTAINER_IMAGE}" sh -c " + set -e + helm push /work/charts/solr-operator-${CHART_VERSION}.tgz ${OCI_BASE} + helm push /work/charts/solr-${CHART_VERSION}.tgz ${OCI_BASE} + "; then + pushed=true + break + fi + echo "Push attempt ${attempt} failed, the registry may still be starting. Retrying." + sleep 2 +done +if [[ "${pushed}" != "true" ]]; then + echo "Could not push the charts to the test registry" >&2 && exit 1 +fi + +# --- Generate the index, exactly as a release would ---------------------------------------------- + +./hack/release/upload/update_helm_index.sh -n -c -d "${CHARTS_DIR}" -o "${OCI_BASE}" -i "${SITE_DIR}/index.yaml" + +# --- The checks, run once per Helm version ------------------------------------------------------- + +cat > "${WORK_DIR}/checks.sh" << 'EOF' +#!/bin/sh +# Each check prints 'RESULT||PASS' or 'RESULT||FAIL', followed by its output on failure. +V="$1" +REPO_URL="$2" +OCI_BASE="$3" +KEYRING=/work/gpg/pubring.gpg +# 'helm pull -d' does not create its destination directory. +mkdir -p /tmp/direct /tmp/pull /tmp/pull-verify + +check() { + name="$1"; shift + if "$@" > /tmp/check.log 2>&1; then + echo "RESULT|${name}|PASS" + else + echo "RESULT|${name}|FAIL" + tail -n 5 /tmp/check.log | sed 's/^/ /' + fi +} + +umbrella() { + dir="$1"; repository="$2" + mkdir -p "${dir}" + cat > "${dir}/Chart.yaml" << CHART +apiVersion: v2 +name: umbrella +version: 0.0.1 +dependencies: + - name: solr + version: "${V}" + repository: "${repository}" +CHART + helm dependency update "${dir}" && test -f "${dir}/charts/solr-${V}.tgz" \ + && cmp "${dir}/charts/solr-${V}.tgz" "/work/charts/solr-${V}.tgz" +} + +helm version --short + +# Control: the registry and TLS setup work without the index, so a failure below is the index's. +check "control: helm pull oci:// directly" \ + helm pull "${OCI_BASE}/solr-operator" --version "${V}" -d /tmp/direct + +check "helm repo add" helm repo add apache-solr "${REPO_URL}" +check "helm repo update" helm repo update +check "helm search repo" sh -c "helm search repo apache-solr/solr-operator --versions | grep -q '${V}'" +check "helm show chart" helm show chart apache-solr/solr-operator --version "${V}" +check "helm pull (byte-identical)" sh -c " + helm pull apache-solr/solr-operator --version '${V}' -d /tmp/pull && + cmp '/tmp/pull/solr-operator-${V}.tgz' '/work/charts/solr-operator-${V}.tgz'" +check "helm pull --verify" \ + helm pull apache-solr/solr-operator --version "${V}" --verify --keyring "${KEYRING}" -d /tmp/pull-verify +# 'helm template' resolves the chart through the same code path as 'helm install', without +# needing a cluster. +check "install path: solr-operator" helm template t apache-solr/solr-operator --version "${V}" +check "install path: solr" helm template t apache-solr/solr --version "${V}" +check "install path: --verify" \ + helm template t apache-solr/solr-operator --version "${V}" --verify --keyring "${KEYRING}" +check "dependency update: repository url" umbrella /tmp/umbrella-url "${REPO_URL}" +check "dependency update: @repo alias" umbrella /tmp/umbrella-alias "@apache-solr" +EOF + +RESULTS_FILE="${WORK_DIR}/results.txt" +: > "${RESULTS_FILE}" +for v in ${HELM_VERSIONS}; do + echo "" + echo "=== Helm v${v} ===" + output="$(in_helm_container "$(fetch_helm "${v}")" "${CONTAINER_IMAGE}" \ + sh /work/checks.sh "${CHART_VERSION}" "${REPO_URL}" "${OCI_BASE}" 2>&1 || true)" + echo "${output}" | sed -n 's/^RESULT|\(.*\)|\(.*\)$/ \2 \1/p; /^ /p; /^v[0-9]/p' + echo "${output}" | sed -n "s/^RESULT|\(.*\)|\(.*\)$/v${v}|\1|\2/p" >> "${RESULTS_FILE}" +done + +echo "" +echo "=== Summary ===" +failures="$(grep -c '|FAIL$' "${RESULTS_FILE}" || true)" +total="$(wc -l < "${RESULTS_FILE}" | tr -d ' ')" +grep '|FAIL$' "${RESULTS_FILE}" | sed 's/^\(.*\)|FAIL$/ FAIL \1/' || true +expected=$(( $(grep -c '^check "' "${WORK_DIR}/checks.sh") * $(echo ${HELM_VERSIONS} | wc -w) )) +if [[ "${total}" -ne "${expected}" ]]; then + echo "Only ${total} of ${expected} checks reported a result" >&2 + exit 1 +fi +echo "${total} checks across Helm ${HELM_VERSIONS}: $((total - failures)) passed, ${failures} failed" +if [[ "${failures}" -gt 0 ]]; then + exit 1 +fi diff --git a/hack/release/upload/update_helm_index.sh b/hack/release/upload/update_helm_index.sh new file mode 100755 index 000000000..166e12f42 --- /dev/null +++ b/hack/release/upload/update_helm_index.sh @@ -0,0 +1,242 @@ +#!/usr/bin/env bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +# exit immediately when a command fails +set -e +# only exit with zero if all commands of the pipeline exit successfully +set -o pipefail +# error on unset variables +set -u + +show_help() { +cat << EOF +Usage: ./hack/release/upload/update_helm_index.sh [-h] [-g GPG_KEY] [-n] [-c] [-o OCI_BASE] [-v VERSION] (-r RELEASE_URL | -d CHARTS_DIR) -i INDEX_FILE + +Add (or replace) Helm chart versions in a Helm repository index.yaml, whose entries point at +the OCI registry the charts were published to, instead of at HTTPS tarballs. + +The index is served from https://solr.apache.org/charts, and is checked into the solr-site +repository. Point -i at the index.yaml in a solr-site checkout. Nothing is committed or uploaded. + +An entry that already exists for the same chart and version is replaced in place, keeping its +original 'created' timestamp. Its digest must not change, since the OCI copy is required to be +byte-identical to the released chart. This makes it safe to re-run, and is what backfills older +releases once they have been published to the OCI registry. + + -h Display this help and exit + -i The index.yaml to update. + -c Create the index if it does not exist. Without this, a missing index is an error, so that a + wrong path can not silently produce an index that has lost every earlier release. + -r URL of the released Solr Operator artifacts, on dist.apache.org or archive.apache.org + (do not include the 'helm-charts' suffix). The charts are downloaded, and their + checksums and GPG signatures verified. The Solr KEYS must already be imported into gpg. + -d A local directory of chart tarballs to index instead of -r. Nothing is verified. + Meant for testing. + -v Version of the release, e.g. v0.10.0 (Optional, defaults to the last path element of -r) + -o OCI registry the charts were pushed to (Optional, defaults to ${DEFAULT_OCI_BASE}) + -g GPG Key to sign the new index file (Optional, defaults to the gpg default key) + -n Do not sign the index, or write its checksum. Meant for testing. +EOF +} + +DEFAULT_OCI_BASE="oci://ghcr.io/apache/solr-operator/helm" +CHART_NAMES=(solr-operator solr) + +OPTIND=1 +while getopts hi:r:d:v:o:g:nc opt; do + case $opt in + h) + show_help + exit 0 + ;; + i) INDEX_FILE=$OPTARG + ;; + r) RELEASE_URL=$OPTARG + ;; + d) CHARTS_DIR=$OPTARG + ;; + v) VERSION=$OPTARG + ;; + o) OCI_BASE=$OPTARG + ;; + g) GPG_KEY=$OPTARG + ;; + n) NO_SIGN=true + ;; + c) CREATE=true + ;; + *) + show_help >&2 + exit 1 + ;; + esac +done +shift "$((OPTIND-1))" # Discard the options and sentinel -- + +if [[ -z "${INDEX_FILE:-}" ]]; then + echo "Specify the index.yaml to update via -i, or through the INDEX_FILE env var" >&2 && exit 1 +fi +if [[ ! -f "${INDEX_FILE}" && "${CREATE:-}" != "true" ]]; then + echo "The index ${INDEX_FILE} does not exist. Pass -c to create a new one." >&2 && exit 1 +fi +if [[ -z "${RELEASE_URL:-}" && -z "${CHARTS_DIR:-}" ]]; then + echo "Specify either a release url via -r, or a local charts directory via -d" >&2 && exit 1 +fi +if [[ -n "${RELEASE_URL:-}" && -n "${CHARTS_DIR:-}" ]]; then + echo "Specify only one of -r and -d" >&2 && exit 1 +fi +OCI_BASE="${OCI_BASE:-${DEFAULT_OCI_BASE}}" +OCI_BASE="${OCI_BASE%/}" +if [[ "${OCI_BASE}" != oci://* ]]; then + echo "The OCI registry must start with oci:// : ${OCI_BASE}" >&2 && exit 1 +fi + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" +YAML_HEADER_FILE="${REPO_ROOT}/hack/headers/header.yaml.txt" +YQ="${YQ:-${REPO_ROOT}/bin/yq}" +if [[ ! -x "${YQ}" ]]; then + echo "yq was not found at ${YQ}. Run 'make yq' first, or set the YQ env var." >&2 && exit 1 +fi +HELM="${HELM:-helm}" + +sha512() { + if command -v sha512sum >/dev/null 2>&1; then + sha512sum "$@" + else + shasum -a 512 "$@" + fi +} + +sha256_of() { + if command -v sha256sum >/dev/null 2>&1; then + sha256sum "$1" | awk '{print $1}' + else + shasum -a 256 "$1" | awk '{print $1}' + fi +} + +TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/solr-operator-helm-index-XXXXXXXX") +trap 'rm -rf "${TMP_DIR}"' EXIT +mkdir -p "${TMP_DIR}/charts" + +if [[ -n "${RELEASE_URL:-}" ]]; then + RELEASE_URL="${RELEASE_URL%/}" + VERSION="${VERSION:-$(basename "${RELEASE_URL}")}" + CHART_VERSION="${VERSION#v}" + echo "Downloading and verifying the ${VERSION} Helm charts from ${RELEASE_URL}/helm-charts" + ( + cd "${TMP_DIR}/charts" + for name in "${CHART_NAMES[@]}"; do + for suffix in "" .sha512 .asc; do + curl --fail --show-error --silent --location --retry 3 --retry-delay 5 \ + -O "${RELEASE_URL}/helm-charts/${name}-${CHART_VERSION}.tgz${suffix}" + done + sha512 -c "${name}-${CHART_VERSION}.tgz.sha512" + if ! gpg --verify "${name}-${CHART_VERSION}.tgz.asc" "${name}-${CHART_VERSION}.tgz"; then + echo "GPG verification failed for ${name}-${CHART_VERSION}.tgz. If the key is missing, import the Solr KEYS first:" >&2 + echo " curl -sL https://dist.apache.org/repos/dist/release/solr/KEYS | gpg --import" >&2 + exit 1 + fi + rm "${name}-${CHART_VERSION}.tgz.sha512" "${name}-${CHART_VERSION}.tgz.asc" + done + ) +else + shopt -s nullglob + tarballs=("${CHARTS_DIR}"/*.tgz) + shopt -u nullglob + if [[ ${#tarballs[@]} -eq 0 ]]; then + echo "No chart tarballs found in ${CHARTS_DIR}" >&2 && exit 1 + fi + cp "${tarballs[@]}" "${TMP_DIR}/charts/" +fi + +# 'helm repo index' produces the exact metadata Helm expects for each chart version (the +# Chart.yaml fields, digest and created timestamp). Only its urls are wrong for us, since it +# can only produce HTTP urls. Helm resolves an oci:// url with a tag through its OCI getter. +NEW_INDEX="${TMP_DIR}/charts/index.yaml" +"${HELM}" repo index "${TMP_DIR}/charts" +OCI_BASE="${OCI_BASE}" "${YQ}" -i \ + '.entries[][] |= (.urls = [strenv(OCI_BASE) + "/" + .name + ":" + .version])' "${NEW_INDEX}" + +# Guard against indexing a chart whose digest does not match the tarball that was verified. +while IFS=$'\t' read -r name version digest; do + actual="$(sha256_of "${TMP_DIR}/charts/${name}-${version}.tgz")" + if [[ "${actual}" != "${digest}" ]]; then + echo "Digest mismatch for ${name}-${version}.tgz: index has ${digest}, file is ${actual}" >&2 && exit 1 + fi +done < <("${YQ}" '.entries[][] | [.name, .version, .digest] | @tsv' "${NEW_INDEX}") + +# Start from the existing index, dropping its comments (the license header is re-added below). +WORK_INDEX="${TMP_DIR}/index.yaml" +if [[ -f "${INDEX_FILE}" ]]; then + "${YQ}" '... comments=""' "${INDEX_FILE}" > "${WORK_INDEX}" +else + echo "Creating a new index at ${INDEX_FILE}" + printf 'apiVersion: v1\nentries: {}\n' > "${WORK_INDEX}" +fi + +while IFS=$'\t' read -r name version; do + export N="${name}" V="${version}" NEW="${NEW_INDEX}" + existing="$("${YQ}" '[.entries[strenv(N)][]? | select(.version == strenv(V))] | length' "${WORK_INDEX}")" + if [[ "${existing}" -gt 0 ]]; then + old_digest="$("${YQ}" '.entries[strenv(N)][] | select(.version == strenv(V)) | .digest' "${WORK_INDEX}")" + new_digest="$("${YQ}" '.entries[strenv(N)][] | select(.version == strenv(V)) | .digest' "${NEW_INDEX}")" + if [[ "${old_digest}" != "${new_digest}" ]]; then + echo "Refusing to replace ${name} ${version}: the indexed digest ${old_digest} differs from the chart's ${new_digest}." >&2 + echo "The OCI copy must be byte-identical to the released chart." >&2 + exit 1 + fi + echo "Replacing ${name} ${version}, keeping its original created timestamp" + "${YQ}" -i ' + (.entries[strenv(N)][] | select(.version == strenv(V))) |= + (load(strenv(NEW)).entries[strenv(N)][] | select(.version == strenv(V))) * {"created": .created} + ' "${WORK_INDEX}" + else + echo "Adding ${name} ${version}" + # New releases are prepended, so the index stays newest-first. Helm sorts on load anyway. + "${YQ}" -i ' + .entries[strenv(N)] = ( + [load(strenv(NEW)).entries[strenv(N)][] | select(.version == strenv(V))] + (.entries[strenv(N)] // []) + ) + ' "${WORK_INDEX}" + fi + unset N V NEW +done < <("${YQ}" '.entries[][] | [.name, .version] | @tsv' "${NEW_INDEX}") + +GENERATED="$(date -u +%Y-%m-%dT%H:%M:%S.000000000Z)" "${YQ}" -i '.generated = strenv(GENERATED)' "${WORK_INDEX}" + +mkdir -p "$(dirname "${INDEX_FILE}")" +{ + cat "${YAML_HEADER_FILE}" + printf "\n\n" + cat "${WORK_INDEX}" +} > "${INDEX_FILE}" +echo "Wrote ${INDEX_FILE}" + +if [[ "${NO_SIGN:-}" != "true" ]]; then + GPG_USER=() + if [[ -n "${GPG_KEY:-}" ]]; then + GPG_USER=(-u "${GPG_KEY}") + fi + ( + cd "$(dirname "${INDEX_FILE}")" + index_name="$(basename "${INDEX_FILE}")" + rm -f "${index_name}.asc" + gpg ${GPG_USER[@]+"${GPG_USER[@]}"} --pinentry-mode loopback -ab "${index_name}" + sha512 -b "${index_name}" > "${index_name}.sha512" + ) + echo "Signed ${INDEX_FILE}, and wrote its checksum" +fi diff --git a/hack/release/wizard/releaseWizard.yaml b/hack/release/wizard/releaseWizard.yaml index 6622c3984..5c912e27d 100644 --- a/hack/release/wizard/releaseWizard.yaml +++ b/hack/release/wizard/releaseWizard.yaml @@ -1101,29 +1101,10 @@ groups: cmd: svn move -m "Move Solr Operator {{ release_version }} RC{{ rc_number }} to release repo" {{ dist_stage_url }} {{ dist_release_url }} logfile: svn_mv_solr_operator.log tee: true - - !Todo - id: publish_helm_charts - title: Publish the staged Helm charts - depends: svn_release_mv - vars: - dist_release_url: https://dist.apache.org/repos/dist/release/solr/solr-operator/{{ release_version }} - official_helm_charts_url: https://nightlies.apache.org/solr/release/helm-charts - commands: !Commands - root_folder: '{{ git_checkout_folder }}' - confirm_each_command: false - commands_text: | - This will upload the staged Helm chart to the release location in nightlies.apache.org. - You will be prompted for your Apache password in the beggining, to use when uploading. - Next you will be prompted for your GPG Key passphrase, to sign the helm index.yaml. - commands: - - !Command - cmd: ./hack/release/upload/upload_helm.sh -g "{{ gpg_key | default("", True) }}" -a "{{ gpg.apache_id | default("", True) }}" -c "{{ official_helm_charts_url }}" -r "{{ dist_release_url }}" - logfile: upload_helm.log - tee: true - !Todo id: publish_helm_charts_oci title: Publish Helm charts to the OCI registry (GHCR) - depends: publish_helm_charts + depends: svn_release_mv vars: dist_release_url: https://dist.apache.org/repos/dist/release/solr/solr-operator/{{ release_version }} solr_operator_chart_url: '{{ dist_release_url }}/helm-charts/solr-operator-{{ release_version[1:] }}.tgz' @@ -1250,16 +1231,19 @@ groups: title: Check state of ArtifactHub entries depends: - publish_docker_image - - publish_helm_charts - publish_helm_charts_oci + - publish_website description: | Check to make sure that ArtifactHub has successfully loaded the {{ release_version }} version of the Solr Operator and Solr Helm Charts. Mark this as complete when you have confirmed all aspects of the chart in artifactHub. The ChangeLog is very finicky, so make sure that it renders correctly. - Note that ArtifactHub still indexes the HTTPS chart repository, not the OCI registry, - so the OCI copies published in the previous step will not show up here. + ArtifactHub tracks the Helm repository at https://solr.apache.org/charts, so the new version + only shows up once the website, with the updated index.yaml, has been published. The index + entries point at the OCI copies on ghcr.io, which ArtifactHub downloads to read the charts. + If the new version does not appear after the next ArtifactHub scan (up to ~30 minutes), check + the repository's tracking errors on ArtifactHub (control panel > repositories) before anything else. links: - https://artifacthub.io/packages/helm/apache-solr/solr-operator - https://artifacthub.io/packages/helm/apache-solr/solr @@ -1381,6 +1365,46 @@ groups: cmd: git add content/doap/solr-operator.rdf && git commit -m "DOAP changes for Solr Operator release {{ release_version }}" logfile: commit.log stdout: true + - !Todo + id: website_update_helm_index + title: Add the release to the Helm repository index + depends: + - website_git_clone + - publish_helm_charts_oci + vars: + dist_release_url: https://dist.apache.org/repos/dist/release/solr/solr-operator/{{ release_version }} + helm_index_file: '{{ [git_website_folder, "content", "charts", "index.yaml"] | path_join }}' + description: | + The Helm repository at https://solr.apache.org/charts is the index.yaml checked into the + website, under content/charts/. Its entries point at the OCI copies of the charts on ghcr.io, + so the charts must have been published to the OCI registry first. + + The script downloads the released charts from dist.apache.org, verifies their checksums and + signatures, and adds entries for them to the index, pointing at: + - oci://ghcr.io/apache/solr-operator/helm/solr-operator:{{ release_version[1:] }} + - oci://ghcr.io/apache/solr-operator/helm/solr:{{ release_version[1:] }} + It then signs the index, and writes its checksum. + commands: !Commands + root_folder: '{{ git_checkout_folder }}' + confirm_each_command: false + commands_text: | + This will add the new release to the website's Helm repository index. + You will be prompted for your GPG Key passphrase, to sign the index.yaml. + commands: + - !Command + cmd: git checkout {{ release_version }} && make yq + comment: The index script and yq come from the release tag + tee: true + - !Command + cmd: ./hack/release/upload/update_helm_index.sh -g "{{ gpg_key | default("", True) }}" -r "{{ dist_release_url }}" -i "{{ helm_index_file }}" + logfile: update_helm_index.log + tee: true + - !Command + cmd: git -C "{{ git_website_folder }}" add content/charts && git -C "{{ git_website_folder }}" commit -m "Add Solr Operator {{ release_version }} to the Helm repository index" + logfile: commit.log + stdout: true + post_description: | + You will push and verify all changes in a later step - !Todo id: update_other title: Update rest of webpage @@ -1415,6 +1439,7 @@ groups: - prepare_announce - website_update_doap - website_update_versions + - website_update_helm_index description: | Push the website changes to 'main' branch, and check the staging site. You will get a chance to preview the diff of all changes before you push. @@ -1473,6 +1498,15 @@ groups: Wait a few minutes for the build to happen. You can follow the site build at https://ci2.apache.org/#/builders/3 Verify on https://solr.apache.org/operator that the site is OK. + + Then verify that the Helm repository serves the new release, with a throwaway repo name, + and no registry credentials: + + helm registry logout ghcr.io + helm repo add apache-solr-check https://solr.apache.org/charts + helm show chart apache-solr-check/solr-operator --version {{ release_version[1:] }} + helm show chart apache-solr-check/solr --version {{ release_version[1:] }} + helm repo remove apache-solr-check links: - https://ci2.apache.org/#/builders/3 - https://solr.apache.org diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml index aab5d6632..e27c27c76 100644 --- a/helm/solr-operator/Chart.yaml +++ b/helm/solr-operator/Chart.yaml @@ -217,6 +217,20 @@ annotations: links: - name: Github PR url: https://github.com/apache/solr-operator/pull/827 + - kind: added + description: The Helm charts are now published as OCI artifacts to oci://ghcr.io/apache/solr-operator/helm, which needs no `helm repo add` and no credentials + links: + - name: Github Issue + url: https://github.com/apache/solr-operator/issues/813 + - name: Github PR + url: https://github.com/apache/solr-operator/pull/814 + - kind: changed + description: The Helm repository at https://solr.apache.org/charts now lists the OCI charts, so existing `helm repo add` setups and chart dependencies keep working. It requires Helm 3.8 or later + links: + - name: Github Issue + url: https://github.com/apache/solr-operator/issues/813 + - name: Github PR + url: https://github.com/apache/solr-operator/pull/900 artifacthub.io/images: | - name: solr-operator image: apache/solr-operator:v0.10.0-prerelease diff --git a/helm/solr-operator/README.md b/helm/solr-operator/README.md index 79acc1a40..8934e2217 100644 --- a/helm/solr-operator/README.md +++ b/helm/solr-operator/README.md @@ -31,19 +31,32 @@ If you do not wish to use the Zookeeper Operator, set: - `zookeeper-operator.use: false` -### Adding the Solr Operator Helm Chart Repository -You should only need to add the solr operator helm chart repository once, by running the following command: +### Installing the Chart + +The Solr Operator Helm chart is published as an OCI artifact to the GitHub Container Registry, and the Helm repository at `https://solr.apache.org/charts` lists the same chart. +Both are supported, see [Where the Helm charts are published](https://solr.apache.org/guide/operator/latest/upgrade-notes/upgrade-notes.html#where-the-helm-charts-are-published). +The charts are signed, and can be verified when installing, see [Verifying the Helm charts](https://solr.apache.org/guide/operator/latest/upgrade-notes/upgrade-notes.html#verifying-the-helm-charts). + +Install the CRDs first. Helm does not install the `ZookeeperCluster` CRD, so this step is required whichever chart source you use: ```bash -helm repo add apache-solr https://solr.apache.org/charts +kubectl create -f https://solr.apache.org/operator/downloads/crds/v0.10.0-prerelease/all-with-dependencies.yaml ``` -### Installing the Chart +#### OCI Charts -To install the Solr Operator for the first time in your cluster, you can use the latest version or a specific version, run with the following commands: +No repository needs to be added, and no credentials are required. ```bash -kubectl create -f https://solr.apache.org/operator/downloads/crds/v0.10.0-prerelease/all-with-dependencies.yaml +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version 0.10.0-prerelease +``` + +#### Charts Repo + +This requires Helm 3.8 or later. + +```bash +helm repo add apache-solr https://solr.apache.org/charts helm install solr-operator apache-solr/solr-operator --version 0.10.0-prerelease ``` @@ -54,10 +67,26 @@ _Note that the Helm chart version does not contain a `v` prefix, which the downl ### Upgrading the Solr Operator -If you are upgrading your Solr Operator deployment, you should always use a specific version of the chart and pre-install the Solr CRDS: +If you are upgrading your Solr Operator deployment, you should always use a specific version of the chart and pre-install the Solr CRDS. + +Upgrade the CRDs first. Helm does not update CRDs that are already installed, so this step is required whichever chart source you use: ```bash kubectl replace -f https://solr.apache.org/operator/downloads/crds/v0.10.0-prerelease/all-with-dependencies.yaml +``` + +Then upgrade the chart. + +#### OCI Charts + +```bash +helm upgrade solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version 0.10.0-prerelease +``` + +#### Charts Repo + +```bash +helm repo update helm upgrade solr-operator apache-solr/solr-operator --version 0.10.0-prerelease ``` @@ -67,18 +96,20 @@ If you want to specify the namespace for the installation, use the `--namespace` All resources will be deployed to the given namespace. ```bash -helm install solr-operator apache-solr/solr-operator --namespace solr +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version 0.10.0-prerelease --namespace solr ``` If you want to only watch that namespace, or others, then you will have to provide the `watchNamespaces` option. ```bash # Watch the namespace where the operator is deployed to (just pass the boolean true) -helm install solr-operator apache-solr/solr-operator --namespace solr --set watchNamespaces=true +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version 0.10.0-prerelease --namespace solr --set watchNamespaces=true + # Watch a single namespace different than the one being deployed to -helm install solr-operator apache-solr/solr-operator --namespace solr --set watchNamespaces=other -# Watch multiple namespaces (commmas must be escaped in the set string) -helm install solr-operator apache-solr/solr-operator --namespace solr --set watchNamespaces="team1\,team2\,team3" +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version 0.10.0-prerelease --namespace solr --set watchNamespaces=other + +# Watch multiple namespaces (commas must be escaped in the set string) +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version 0.10.0-prerelease --namespace solr --set watchNamespaces="team1\,team2\,team3" ``` Note: Passing `false` or `""` to the `watchNamespaces` variable will both result in the operator watchting all namespaces in the Kube cluster. @@ -90,8 +121,16 @@ Helm 3 automatically installs the Solr CRDs in the /crds directory, so no furthe If you have solr operator installations in multiple namespaces that are managed separately, you will likely want to skip installing CRDs when installing the chart. This can be done with the `--skip-crds` helm option. +#### OCI Charts + +```bash +helm install solr-operator oci://ghcr.io/apache/solr-operator/helm/solr-operator --version 0.10.0-prerelease --skip-crds --namespace solr +``` + +#### Charts Repo + ```bash -helm install solr-operator apache-solr/solr-operator --skip-crds --namespace solr +helm install solr-operator apache-solr/solr-operator --version 0.10.0-prerelease --skip-crds --namespace solr ``` **Helm will not upgrade CRDs once they have been installed. diff --git a/helm/solr/Chart.yaml b/helm/solr/Chart.yaml index 302e449e0..40900d26d 100644 --- a/helm/solr/Chart.yaml +++ b/helm/solr/Chart.yaml @@ -80,6 +80,20 @@ annotations: links: - name: Github PR url: https://github.com/apache/solr-operator/pull/827 + - kind: added + description: The Helm charts are now published as OCI artifacts to oci://ghcr.io/apache/solr-operator/helm, which needs no `helm repo add` and no credentials + links: + - name: Github Issue + url: https://github.com/apache/solr-operator/issues/813 + - name: Github PR + url: https://github.com/apache/solr-operator/pull/814 + - kind: changed + description: The Helm repository at https://solr.apache.org/charts now lists the OCI charts, so existing `helm repo add` setups and chart dependencies keep working. It requires Helm 3.8 or later + links: + - name: Github Issue + url: https://github.com/apache/solr-operator/issues/813 + - name: Github PR + url: https://github.com/apache/solr-operator/pull/900 artifacthub.io/containsSecurityUpdates: "true" artifacthub.io/recommendations: | - url: https://artifacthub.io/packages/helm/apache-solr/solr-operator diff --git a/helm/solr/README.md b/helm/solr/README.md index 3c486f8fe..fcb4d8da5 100644 --- a/helm/solr/README.md +++ b/helm/solr/README.md @@ -33,9 +33,24 @@ There may be breaking changes between the version you are using and the version ### Installing the Chart -To install a SolrCloud for the first time in your cluster, you can use the latest version or a specific version, run with the following commands: +The Solr Helm chart is published as an OCI artifact to the GitHub Container Registry, and the Helm repository at `https://solr.apache.org/charts` lists the same chart. +Both are supported, see [Where the Helm charts are published](https://solr.apache.org/guide/operator/latest/upgrade-notes/upgrade-notes.html#where-the-helm-charts-are-published). +The charts are signed, and can be verified when installing, see [Verifying the Helm charts](https://solr.apache.org/guide/operator/latest/upgrade-notes/upgrade-notes.html#verifying-the-helm-charts). + +To install a SolrCloud for the first time in your cluster, you can use the latest version or a specific version: + +#### OCI Charts + +```bash +helm install example oci://ghcr.io/apache/solr-operator/helm/solr --version 0.10.0-prerelease --set image.tag=9.11.0 +``` + +#### Charts Repo + +This requires Helm 3.8 or later. ```bash +helm repo add apache-solr https://solr.apache.org/charts helm install example apache-solr/solr --version 0.10.0-prerelease --set image.tag=9.11.0 ``` @@ -49,7 +64,16 @@ _Note that the Helm chart version does not contain a `v` prefix, which the Solr If you are upgrading your SolrCloud deployment, you should always use a specific version of the chart and upgrade **after [upgrading the Solr Operator](https://artifacthub.io/packages/helm/apache-solr/solr-operator#upgrading-the-solr-operator) to the same version**: +#### OCI Charts + +```bash +helm upgrade example oci://ghcr.io/apache/solr-operator/helm/solr --version 0.10.0-prerelease --reuse-values --set image.tag=9.11.0 +``` + +#### Charts Repo + ```bash +helm repo update helm upgrade example apache-solr/solr --version 0.10.0-prerelease --reuse-values --set image.tag=9.11.0 ```