From a3f62e75b0b17f65b1ec2471d6d6c138410ae927 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Wed, 14 Feb 2024 14:27:40 +0200 Subject: [PATCH 1/2] .github: publish unstable Helm charts to image registry. Package and push unstable Helm charts to our image registry. Note that currently Helm is unable to search OCI registries. Before that gets fixed, the plublished unstable chart is not discoverable. Signed-off-by: Krisztian Litkey --- .github/workflows/package-helm.yaml | 68 ++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package-helm.yaml b/.github/workflows/package-helm.yaml index 524cfca6f..79ce03737 100644 --- a/.github/workflows/package-helm.yaml +++ b/.github/workflows/package-helm.yaml @@ -4,12 +4,20 @@ on: push: tags: - "v*.*.*" + branches: + - main env: CHARTS_DIR: deployment/helm/ + IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }} + UNSTABLE_CHARTS: unstable-helm-charts + REGISTRY: ghcr.io + REGISTRY_USER: ${{ github.repository_owner }} + REGISTRY_PATH: ${{ github.repository }} jobs: release: + if: ${{ github.env.IS_RELEASE == 'true' }} permissions: contents: write runs-on: ubuntu-latest @@ -20,7 +28,7 @@ jobs: - name: Install Helm uses: azure/setup-helm@v4.0.0 - - name: Package Helm charts + - name: Package Stable Helm Charts run: | find "$CHARTS_DIR" -name values.yaml | xargs -I '{}' \ sed -e s"/pullPolicy:.*/pullPolicy: IfNotPresent/" -i '{}' @@ -30,10 +38,66 @@ jobs: mv $SRC_FILE $DEST_FILE done - - name: Upload Helm packages to GitHub releases + - name: Upload Stable Helm Charts to GitHub Release uses: softprops/action-gh-release@v1 with: name: ${{ github.ref_name }} draft: true append_body: true files: nri-*helm-chart*.tgz + + unstable: + concurrency: + group: unstable-helm-charts + cancel-in-progress: false + if: ${{ github.env.IS_RELEASE != 'true' }} + permissions: + packages: write + runs-on: ubuntu-latest + steps: + - name: Deep Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Helm + uses: azure/setup-helm@v4.0.0 + + - name: Package Unstable Helm Charts + id: package-charts + run: | + # For unstable chart verison we use: + # - chart version: x.y-unstable derived from the latest tag x.y.z + # - image version: 'unstable'. + majmin="$(git describe | sed -E 's/v([0-9]*\.[0-9]*).*$/\1/')" + CHART_VERSION="${majmin}-unstable" + APP_VERSION=unstable + # Package charts + find "$CHARTS_DIR" -name values.yaml | xargs -I '{}' \ + sed -e s"/pullPolicy:.*/pullPolicy: Always/" -i '{}' + helm package --version "$CHART_VERSION" --app-version $APP_VERSION "$CHARTS_DIR"/* + find "$CHARTS_DIR" -name values.yaml | xargs -I '{}' \ + git checkout '{}' + mkdir ../$UNSTABLE_CHARTS + find . -name '*.tgz' -print | while read SRC_FILE; do + DEST_FILE=$(echo $SRC_FILE | sed 's/v/helm-chart-v/g') + mv -v $SRC_FILE ../$UNSTABLE_CHARTS/$DEST_FILE + done + + - name: Log In To Registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | \ + helm registry login ${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }} -u ${{ env.REGISTRY_USER }} --password-stdin + + - name: Push Unstable Helm Charts To Registry + shell: bash + run: | + # Notes: + # Currently we only publish unstable Helm charts from main/HEAD. + # We have no active cleanup of old unstable charts in place. In + # between new tags unstable chart have the same version, though. + pushd ../$UNSTABLE_CHARTS + for i in ./*.tgz; do + helm push $i oci://${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }} + done + popd From 65e1f3228b927b111724b234317e4a30cef88d3d Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Tue, 26 Mar 2024 10:48:23 +0200 Subject: [PATCH 2/2] docs: update documentation. Add short instructions about how to discover and use unstable Helm charts to the documentation. Signed-off-by: Krisztian Litkey --- docs/deployment/helm/index.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/deployment/helm/index.md b/docs/deployment/helm/index.md index b13388c49..10b8771c4 100644 --- a/docs/deployment/helm/index.md +++ b/docs/deployment/helm/index.md @@ -1,5 +1,7 @@ # Helm +## Stable Helm Charts + All the available charts can be found in [artifacthub.io](https://artifacthub.io/packages/search?ts_query_web=nri&verified_publisher=true&official=true&sort=relevance&page=1). **NOTE:** NRI-plugins Helm installation has been successfully verified in both local clusters and major Cloud Providers' managed clusters, including: @@ -19,6 +21,26 @@ All the available charts can be found in [artifacthub.io](https://artifacthub.io While Ubuntu 20.04/22.04 was used across all three CSP environments, it's worth noting that node images are not limited to Ubuntu 20.04/22.04 only. The majority of widely recognized Linux distributions should be suitable for use. +## Unstable Helm Charts + +Helm charts are also published from the main/development branch after each merge. +These charts reference the latest development images tagged as `unstable` and are +are stored alongside plugin images in the OCI image registry. + +### Discovering Unstable Helm Charts + +Unstable charts can be discovered using [skopeo](https://github.com/containers/skopeo). +For instance, one can list the available charts for the balloons plugin using this +skopeo command: +`skopeo list-tags docker://ghcr.io/containers/nri-plugins/nri-resource-policy-balloons` + +### Using Unstable Helm Charts + +Once discovered, unstable Helm charts can be used like any other. For instance, to use +the `$X.$Y-unstable` version of the chart to install the development version of the +balloons plugin one can use this command: +`helm install --devel -n kube-system test oci://ghcr.io/containers/nri-plugins/nri-resource-policy-balloons --version $X.$Y-unstable --set image.tag=unstable --set image.pullPolicy=Always` + ```{toctree} --- maxdepth: 2