From 0f16eaabe3ed97cf2aba61f6055711440dd3f3b8 Mon Sep 17 00:00:00 2001 From: Benjamin Buchfink Date: Sat, 13 Jul 2024 14:35:09 +0200 Subject: [PATCH] ci: Create helm chart for BaGetter (#117) * Created helm chart for BaGetter * Chart.lock should not be distributed * Disabled k8s probes /health endpoint is not released in the latest container image * Use corrent default health endpoint The health probes are prepared but commented out. The default endpoint is not /healthz * Moved chart folder to deployment templates folder * Update helm chart in release.yml --- .github/workflows/release.yml | 21 ++++ .gitignore | 4 + .../chart/bagetter/.helmignore | 27 ++++++ .../chart/bagetter/Chart.yaml | 32 ++++++ deployment templates/chart/bagetter/README.md | 36 +++++++ .../chart/bagetter/templates/common.yaml | 5 + .../chart/bagetter/values.yaml | 97 +++++++++++++++++++ 7 files changed, 222 insertions(+) create mode 100644 deployment templates/chart/bagetter/.helmignore create mode 100644 deployment templates/chart/bagetter/Chart.yaml create mode 100644 deployment templates/chart/bagetter/README.md create mode 100644 deployment templates/chart/bagetter/templates/common.yaml create mode 100644 deployment templates/chart/bagetter/values.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c4923bf61..a49161280 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,3 +113,24 @@ jobs: bagetter/bagetter:${{ needs.version.outputs.RELEASE_VERSION }} build-args: | Version=${{ needs.version.outputs.RELEASE_VERSION }} + + release_helm_chart: + if: ${{ github.ref_type == 'tag' }} + needs: [version, verify] + name: Release Helm chart to GitHub + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - name: Update version in helm chart + run: | + sed -i "s/version: \".*\"/version: \"${{ needs.version.outputs.RELEASE_VERSION }}\"/" deployment%20templates/chart/bagetter/Chart.yaml + sed -i "s/appVersion: \".*\"/appVersion: \"${{ needs.version.outputs.RELEASE_VERSION }}\"/" deployment%20templates/chart/bagetter/Chart.yaml + - name: Generate helm docs + uses: losisin/helm-docs-github-action@v1 + with: + chart-search-root: deployment%20templates + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Release helm chart version ${{ needs.version.outputs.RELEASE_VERSION }}" + file_pattern: 'deployment%20templates/chart/bagetter/Chart.yaml deployment%20templates/chart/bagetter/README.md' diff --git a/.gitignore b/.gitignore index e660e4b54..828b85b53 100644 --- a/.gitignore +++ b/.gitignore @@ -274,3 +274,7 @@ __pycache__/ **/bagetter.db-wal .vscode/ + +# Chart dependencies +charts/ +Chart.lock \ No newline at end of file diff --git a/deployment templates/chart/bagetter/.helmignore b/deployment templates/chart/bagetter/.helmignore new file mode 100644 index 000000000..dcb19daba --- /dev/null +++ b/deployment templates/chart/bagetter/.helmignore @@ -0,0 +1,27 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +# OWNERS file for Kubernetes +OWNERS +# helm-docs templates +*.gotmpl \ No newline at end of file diff --git a/deployment templates/chart/bagetter/Chart.yaml b/deployment templates/chart/bagetter/Chart.yaml new file mode 100644 index 000000000..4c3f6704f --- /dev/null +++ b/deployment templates/chart/bagetter/Chart.yaml @@ -0,0 +1,32 @@ +apiVersion: v2 +name: bagetter +description: A Helm chart for BaGetter nuget package server +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.0.4" + +keywords: + - nuget + - baget + - bagetter + +home: https://github.com/bagetter/BaGetter/tree/master/charts/BaGetter +# icon: + +sources: + - https://github.com/bagetter/BaGetter + - https://hub.docker.com/r/bagetter/bagetter + +dependencies: + - name: common + repository: http://bjw-s.github.io/helm-charts/ + version: 3.0.3 diff --git a/deployment templates/chart/bagetter/README.md b/deployment templates/chart/bagetter/README.md new file mode 100644 index 000000000..60e36ed22 --- /dev/null +++ b/deployment templates/chart/bagetter/README.md @@ -0,0 +1,36 @@ +# bagetter + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.4](https://img.shields.io/badge/AppVersion-1.0.4-informational?style=flat-square) + +A Helm chart for BaGetter nuget package server + +**Homepage:** + +## Source Code + +* +* + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| http://bjw-s.github.io/helm-charts/ | common | 3.0.3 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| configMaps | object | See below | environment variables. See more environment variables in the [BaGetter documentation](https://www.bagetter.com/docs/Installation/docker). | +| configMaps.bagetter-env.data.ApiKey | string | `"ChangeMe"` | Set the Nuget API key | +| configMaps.bagetter-env.data.Storage__Type | string | `"FileSystem"` | Set database and storage settings | +| controllers | object | See values.yaml | Configures containers for the chart. | +| controllers.bagetter.containers.bagetter.image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| controllers.bagetter.containers.bagetter.image.repository | string | `"bagetter/bagetter"` | image repository | +| controllers.bagetter.containers.bagetter.image.tag | string | `"latest"` | image tag | +| ingress | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | +| persistence | object | See values.yaml | Configure persistence settings for the chart under this key. | +| service | object | See values.yaml | Configures service settings for the chart. | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1) diff --git a/deployment templates/chart/bagetter/templates/common.yaml b/deployment templates/chart/bagetter/templates/common.yaml new file mode 100644 index 000000000..cc082b8f6 --- /dev/null +++ b/deployment templates/chart/bagetter/templates/common.yaml @@ -0,0 +1,5 @@ +--- +{{- include "bjw-s.common.loader.init" . }} + +{{/* Render the templates */}} +{{ include "bjw-s.common.loader.generate" . }} diff --git a/deployment templates/chart/bagetter/values.yaml b/deployment templates/chart/bagetter/values.yaml new file mode 100644 index 000000000..b6a18ee15 --- /dev/null +++ b/deployment templates/chart/bagetter/values.yaml @@ -0,0 +1,97 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/app-template-3.0.1/charts/other/app-template/values.schema.json + +# +# IMPORTANT NOTE +# +# This chart inherits from the common library chart. You can check the default values/options here: +# https://github.com/bjw-s/helm-charts/tree/main/charts/library/common/values.yaml +# + +# -- environment variables. See more environment variables in the [BaGetter documentation](https://www.bagetter.com/docs/Installation/docker). +# @default -- See below +configMaps: + bagetter-env: + data: + # -- Set the Nuget API key + ApiKey: "ChangeMe" + # -- Set database and storage settings + Storage__Type: "FileSystem" + Storage__Path: "/data" + Database__Type: "Sqlite" + Database__ConnectionString: "Data Source=/data/bagetter.db" + # -- Additional settings. See [BaGetter configuration](https://www.bagetter.com/docs/configuration) + #Mirror__Enabled: "true" + #Mirror__PackageSource: "https://api.nuget.org/v3/index.json" + #PackageDeletionBehavior: "HardDelete" + +# -- Configures containers for the chart. +# @default -- See values.yaml +controllers: + bagetter: + containers: + bagetter: + image: + # -- image repository + repository: bagetter/bagetter + # -- image tag + tag: latest + # -- image pull policy + pullPolicy: IfNotPresent + envFrom: + - configMapRef: + name: bagetter-bagetter-env + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + cpu: 500m + memory: 512Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + privileged: false + readOnlyRootFilesystem: false + # probes: # comming with v1.0.5 + # liveness: + # enabled: true + # type: HTTP + # path: /health + # readiness: + # enabled: true + +# -- Configures service settings for the chart. +# @default -- See values.yaml +service: + bagetter-srv: + controller: bagetter + ports: + http: + port: 8080 + +# -- Enable and configure ingress settings for the chart under this key. +# @default -- See values.yaml +ingress: + bagetter-ingress: + enabled: false + # className: "ingress-nginx" + hosts: [] + # - host: bagetter.mydomain.com + # paths: + # - path: / + # service: + # identifier: bagetter + # port: 8080 + +# -- Configure persistence settings for the chart under this key. +# @default -- See values.yaml +persistence: + bagetter-data: + enabled: true + accessMode: "ReadWriteOnce" + size: "10Gi" + globalMounts: + - path: "/data"