diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..d05656d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,52 @@ +--- +name: Bug report +description: Create a report to help us improve. +body: + - type: markdown + attributes: + value: | + Thank you for opening a bug report for Perses. + + Please do *NOT* ask support questions in Github issues. + + If your issue is not a feature request or bug report use [Discussions](https://github.com/perses/perses/discussions). + - type: textarea + attributes: + label: What did you do? + description: Please provide steps for us to reproduce this issue. + validations: + required: true + - type: textarea + attributes: + label: What did you expect to see? + - type: textarea + attributes: + label: What did you see instead? Under which circumstances? + validations: + required: true + - type: markdown + attributes: + value: | + ## Environment + - type: input + attributes: + label: System information + description: insert output of `uname -srm` here, or operating system version + placeholder: e.g. Linux 5.16.15 x86_64 + - type: textarea + attributes: + label: Perses version + description: Insert the Perses version here. + render: text + placeholder: | + e.g. 0.39.0 + - type: textarea + attributes: + label: Perses configuration file + description: Insert relevant configuration here. Don't forget to remove secrets. + render: yaml + - type: textarea + attributes: + label: Logs + description: Insert Perses logs relevant to the issue here. + render: text diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..605f077 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,10 @@ +blank_issues_enabled: false +contact_links: + - name: Perses Discussions + url: https://github.com/perses/perses/discussions + - name: Perses Public Channel + url: https://matrix.to/#/!mnvXmsFzbmKXoBYGcv:matrix.org?via=matrix.org + about: If you need help or support, please request help here + - name: Perses Development Channel + url: https://matrix.to/#/#perses-dev:matrix.org + about: If you are unsure about what to do, and you are eager to contribute, you can reach us on this development channel diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..3c7b0a3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,18 @@ +--- +name: Feature request +description: Suggest an idea for this project. +body: + - type: markdown + attributes: + value: | + Thank you for opening a feature request for Perses. + + Please do *NOT* ask support questions in Github issues. + + If your issue is not a feature request or bug report use [Discussions](https://github.com/perses/perses/discussions). + - type: textarea + attributes: + label: Proposal + description: Use case. Why is this important? + validations: + required: true diff --git a/.github/actions/setup_environment/action.yaml b/.github/actions/setup_environment/action.yaml new file mode 100644 index 0000000..fb6517b --- /dev/null +++ b/.github/actions/setup_environment/action.yaml @@ -0,0 +1,15 @@ +name: "Setup environment" +description: "Setup GO or NPM environment" +runs: + using: composite + steps: + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: 1.21.x + - uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- diff --git a/.github/actions/setup_helmlint/action.yaml b/.github/actions/setup_helmlint/action.yaml new file mode 100644 index 0000000..8ad330b --- /dev/null +++ b/.github/actions/setup_helmlint/action.yaml @@ -0,0 +1,25 @@ +name: Setup +description: sets up helm lint and testing environment +inputs: + create-kind-cluster: + description: "Whether or not to create a kind cluster during setup" + required: true + default: "false" +runs: + using: "composite" + steps: + - name: Set up Helm + uses: azure/setup-helm@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.7 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.4.0 + + - name: Create kind cluster + uses: helm/kind-action@v1.5.0 + if: ${{ inputs.create-kind-cluster == 'true' }} + with: + node_image: kindest/node:v1.28.0 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..013ee9f --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,14 @@ + + +# Description + + + +# Checklist + +- [ ] Pull request has a descriptive title and context useful to a reviewer. +- [ ] Pull request title follows the `[] ` naming convention using one of the following `catalog_entry` values: `FEATURE`, `ENHANCEMENT`, `BUGFIX`, `BREAKINGCHANGE`, `IGNORE`. +- [ ] All commits have [DCO signoffs](https://github.com/probot/dco#how-it-works). diff --git a/.github/workflows/lint-and-test.yaml b/.github/workflows/lint-and-test.yaml new file mode 100644 index 0000000..2159d34 --- /dev/null +++ b/.github/workflows/lint-and-test.yaml @@ -0,0 +1,36 @@ +name: lint and test + +on: + pull_request: + paths: + - "charts/perses/**" + branches: + - main + +jobs: + helm-lint-and-test: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: setup helm lint requirements + uses: ./.github/actions/setup_helmlint + with: + create-kind-cluster: "true" + + - name: setup go lang + uses: ./.github/actions/setup_environment + with: + enable_go: true + + - name: run chart-testing (install) + run: ct install --charts charts/perses + + - name: install mdox + run: go install github.com/bwplotka/mdox@latest + + - name: run chart README lint + run: make update-helm-readme && make checkdocs diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..827ac7c --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,57 @@ +name: release + +on: + push: + paths: + - "charts/perses/**" + branches: + - main + +jobs: + release: + permissions: + contents: write # to push chart release and create a release (helm/chart-releaser-action) + packages: write # needed for ghcr access + id-token: write # needed for keyless signing + + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Fetch history + run: git fetch --prune --unshallow + + - 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@v3.5 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.5.0 + with: + charts_dir: charts + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + CR_GENERATE_RELEASE_NOTES: true + + # see https://github.com/helm/chart-releaser/issues/183 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push charts to GHCR + run: | + shopt -s nullglob + for pkg in .cr-release-packages/*; do + if [ -z "${pkg:-}" ]; then + break + fi + helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts" + done diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..167a01b --- /dev/null +++ b/.gitignore @@ -0,0 +1,234 @@ +# Created by https://www.toptal.com/developers/gitignore/api/helm,macos,linux,windows,visualstudiocode,vim,goland +# Edit at https://www.toptal.com/developers/gitignore?templates=helm,macos,linux,windows,visualstudiocode,vim,goland + +### GoLand ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### GoLand Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Helm ### +# Chart dependencies +**/charts/*.tgz + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/helm,macos,linux,windows,visualstudiocode,vim,goland \ No newline at end of file diff --git a/.mdox.validate.yaml b/.mdox.validate.yaml new file mode 100644 index 0000000..6e49fa0 --- /dev/null +++ b/.mdox.validate.yaml @@ -0,0 +1,7 @@ +version: 1 +timeout: "1m" + +validators: + # randomly it returns the error: status code 403: Forbidden + - regex: 'groups\.google\.com' + type: "ignore" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..015f6e3 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +# Copyright 2023 The Perses Authors +# Licensed 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. + +GO ?= go +MDOX ?= mdox + +.PHONY: checkdocs +checkdocs: + @echo ">> check format markdown docs" + @make fmt-docs + @git diff --exit-code -- *.md + +.PHONY: fmt-docs +fmt-docs: + @echo ">> format markdown document" + $(MDOX) fmt --soft-wraps -l $$(find . -name '*.md' -print) --links.validate.config-file=./.mdox.validate.yaml + +.PHONY: update-helm-readme +update-helm-readme: + @docker run --rm --volume "$$(pwd)/charts/perses:/helm-docs" -u $$(id -u) jnorwood/helm-docs:latest + @make fmt-docs \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1dc0ed4 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# Perses Kubernetes Helm Charts + +The code is provided as-is with no warranties. + +## Usage + +[Helm](https://helm.sh) must be installed to use the charts. +Please refer to Helm's [documentation](https://helm.sh/docs/) to get started. + +Once Helm is set up properly, add the repo as follows: + +```console +helm repo add perses https://perses.github.io/perses +``` + +You can then run `helm search repo perses` to see the charts. + +## Contributing + + + +We'd love to have you contribute! Please refer to our [contribution guidelines]() for details. + +## License + + + +[Apache 2.0 License](https://github.com/perses/helm-charts/blob/main/LICENSE). diff --git a/charts/perses/.helmignore b/charts/perses/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/perses/.helmignore @@ -0,0 +1,23 @@ +# 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/ diff --git a/charts/perses/Chart.yaml b/charts/perses/Chart.yaml new file mode 100644 index 0000000..0f9c833 --- /dev/null +++ b/charts/perses/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: perses +description: Perses helm chart +icon: https://avatars.githubusercontent.com/u/77209215?s=200&v=4 +type: application +version: 0.1.0 +appVersion: "0.39.0" +sources: + - https://github.com/perses/perses +annotations: + "artifacthub.io/license": Apache-2.0 + "artifacthub.io/links": | + - name: Chart Source + url: https://github.com/perses/perses/tree/main/charts/perses + - name: Upstream Project + url: https://github.com/perses/perses +keywords: + - monitoring + - metric + - dashboarding + - prometheus diff --git a/charts/perses/README.md b/charts/perses/README.md new file mode 100644 index 0000000..f51d704 --- /dev/null +++ b/charts/perses/README.md @@ -0,0 +1,77 @@ + + +# perses + +Perses helm chart + +![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: 0.37.2](https://img.shields.io/badge/AppVersion-0.37.2-informational?style=flat-square) + +## Installing the Chart + +To install the chart with the release name `my-release`: + +``` +helm repo add perses https://perses.github.io/perses +helm repo update +helm install my-release perses/perses +``` + +## Uninstalling the Chart + +To uninstall/delete the my-release deployment: + +``` +helm delete my-release +``` + +## Values + +| Key | Type | Default | Description | +|-----------------------------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| annotations | object | `{}` | Statefulset Annotations | +| config | object | `{"annotations":{},"database":{"file":{"extension":"yaml","folder":"/etc/perses/storage"},"sql":{}},"important_dashboards":[],"readOnly":false,"schemas":{"datasources_path":"/etc/perses/schemas/datasources","panels_path":"/etc/perses/schemas/panels","queries_path":"/etc/perses/schemas/queries","variables_path":"/etc/perses/schemas/variables"}}` | Perses configuration file ref: https://github.com/perses/perses/blob/main/docs/configuration.md | +| config.annotations | object | `{}` | Annotations for config secret | +| config.database | object | `{"file":{"extension":"yaml","folder":"/etc/perses/storage"},"sql":{}}` | Database config based on data base type | +| config.database.file | object | `{"extension":"yaml","folder":"/etc/perses/storage"}` | file system configs | +| config.database.sql | object | `{}` | SQL Config | +| config.important_dashboards | list | `[]` | Important dashboards list | +| config.readOnly | bool | `false` | Configure Perses instance as readonly | +| config.schemas | object | `{"datasources_path":"/etc/perses/schemas/datasources","panels_path":"/etc/perses/schemas/panels","queries_path":"/etc/perses/schemas/queries","variables_path":"/etc/perses/schemas/variables"}` | Schemas paths | +| fullnameOverride | string | `""` | Override fully qualified app name | +| image.name | string | `"persesdev/perses"` | Perses image repository and name | +| image.pullPolicy | string | `"IfNotPresent"` | Default image pull policy | +| image.version | string | `""` | Overrides the image tag whose default is the chart appVersion. | +| ingress | object | `{"annotations":{},"enabled":false,"hostname":"perses.local","ingressClassName":"","path":"/","pathType":"Prefix"}` | Configure the ingress resource that allows you to access Thanos Query Frontend ref: https://kubernetes.io/docs/concepts/services-networking/ingress/ | +| ingress.annotations | object | `{}` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. For a full list of possible ingress annotations, please see ref: https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md | +| ingress.enabled | bool | `false` | Enable ingress controller resource | +| ingress.hostname | string | `"perses.local"` | Default host for the ingress resource | +| ingress.ingressClassName | string | `""` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster . ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/ | +| ingress.path | string | `"/"` | Ingress path | +| ingress.pathType | string | `"Prefix"` | Ingress path type | +| livenessProbe | object | `{"enabled":true,"failureThreshold":5,"initialDelaySeconds":10,"periodSeconds":60,"successThreshold":1,"timeoutSeconds":5}` | Liveness probe configuration Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ | +| logLevel | string | `"info"` | Log level for Perses be configured in available options "panic", "error", "warning", "info", "debug", "trace" | +| nameOverride | string | `""` | Override name of the chart used in Kubernetes object names. | +| persistence | object | `{"accessModes":["ReadWriteOnce"],"annotations":{},"enabled":false,"labels":{},"size":"8Gi","storageClass":""}` | Persistence parameters | +| persistence.accessModes | list | `["ReadWriteOnce"]` | PVC Access Modes for data volume | +| persistence.annotations | object | `{}` | Annotations for the PVC | +| persistence.enabled | bool | `false` | If disabled it will use a emptydir volume | +| persistence.labels | object | `{}` | Labels for the PVC | +| persistence.size | string | `"8Gi"` | PVC Storage Request for data volume | +| persistence.storageClass | string | `""` | Specify the `storageClass` used to provision the volume | +| readinessProbe | object | `{"enabled":true,"failureThreshold":5,"initialDelaySeconds":5,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":5}` | Readiness probe configuration Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ | +| replicas | int | `1` | Number of pod replicas. | +| resources | object | `{}` | Resource limits & requests. Update according to your own use case as these values might be too low for a typical deployment. ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | +| service | object | `{"annotations":{},"labels":{},"port":8080,"targetPort":8080,"type":"ClusterIP"}` | Expose the Perses service to be accessed from outside the cluster (LoadBalancer service). or access it from within the cluster (ClusterIP service). Set the service type and the port to serve it. | +| service.annotations | object | `{}` | Annotations to add to the service | +| service.labels | object | `{}` | Labeles to add to the service | +| service.port | int | `8080` | Service Port | +| service.targetPort | int | `8080` | Perses running port | +| service.type | string | `"ClusterIP"` | Service Type | +| serviceAccount | object | `{"annotations":{},"create":true,"name":""}` | Service account for Perses to use. | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `true` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | + +--- + +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/charts/perses/README.md.gotmpl b/charts/perses/README.md.gotmpl new file mode 100644 index 0000000..ad521a1 --- /dev/null +++ b/charts/perses/README.md.gotmpl @@ -0,0 +1,30 @@ + + +{{ template "chart.header" . }} +{{ template "chart.description" . }} + +{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} + +## Installing the Chart + +To install the chart with the release name `my-release`: + +``` +helm repo add perses https://perses.github.io/perses +helm repo update +helm install my-release perses/perses +``` + +## Uninstalling the Chart + +To uninstall/delete the my-release deployment: + +``` +helm delete my-release +``` + +{{ template "chart.requirementsSection" . }} + +{{ template "chart.valuesSection" . }} + +{{ template "helm-docs.versionFooter" . }} \ No newline at end of file diff --git a/charts/perses/templates/NOTES.txt b/charts/perses/templates/NOTES.txt new file mode 100644 index 0000000..f896bb6 --- /dev/null +++ b/charts/perses/templates/NOTES.txt @@ -0,0 +1,11 @@ +{{- if and .Values.config.database.file .Values.config.database.sql }} +{{ fail "[ERROR] 'config.database' must be set as file or SQL, and those options are mutually exclusive." }} +{{ end }} + +{{- if and .Values.persistence.enabled (eq .Values.persistence.storageClass "") }} +{{ fail "[ERROR] 'persistencen.storageClass' must be set." }} +{{ end }} + +{{- if and .Values.ingress.enabled (eq .Values.ingress.ingressClassName "") }} +{{ fail "[ERROR] 'ingress.ingressClassName' must be set." }} +{{ end }} \ No newline at end of file diff --git a/charts/perses/templates/_helpers.tpl b/charts/perses/templates/_helpers.tpl new file mode 100644 index 0000000..9f77a6f --- /dev/null +++ b/charts/perses/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "perses.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "perses.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "perses.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "perses.labels" -}} +helm.sh/chart: {{ include "perses.chart" . }} +{{ include "perses.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "perses.selectorLabels" -}} +app.kubernetes.io/name: {{ include "perses.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "perses.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "perses.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/perses/templates/config.yaml b/charts/perses/templates/config.yaml new file mode 100644 index 0000000..df345b9 --- /dev/null +++ b/charts/perses/templates/config.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "perses.fullname" . }} + labels: + {{- include "perses.labels" . | nindent 4 }} + {{- with .Values.config.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +type: Opaque +stringData: + config.yaml: |- + readonly: {{ .Values.config.readOnly }} + + database: + {{- with .Values.config.database.file }} + file: + {{- toYaml . | nindent 8 }} + {{ end -}} + + {{- with .Values.config.database.sql }} + sql: + {{- tpl (toYaml .) $ | nindent 8 }} + {{ end -}} + + {{- with .Values.config.important_dashboards }} + important_dashboards: + {{- toYaml . | nindent 6 }} + {{- end }} + + {{- with .Values.config.schemas }} + schemas: + {{- toYaml . | nindent 6 }} + {{- end }} + diff --git a/charts/perses/templates/ingress.yaml b/charts/perses/templates/ingress.yaml new file mode 100644 index 0000000..a2ccf0a --- /dev/null +++ b/charts/perses/templates/ingress.yaml @@ -0,0 +1,27 @@ +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "perses.fullname" . }} + labels: + {{- include "perses.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName | quote }} + {{- end }} + rules: + - host : {{ .Values.ingress.hostname }} + http: + paths: + - path: {{ .Values.ingress.path }} + pathType: {{ .Values.ingress.pathType }} + backend: + service: + name: {{ include "perses.fullname" . }} + port: + name: {{ .Values.service.port }} +{{- end }} \ No newline at end of file diff --git a/charts/perses/templates/pvc.yaml b/charts/perses/templates/pvc.yaml new file mode 100644 index 0000000..3f81d25 --- /dev/null +++ b/charts/perses/templates/pvc.yaml @@ -0,0 +1,21 @@ +{{- if .Values.persistence.enabled }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "perses.fullname" . }} + labels: + {{- include "perses.labels" . | nindent 4 }} + {{- with .Values.persistence.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + storageClassName: {{ .Values.persistence.storageClass }} + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- end }} \ No newline at end of file diff --git a/charts/perses/templates/service.yaml b/charts/perses/templates/service.yaml new file mode 100644 index 0000000..ea02774 --- /dev/null +++ b/charts/perses/templates/service.yaml @@ -0,0 +1,42 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "perses.fullname" . }} + labels: + {{- include "perses.labels" . | nindent 4 }} + {{- with .Values.service.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }} + type: ClusterIP + {{- with .Values.service.clusterIP }} + clusterIP: {{ . }} + {{- end }} + {{- else if eq .Values.service.type "LoadBalancer" }} + type: {{ .Values.service.type }} + {{- with .Values.service.loadBalancerIP }} + loadBalancerIP: {{ . }} + {{- end }} + {{- with .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- else }} + type: {{ .Values.service.type }} + {{- end }} + ports: + - name: {{ .Values.service.portName }} + port: {{ .Values.service.port }} + protocol: TCP + targetPort: {{ .Values.service.targetPort }} + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} + nodePort: {{ .Values.service.nodePort }} + {{- end }} + selector: + {{- include "perses.selectorLabels" . | nindent 4 }} + diff --git a/charts/perses/templates/serviceaccount.yaml b/charts/perses/templates/serviceaccount.yaml new file mode 100644 index 0000000..a285c49 --- /dev/null +++ b/charts/perses/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "perses.serviceAccountName" . }} + labels: + {{- include "perses.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/perses/templates/statefulset.yaml b/charts/perses/templates/statefulset.yaml new file mode 100644 index 0000000..41eac6a --- /dev/null +++ b/charts/perses/templates/statefulset.yaml @@ -0,0 +1,76 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "perses.fullname" . }} + labels: + {{- include "perses.labels" . | nindent 4 }} + {{- with .Values.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + replicas: {{ .Values.replicas }} + serviceName: {{ include "perses.fullname" . }}-headless + selector: + matchLabels: + {{- include "perses.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "perses.selectorLabels" . | nindent 8 }} + spec: + serviceAccountName: {{ include "perses.serviceAccountName" . }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.name }}:v{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --config=/perses/config/config.yaml + - --web.listen-address=:{{ .Values.service.targetPort }} + - --web.hide-port=false + - --web.telemetry-path=/metrics + - --log.level={{ .Values.logLevel }} + - --log.method-trace=true + volumeMounts: + - name: config + mountPath: "/perses/config" + - name: data + mountPath: /perses + ports: + - name: http + containerPort: {{ .Values.service.targetPort }} + readinessProbe: + httpGet: + path: /metrics + port: http + scheme: HTTP + initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} + livenessProbe: + httpGet: + path: /metrics + port: http + scheme: HTTP + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + successThreshold: {{ .Values.livenessProbe.successThreshold }} + failureThreshold: {{ .Values.livenessProbe.failureThreshold }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 10 }} + {{- end }} + volumes: + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "perses.fullname" . }} + {{- else }} + emptyDir: {} + {{- end }} + - name: config + secret: + secretName: {{ include "perses.fullname" . }} \ No newline at end of file diff --git a/charts/perses/values.schema.json b/charts/perses/values.schema.json new file mode 100644 index 0000000..3b59c7b --- /dev/null +++ b/charts/perses/values.schema.json @@ -0,0 +1,440 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "title": "Values", + "additionalProperties": false, + "properties": { + "nameOverride": { + "description": "Override name of the chart used in Kubernetes object names.", + "type": "string" + }, + "fullnameOverride": { + "description": "Override fully qualified app name.", + "type": "string" + }, + "image": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "pullPolicy": { + "type": "string" + } + }, + "required": [ + "name", + "pullPolicy" + ] + }, + "service": { + "type": "object", + "additionalProperties": false, + "properties": { + "annotations": { + "type": "object" + }, + "labels": { + "type": "object" + }, + "type": { + "type": "string", + "enum": [ + "ClusterIP", + "NodePort", + "LoadBalancer", + "ExternalName" + ] + }, + "port": { + "type": "integer" + }, + "targetPort": { + "type": "integer" + } + }, + "required": [ + "port", + "targetPort", + "type" + ] + }, + "replicas": { + "type": "integer" + }, + "logLevel": { + "type": "string", + "enum": [ + "panic", + "error", + "warning", + "info", + "debug", + "trace" + ] + }, + "annotations": { + "type": "object" + }, + "config": { + "type": "object", + "additionalProperties": false, + "properties": { + "annotations": { + "type": "object" + }, + "readOnly": { + "type": "boolean", + "default": false + }, + "schemas": { + "type": "object" + }, + "important_dashboards": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "project": { + "type": "string" + }, + "dashboard": { + "type": "string" + } + } + } + }, + "database": { + "type": "object", + "additionalProperties": false, + "properties": { + "file": { + "type": "object", + "additionalProperties": false, + "properties": { + "folder": { + "type": "string" + }, + "extension": { + "type": "string", + "enum": [ + "yaml", + "json" + ] + } + }, + "required": [ + "extension", + "folder" + ] + }, + "sql": { + "type": "object", + "additionalProperties": false, + "properties": { + "rejectReadOnly": { + "type": "boolean" + }, + "parseTime": { + "type": "boolean" + }, + "multiStatements": { + "type": "boolean" + }, + "interpolateParams": { + "type": "boolean" + }, + "columnsWithAlias": { + "type": "boolean" + }, + "clientFoundRows": { + "type": "boolean" + }, + "checkConnLiveness": { + "type": "boolean" + }, + "allowOldPasswords": { + "type": "boolean" + }, + "allowNativePasswords": { + "type": "boolean" + }, + "allowFallbackToPlaintext": { + "type": "boolean" + }, + "allowCleartextPasswords": { + "type": "boolean" + }, + "allowAllFiles": { + "type": "boolean" + }, + "writeTimeout": { + "type": "string" + }, + "readTimeout": { + "type": "string" + }, + "serverPubKey": { + "type": "string" + }, + "maxAllowedPacket": { + "type": "integer" + }, + "loc": { + "type": "string" + }, + "collation": { + "type": "string" + }, + "dbName": { + "type": "string" + }, + "addr": { + "type": "string" + }, + "net": { + "type": "string" + }, + "passwordFile": { + "type": "string" + }, + "user": { + "type": "string" + }, + "tlsConfig": { + "properties": { + "ca": { + "type": "string" + }, + "cert": { + "type": "string" + }, + "key": { + "type": "string" + }, + "caFile": { + "type": "string" + }, + "certFile": { + "type": "string" + }, + "keyFile": { + "type": "string" + }, + "serverName": { + "type": "string" + }, + "insecureSkipVerify": { + "type": "boolean" + } + } + } + } + } + }, + "required": [ + "file", + "sql" + ] + } + }, + "required": [ + "database", + "schemas" + ] + }, + "persistence": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "storageClass": { + "type": "string" + }, + "accessModes": { + "type": "array", + "items": { + "type": "string" + } + }, + "size": { + "type": "string" + }, + "labels": { + "type": "object" + }, + "annotations": { + "type": "object" + } + }, + "required": [ + "accessModes", + "enabled", + "size", + "storageClass" + ] + }, + "livenessProbe": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "initialDelaySeconds": { + "type": "integer" + }, + "periodSeconds": { + "type": "integer" + }, + "timeoutSeconds": { + "type": "integer" + }, + "successThreshold": { + "type": "integer" + }, + "failureThreshold": { + "type": "integer" + } + }, + "required": [ + "enabled", + "failureThreshold", + "initialDelaySeconds", + "periodSeconds", + "successThreshold", + "timeoutSeconds" + ] + }, + "readinessProbe": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "initialDelaySeconds": { + "type": "integer" + }, + "periodSeconds": { + "type": "integer" + }, + "timeoutSeconds": { + "type": "integer" + }, + "successThreshold": { + "type": "integer" + }, + "failureThreshold": { + "type": "integer" + } + }, + "required": [ + "enabled", + "failureThreshold", + "initialDelaySeconds", + "periodSeconds", + "successThreshold", + "timeoutSeconds" + ] + }, + "ingress": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "hostname": { + "type": "string" + }, + "ingressClassName": { + "type": "string" + }, + "annotations": { + "type": "object" + }, + "path": { + "type": "string" + }, + "pathType": { + "type": "string", + "enum": [ + "Exact", + "Prefix", + "ImplementationSpecific" + ] + } + }, + "required": [ + "hostname", + "ingressClassName", + "path", + "pathType" + ] + }, + "serviceAccount": { + "type": "object", + "additionalProperties": false, + "properties": { + "create": { + "type": "boolean" + }, + "annotations": { + "type": "object" + }, + "name": { + "type": "string" + } + }, + "required": [ + "annotations", + "create", + "name" + ] + }, + "resources": { + "type": "object", + "additionalProperties": false, + "properties": { + "limits": { + "type": "object", + "additionalProperties": false, + "properties": { + "cpu": { + "type": [ + "string", + "integer" + ] + }, + "memory": { + "type": "string" + } + } + }, + "requests": { + "type": "object", + "additionalProperties": false, + "properties": { + "cpu": { + "type": [ + "string", + "integer" + ] + }, + "memory": { + "type": "string" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/charts/perses/values.yaml b/charts/perses/values.yaml new file mode 100644 index 0000000..0c7cb99 --- /dev/null +++ b/charts/perses/values.yaml @@ -0,0 +1,164 @@ +# Default values for perses. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# -- Override name of the chart used in Kubernetes object names. +nameOverride: "" + +# -- Override fully qualified app name +fullnameOverride: "" + +## Image of Perses +## +image: + # -- Perses image repository and name + name: "persesdev/perses" + + # -- Overrides the image tag whose default is the chart appVersion. + version: "" + + # -- Default image pull policy + pullPolicy: IfNotPresent + +# -- Service account for Perses to use. +serviceAccount: + # -- Specifies whether a service account should be created + create: true + # -- Annotations to add to the service account + annotations: {} + # -- The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +# -- Expose the Perses service to be accessed from outside the cluster (LoadBalancer service). +# or access it from within the cluster (ClusterIP service). Set the service type and the port to serve it. +service: + # -- Annotations to add to the service + annotations: {} + # -- Labeles to add to the service + labels: {} + # -- Service Type + type: "ClusterIP" + # -- Service Port + port: 8080 + # -- Perses running port + targetPort: 8080 + +# -- Statefulset Annotations +annotations: {} + +# -- Number of pod replicas. +replicas: 1 + +# -- Log level for Perses be configured in +# available options "panic", "error", "warning", "info", "debug", "trace" +logLevel: info + +# -- Liveness probe configuration +# Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + enabled: true + initialDelaySeconds: 10 + periodSeconds: 60 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + +# -- Readiness probe configuration +# Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +readinessProbe: + enabled: true + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + +# -- Resource limits & requests. +# Update according to your own use case as these values might be too low for a typical deployment. +# ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ +resources: {} + +# -- Perses configuration file +# ref: https://github.com/perses/perses/blob/main/docs/configuration.md +config: + # -- Annotations for config secret + annotations: {} + + # -- Configure Perses instance as readonly + readOnly: false + + # -- Schemas paths + schemas: + panels_path: "/etc/perses/schemas/panels" + queries_path: "/etc/perses/schemas/queries" + datasources_path: "/etc/perses/schemas/datasources" + variables_path: "/etc/perses/schemas/variables" + + # -- Important dashboards list + important_dashboards: + [] + # - project: "perses" + # dashboard: "Demo" + + # -- Database config based on data base type + database: + # -- file system configs + file: + folder: /etc/perses/storage + extension: yaml + # -- SQL Config + sql: + {} + # user: "user" + # password: "password" + # net: "tcp" + # addr: "localhost:3306" + # db_name: "perses" + # allow_native_passwords: true + +# -- Persistence parameters +persistence: + # -- If disabled it will use a emptydir volume + enabled: false + + # -- Specify the `storageClass` used to provision the volume + storageClass: "" + + # -- PVC Access Modes for data volume + accessModes: + - ReadWriteOnce + + # -- PVC Storage Request for data volume + size: 8Gi + + # -- Labels for the PVC + labels: {} + # -- Annotations for the PVC + annotations: {} + +# -- Configure the ingress resource that allows you to access Thanos Query Frontend +# ref: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + # -- Enable ingress controller resource + enabled: false + + # -- Default host for the ingress resource + hostname: perses.local + + # -- IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) + # This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster . + # ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/ + # + ingressClassName: "" + + # -- Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. + # For a full list of possible ingress annotations, please see + # ref: https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md + annotations: {} + + # -- Ingress path + path: / + + # -- Ingress path type + pathType: Prefix