diff --git a/.github/workflows/helm-charts-release.yml b/.github/workflows/helm-charts-release.yml new file mode 100644 index 0000000..edd446f --- /dev/null +++ b/.github/workflows/helm-charts-release.yml @@ -0,0 +1,31 @@ +name: Release Charts + +on: + push: + branches: + - main + +jobs: + release: + name: Release Charts + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + 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: Install Helm + uses: azure/setup-helm@v1 + with: + version: v3.4.0 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.1.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/helm-charts-test.yml b/.github/workflows/helm-charts-test.yml index fc003af..3df8c3e 100644 --- a/.github/workflows/helm-charts-test.yml +++ b/.github/workflows/helm-charts-test.yml @@ -1,50 +1,47 @@ -name: "helm-charts/test" - -on: - schedule: - - cron: '0 2 * * *' # run at 2 AM UTC - push: - branches: - - dev - pull_request: - branches: - - master +name: Lint and Test Charts + +on: pull_request jobs: lint-test: runs-on: ubuntu-latest - steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up Helm uses: azure/setup-helm@v1 with: - version: v3.4.0 + version: v3.4.1 - - uses: actions/setup-python@v2 + # Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and + # yamllint (https://github.com/adrienverge/yamllint) which require Python + - name: Set up Python + uses: actions/setup-python@v2 with: python-version: 3.7 - name: Set up chart-testing uses: helm/chart-testing-action@v2.0.1 + with: + version: v3.3.0 - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(ct list-changed) + changed=$(ct list-changed --config ct.yaml) if [[ -n "$changed" ]]; then echo "::set-output name=changed::true" fi - name: Run chart-testing (lint) - run: ct lint + run: ct lint --config ct.yaml - name: Create kind cluster - uses: helm/kind-action@v1.0.0 - # Only build a kind cluster if there are chart changes to test. + uses: helm/kind-action@v1.1.0 if: steps.list-changed.outputs.changed == 'true' - name: Run chart-testing (install) - run: ct install \ No newline at end of file + run: ct install --config ct.yaml diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 843460a..2119297 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -3,7 +3,7 @@ name: Release Drafter on: push: branches: - - master + - main jobs: update_release_draft: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e0815a2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: + - repo: local + hooks: + - id: helm-docs + name: Helm Docs + description: Uses 'helm-docs' to create documentation from the Helm chart's 'values.yaml' file, and inserts the result into a corresponding 'README.md' file. + entry: git-hook/helm-docs + files: (README\.md\.gotmpl|(Chart|requirements|values)\.yaml)$ + language: script + require_serial: true + args: + # Make the tool search for charts only under the `charts` directory + - --chart-search-root=charts \ No newline at end of file diff --git a/charts/daemon/Chart.yaml b/charts/daemon/Chart.yaml index f2721c0..8b1b342 100644 --- a/charts/daemon/Chart.yaml +++ b/charts/daemon/Chart.yaml @@ -14,8 +14,14 @@ 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. -version: 0.1.0 +version: 0.1.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. appVersion: latest + +maintainers: + - name: abhi1693 + email: desk.abhimanyu@gmail.com + +icon: https://avatars0.githubusercontent.com/u/60273284 diff --git a/charts/daemon/README.md b/charts/daemon/README.md new file mode 100644 index 0000000..a3dd0ef --- /dev/null +++ b/charts/daemon/README.md @@ -0,0 +1,45 @@ +# daemon + +![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square) + +A Helm chart for Kryptos daemon + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| abhi1693 | desk.abhimanyu@gmail.com | | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| env.CI | int | `1` | | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"kryptosteam/daemon"` | | +| imagePullSecrets | list | `[]` | | +| ingress.annotations | object | `{}` | | +| ingress.enabled | bool | `false` | | +| ingress.hosts[0].host | string | `"chart-example.local"` | | +| ingress.hosts[0].paths | list | `[]` | | +| ingress.tls | list | `[]` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| persistence.accessMode | string | `"ReadWriteOnce"` | | +| persistence.enabled | bool | `false` | | +| persistence.mountPath | string | `"/opt"` | | +| persistence.size | string | `"50Gi"` | | +| podSecurityContext | object | `{}` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `80` | | +| service.type | string | `"ClusterIP"` | | +| serviceAccount.annotations | object | `{}` | | +| serviceAccount.create | bool | `true` | | +| serviceAccount.name | string | `nil` | | +| tolerations | list | `[]` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.4.0](https://github.com/norwoodj/helm-docs/releases/v1.4.0) diff --git a/charts/daemon/templates/persistent-volume-claim.yaml b/charts/daemon/templates/persistent-volume-claim.yaml new file mode 100644 index 0000000..8ac6103 --- /dev/null +++ b/charts/daemon/templates/persistent-volume-claim.yaml @@ -0,0 +1,23 @@ +{{- if and (.Values.persistence.enabled) }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: "{{ template "charts.fullname" . }}" + labels: + {{- include "charts.labels" . | nindent 4 }} + annotations: + helm.sh/resource-policy: "keep" +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/daemon/templates/statefulset.yaml b/charts/daemon/templates/statefulset.yaml index cf7a25b..d4cce63 100644 --- a/charts/daemon/templates/statefulset.yaml +++ b/charts/daemon/templates/statefulset.yaml @@ -9,6 +9,7 @@ spec: selector: matchLabels: {{- include "charts.selectorLabels" . | nindent 6 }} + serviceName: "{{ include "charts.fullname" . }}" template: metadata: labels: @@ -35,6 +36,13 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.env }} + env: + {{- range $name, $value := .Values.env }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} + {{- end }} ports: - name: http containerPort: 80 diff --git a/charts/daemon/values.yaml b/charts/daemon/values.yaml index 000e88c..70791ef 100644 --- a/charts/daemon/values.yaml +++ b/charts/daemon/values.yaml @@ -10,6 +10,9 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +env: + CI: 1 + serviceAccount: # Specifies whether a service account should be created create: true @@ -62,7 +65,7 @@ resources: {} # Persist data to a persistent volume ## persistence: - enabled: true + enabled: false ## If true will use an existing PVC instead of creating one # useExisting: false ## Name of existing PVC to be used in the influx deployment diff --git a/ct.yaml b/ct.yaml index 2ad26b6..6f1480d 100644 --- a/ct.yaml +++ b/ct.yaml @@ -1,5 +1,5 @@ remote: origin -target-branch: master +target-branch: main chart-dirs: - charts helm-extra-args: --timeout 300s diff --git a/git-hook/helm-docs b/git-hook/helm-docs new file mode 100755 index 0000000..28e21b3 --- /dev/null +++ b/git-hook/helm-docs @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e + +VERSION=1.4.0 + +if ! command -v helm-docs &>/dev/null; then + wget https://github.com/norwoodj/helm-docs/releases/download/v"${VERSION}"/helm-docs_"${VERSION}"_linux_amd64.deb + sudo dpkg -i helm-docs_"${VERSION}"_linux_amd64.deb + rm helm-docs_"${VERSION}"_linux_amd64.deb +fi + +if ! command -v pre-commit &>/dev/null; then + pip install pre-commit +fi + +helm-docs "${@}" \ No newline at end of file