From 585ec3ba344b9bcf01570577c61cfa3a1c21efdd Mon Sep 17 00:00:00 2001 From: JMboya <44696487+JeffMboya@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:21:07 +0300 Subject: [PATCH] MG-140 - Create HELM repo with GitHub or any with other provider (#142) * feat: Add helm chart release workflow Signed-off-by: JeffMboya feat: Add helm chart release workflow Signed-off-by: JeffMboya * feat: Package MG helm chart Signed-off-by: JeffMboya * feat: Add index.yaml file Signed-off-by: JeffMboya * feat:Update helm chart-releaser-action to v1.6.0 Signed-off-by: JeffMboya * feat: Add spaces Signed-off-by: JeffMboya * feat: remove index.yaml Signed-off-by: JeffMboya * feat: add charts_dir Signed-off-by: JeffMboya * feat: Add config file for helm chart-releaser-action Signed-off-by: JeffMboya * feat: Add config file for helm chart-releaser-action Signed-off-by: JeffMboya * feat: Add dependecies to release.yaml Signed-off-by: JeffMboya * feat: Add lint and test workflow for Helm charts Signed-off-by: JeffMboya * feat: Update README Signed-off-by: JeffMboya * feat: Add lint-test and reusable workflow Signed-off-by: JeffMboya * Feat: Add inedx.yml Signed-off-by: JeffMboya * Feat: restructure chart directory Signed-off-by: JeffMboya * Feat: Update README Signed-off-by: JeffMboya * Feat: Run release workflow on all branches Signed-off-by: JeffMboya * Feat: Update README Signed-off-by: JeffMboya * Feat: Update release.yaml Signed-off-by: JeffMboya * Feat: Update chart version Signed-off-by: JeffMboya * Feat: Update chart path Signed-off-by: JeffMboya * Feat: Update chart path Signed-off-by: JeffMboya * Feat: Update chart path Signed-off-by: JeffMboya * Delete magistrala-charts dir Signed-off-by: JeffMboya * rename common workflow Signed-off-by: JeffMboya * Remove common workflow Signed-off-by: JeffMboya * remove charts_dir and config parameters from release.yaml Signed-off-by: JeffMboya * delete cr.yml file Signed-off-by: JeffMboya --------- Signed-off-by: JeffMboya --- .github/workflows/lint-test.yaml | 48 ++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 45 ++++++++++++++++++++++++++++ README.md | 2 +- charts/magistrala/Chart.yaml | 4 +-- charts/magistrala/README.md | 50 +++++++++++++++++++++++++++++--- 5 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/lint-test.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml new file mode 100644 index 00000000..de9ae9c0 --- /dev/null +++ b/.github/workflows/lint-test.yaml @@ -0,0 +1,48 @@ +# Copyright (c) Magistrala +# SPDX-License-Identifier: Apache-2.0 + +name: Lint and Test Charts + +on: pull_request + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v4.2.0 + with: + version: v3.15.4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.0 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --target-branch ${{ github.event.repository.default_branch }} + + - name: Create kind cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.10.0 + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --target-branch ${{ github.event.repository.default_branch }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..0795377d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,45 @@ +# Copyright (c) Magistrala +# SPDX-License-Identifier: Apache-2.0 + +name: Release Charts + +on: + push: + branches: + - main + +jobs: + release: + permissions: + contents: write + + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Set up Helm + uses: azure/setup-helm@v4.2.0 + with: + version: v3.15.4 + + - name: Add Dependencies + run: | + helm repo add stable https://charts.helm.sh/stable + helm repo add bitnami https://charts.bitnami.com/bitnami + helm repo add jaegertracing https://jaegertracing.github.io/helm-charts + helm repo add hashicorp https://helm.releases.hashicorp.com + helm repo add nats https://nats-io.github.io/k8s/helm/charts/ + helm repo update + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.HELM_RELEASE_TOKEN }}" diff --git a/README.md b/README.md index 81d89c11..64202165 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## DevOps -DevOps scripts for Magistrala IoT platform. +DevOps scripts for Magistrala IoT platform ## Install diff --git a/charts/magistrala/Chart.yaml b/charts/magistrala/Chart.yaml index f2049016..e9ceb984 100644 --- a/charts/magistrala/Chart.yaml +++ b/charts/magistrala/Chart.yaml @@ -6,8 +6,8 @@ name: magistrala description: Magistrala IoT Platform icon: https://avatars1.githubusercontent.com/u/13207490 type: application -version: 1.0.3 -appVersion: "0.12.1" +version: 1.0.4 # Incremented chart version if the chart is updated +appVersion: "0.12.2" # Update application version if the app is updated home: https://abstractmachines.fr/magistrala.html sources: - https://hub.docker.com/u/magistrala diff --git a/charts/magistrala/README.md b/charts/magistrala/README.md index abbfb3aa..947cff86 100644 --- a/charts/magistrala/README.md +++ b/charts/magistrala/README.md @@ -1,6 +1,6 @@ # Magistrala Helm Chart -Helm Chart for the Magistrala IoT Platform +Helm Chart for the Magistrala IoT Platform. ## Prerequisites @@ -16,6 +16,48 @@ Helm Chart for the Magistrala IoT Platform - Certificate/Key installed as**TLS secret** - Intermediate certificate installed as**Generic secret** +## Adding the Helm Repository + +The Helm charts are published via GitHub Pages. To add the repository to your Helm configuration, run the following command: + +```bash +helm repo add devops-charts https://absmach.github.io/devops/ +``` + +Update your local Helm repository cache to fetch the latest charts: + +```bash +helm repo update +``` + +## Installing the Chart + +Once the repository is added, you can install the chart using Helm. Replace `` with your desired release name: + +```bash +helm install devops-charts/magistrala +``` + +This command will install the `magistrala` chart from the GitHub Pages-hosted Helm repository. + +## Upgrading the Chart + +To upgrade the chart with a new version or updated configuration, use the following command: + +```bash +helm upgrade devops-charts/magistrala +``` + +This ensures that your deployment uses the latest version of the chart while retaining any custom configurations. + +## Uninstalling the Chart + +To uninstall the chart and release, run: + +```bash +helm uninstall +``` + ## Configuration The following table lists the configurable parameters and their default values. @@ -145,7 +187,7 @@ The following table lists the configurable parameters and their default values. | influxdb.writer.httpPort | InfluxDB writer HTTP port | 9006 | | influxdb.reader.httpPort | InfluxDB reader HTTP port | 9005 | | influxdb.backup.enabled | Enable InfluxDB backup | false | -| influxdb.backup.cronjob.schedule | Crontab style time schedule for backup execution | "0 2 * * *" | +| influxdb.backup.cronjob.schedule | Crontab style time schedule for backup execution | "0 2 \* \* \*" | | adapter_opcua.enabled | Enable OPC-UA adapter | false | | adapter_opcua.httpPort | OPC-UA adapter HTTP port | 8188 | | adapter_opcua.redisRouteMapPort | OPC-UA adapter Redis Auth Cache port | 6379 | @@ -160,8 +202,8 @@ The following table lists the configurable parameters and their default values. | notifier_smtp.enabled | Enable SMTP notifier | false | | notifier_smtp.emailHost | SMTP host | false | | notifier_smtp.smtpPort | SMTP port | false | -| notifier_smtp.fromName | SMTP notifier `from` name | false | -| notifier_smtp.fromEmail | SMTP `from` email address | false | +| notifier_smtp.fromName | SMTP notifier `from` name | false | +| notifier_smtp.fromEmail | SMTP `from` email address | false | | notifier_smtp.username | SMTP username | false | | notifier_smtp.password | SMTP password | false | | notifier_smtp.secret | SMTP secret | false |