Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM-1911 create mina-payout-reports helm chart #232

Merged
merged 6 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: helm-docs-built
args:
# Comma separated list, no space
- --chart-to-generate=gpt-survey-summarizer,submission-report,mina-transactions-generator,mina-payouts-data-provider,mina-archive,redisinsight,uptime-service-backend,liminal-manual,delegation-program-leaderboard,matterbridge-bot,mina-staking-ledgers-exporter
- --chart-to-generate=gpt-survey-summarizer,submission-report,mina-transactions-generator,mina-payouts-data-provider,mina-archive,redisinsight,uptime-service-backend,liminal-manual,delegation-program-leaderboard,matterbridge-bot,mina-staking-ledgers-exporter,mina-payout-reports

# The `./` makes it relative to the chart-search-root
- --template-files=./README.md.gotmpl
Expand Down
23 changes: 23 additions & 0 deletions mina-payout-reports/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
24 changes: 24 additions & 0 deletions mina-payout-reports/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: mina-payout-reports
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.16.0"
104 changes: 104 additions & 0 deletions mina-payout-reports/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# mina-payout-reports

![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.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square)

A Helm chart for Kubernetes

## Prerequisites

Before using this Helm chart, you should have the following prerequisites:

- Access to Kubernetes cluster (If needed contact your friendly neighbourhood DevOps engineer)
- Helm >= v3.14.3
- (**Optional**) helmfile >= v0.162.0 to install this chart

## Installation

> Note: **examples** can be found in the repository

To install this Helm chart, the easiest is to create a helmfile.yaml with needed values and run:

```
helmfile template
helmfile apply
```

Or use helmfile only to generate resources and apply them with kubectl like so:

```
helmfile template | kubectl -f -
```

Verify that the chart is deployed successfully:

> Note: `kubectl` is a better suited tool for this

```
helmfile status
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| fullnameOverride | string | `""` | The full release name override |
| ingress.annotations | object | `{}` | The Ingress Annotations |
| ingress.className | string | `""` | The Ingress Class Name to use |
| ingress.enabled | bool | `false` | Whether to create a frontend Ingress |
| ingress.hosts | list | `[]` | The Ingress Hosts |
| ingress.tls | list | `[]` | The TLS configuration |
| nameOverride | string | `""` | The release name override |
| payoutReportsApi.affinity | object | `{}` | Affinity rules |
| payoutReportsApi.archiveDB.host | string | `"localhost"` | Mina Archive Database Host |
| payoutReportsApi.archiveDB.name | string | `"postgres"` | Mina Archive Database Name |
| payoutReportsApi.archiveDB.password | string | `"postgres"` | Mina Archive Database Password |
| payoutReportsApi.archiveDB.port | string | `"5432"` | Mina Archive Database Port |
| payoutReportsApi.archiveDB.user | string | `"postgres"` | Mina Archive Database User |
| payoutReportsApi.aws.accessKeyID | string | `""` | AWS access key ID(leave empty to assume role) |
| payoutReportsApi.aws.region | string | `"us-west-2"` | AWS Region |
| payoutReportsApi.aws.secretAccessKey | string | `""` | AWS access key secret(leave empty to assume role) |
| payoutReportsApi.contactDetailsSpreadsheetName | string | `""` | Google spreadsheet containing contact details |
| payoutReportsApi.extraEnvVars | object | `{}` | Extra Environment Variables |
| payoutReportsApi.gcpServiceAccount | string | `""` | GCP ServiceAccount json data to create a secret from |
| payoutReportsApi.image.pullPolicy | string | `"IfNotPresent"` | The pullPolicy used when pulling the image |
| payoutReportsApi.image.repository | string | `"673156464838.dkr.ecr.us-west-2.amazonaws.com/mina-payout-reports"` | The repository of the image |
| payoutReportsApi.image.tag | string | `""` | The tag of the image |
| payoutReportsApi.imagePullSecrets | list | `[]` | The secrets used to pull the image |
| payoutReportsApi.nodeSelector | object | `{}` | Node selector labels |
| payoutReportsApi.payoutsDB.host | string | `"localhost"` | Delegation Program Payouts Database Host |
| payoutReportsApi.payoutsDB.name | string | `"postgres"` | Delegation Program Payouts Database Name |
| payoutReportsApi.payoutsDB.password | string | `"postgres"` | Delegation Program Payouts Database Password |
| payoutReportsApi.payoutsDB.port | string | `"5432"` | Delegation Program Payouts Database Port |
| payoutReportsApi.payoutsDB.user | string | `"postgres"` | Delegation Program Payouts Database User |
| payoutReportsApi.podAnnotations | object | `{}` | Annotations to add to the pods |
| payoutReportsApi.podSecurityContext | object | `{}` | The Pod Security Context |
| payoutReportsApi.replicaCount | int | `1` | The number of replicas |
| payoutReportsApi.resources | object | `{}` | Resource limitations for the pods |
| payoutReportsApi.s3Bucket | string | `""` | S3 bucket where to store reports |
| payoutReportsApi.securityContext | object | `{}` | The Security Context |
| payoutReportsApi.sendgridToken | string | `""` | A token to use SendGrid email API |
| payoutReportsApi.service.port | int | `5000` | The port of the service |
| payoutReportsApi.service.type | string | `"ClusterIP"` | The type of service to create |
| payoutReportsApi.stakingLedgersBucket | string | `"mina-staking-ledgers"` | Staking ledgers bucket name(GCS) |
| payoutReportsApi.tolerations | list | `[]` | Tolerations |
| payoutReportsApi.walletMappingSpreadsheetTab | string | `""` | Google's public spreadsheet sheet(tab) name |
| payoutReportsApi.walletMappingSpreadsheetUrl | string | `""` | Google's public spreadsheet url containing wallet mappings |
| payoutReportsWeb.affinity | object | `{}` | Affinity rules |
| payoutReportsWeb.extraEnvVars | list | `[]` | Additional list of Environment Variables |
| payoutReportsWeb.image.pullPolicy | string | `"IfNotPresent"` | The pullPolicy used when pulling the image |
| payoutReportsWeb.image.repository | string | `"673156464838.dkr.ecr.us-west-2.amazonaws.com/mina-payout-reports"` | The repository of the image |
| payoutReportsWeb.image.tag | string | `""` | The tag of the image |
| payoutReportsWeb.imagePullSecrets | list | `[]` | The secrets used to pull the image |
| payoutReportsWeb.nodeSelector | object | `{}` | Node selector labels |
| payoutReportsWeb.podAnnotations | object | `{}` | Annotations to add to the pods |
| payoutReportsWeb.podSecurityContext | object | `{}` | The Pod Security Context |
| payoutReportsWeb.replicaCount | int | `1` | The number of replicas |
| payoutReportsWeb.resources | object | `{}` | Resource limitations for the pods |
| payoutReportsWeb.securityContext | object | `{}` | The Security Context |
| payoutReportsWeb.service.port | int | `3000` | The port of the service |
| payoutReportsWeb.service.type | string | `"ClusterIP"` | The type of service to create |
| payoutReportsWeb.tolerations | list | `[]` | Tolerations |
| 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 | `""` | If not set and create is true, a name is generated using the fullname template |

5 changes: 5 additions & 0 deletions mina-payout-reports/files/entrypoint_initdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -x

invoke create-database
69 changes: 69 additions & 0 deletions mina-payout-reports/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mina-payout-reports.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 "mina-payout-reports.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 "mina-payout-reports.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "mina-payout-reports.labels" -}}
helm.sh/chart: {{ include "mina-payout-reports.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels for backend
*/}}
{{- define "mina-payout-reports.selectorLabelsApi" -}}
app.kubernetes.io/name: {{ include "mina-payout-reports.name" . }}-api
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Selector labels for frontend
*/}}
{{- define "mina-payout-reports.selectorLabelsWeb" -}}
app.kubernetes.io/name: {{ include "mina-payout-reports.name" . }}-web
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "mina-payout-reports.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "mina-payout-reports.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions mina-payout-reports/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mina-payout-reports.fullname" . }}-initdb
data:
entrypoint-initdb.sh: |-
{{ .Files.Get "files/entrypoint_initdb.sh" | indent 4 }}
144 changes: 144 additions & 0 deletions mina-payout-reports/templates/deployment-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mina-payout-reports.fullname" . }}-api
labels:
{{- include "mina-payout-reports.labels" . | nindent 4 }}
{{- include "mina-payout-reports.selectorLabelsApi" . | nindent 4 }}
spec:
{{- with .Values.payoutReportsApi }}
replicas: {{ .replicaCount }}
selector:
matchLabels:
{{- include "mina-payout-reports.selectorLabelsApi" $ | nindent 6 }}
template:
metadata:
{{- with .podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "mina-payout-reports.selectorLabelsApi" $ | nindent 8 }}
spec:
{{- with .imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "mina-payout-reports.serviceAccountName" $ }}
securityContext:
{{- toYaml .podSecurityContext | nindent 8 }}
initContainers:
- name: initdb
image: "{{ .image.repository }}:{{ .image.tag | default $.Chart.AppVersion }}"
env:
- name: POSTGRES_PAYOUT_HOST
value: {{ .payoutsDB.host | quote }}
- name: POSTGRES_PAYOUT_PORT
value: {{ .payoutsDB.port | quote }}
- name: POSTGRES_PAYOUT_DB
value: {{ .payoutsDB.name | quote }}
- name: POSTGRES_PAYOUT_USER
value: {{ .payoutsDB.user | quote }}
- name: POSTGRES_PAYOUT_PASSWORD
value: {{ .payoutsDB.password | quote }}
command: ["/bin/entrypoint/entrypoint-initdb.sh"]
volumeMounts:
- name: entrypoint-initdb
mountPath: "/bin/entrypoint"
containers:
- name: payout-reports-api
securityContext:
{{- toYaml .securityContext | nindent 12 }}
image: "{{ .image.repository }}:{{ .image.tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ .image.pullPolicy }}
env:
- name: POSTGRES_PAYOUT_HOST
value: {{ .payoutsDB.host | quote }}
- name: POSTGRES_PAYOUT_PORT
value: {{ .payoutsDB.port | quote }}
- name: POSTGRES_PAYOUT_DB
value: {{ .payoutsDB.name | quote }}
- name: POSTGRES_PAYOUT_USER
value: {{ .payoutsDB.user | quote }}
- name: POSTGRES_PAYOUT_PASSWORD
value: {{ .payoutsDB.password | quote }}
- name: POSTGRES_ARCHIVE_HOST
value: {{ .archiveDB.host | quote }}
- name: POSTGRES_ARCHIVE_PORT
value: {{ .archiveDB.port | quote }}
- name: POSTGRES_ARCHIVE_USER
value: {{ .archiveDB.user | quote }}
- name: POSTGRES_ARCHIVE_PASSWORD
value: {{ .archiveDB.password | quote }}
- name: POSTGRES_ARCHIVE_DB
value: {{ .archiveDB.name | quote }}
- name: SENDGRID_API_KEY
value: {{ .sendgridToken | quote }}
- name: SPREADSHEET_CREDENTIALS_JSON
value: /app/mina_payout/api/gcloud/gcp-sa.json
- name: CONTACT_DETAILS_SPREADSHEET_NAME
value: {{ .contactDetailsSpreadsheetName | quote }}
- name: GCS_BUCKET_NAME
value: {{ .stakingLedgersBucket | quote }}
- name: BP_WALLET_MAPPING_URL
value: {{ .walletMappingSpreadsheetUrl | quote }}
- name: BP_WALLET_MAPPING_TAB
value: {{ .walletMappingSpreadsheetTab | quote }}
- name: AWS_BUCKET_NAME
value: {{ .s3Bucket | quote }}
- name: AWS_REGION
value: {{ .aws.region | quote }}
- name: AWS_ACCESS_KEY_ID
value: {{ .aws.accessKeyID }}
- name: AWS_SECRET_ACCESS_KEY
value: {{ .aws.secretAccessKey }}
- name: SERVER_ALLOWED_ORIGINS
value: "*"
{{- if .extraEnvVars }}
{{- toYaml .extraEnvVars | nindent 12 }}
{{- end }}
volumeMounts:
- name: gcp-sa
mountPath: /app/mina_payout/api/gcloud
ports:
- name: http
containerPort: {{ .service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
resources:
{{- toYaml .resources | nindent 12 }}
{{- with .nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: entrypoint-initdb
configMap:
name: {{ include "mina-payout-reports.fullname" $ }}-initdb
defaultMode: 0777
items:
- key: "entrypoint-initdb.sh"
path: "entrypoint-initdb.sh"
- name: gcp-sa
secret:
secretName: {{ include "mina-payout-reports.fullname" $ }}
defaultMode: 0600
items:
- key: gcp-sa-json
path: gcp-sa.json
{{- end }}
Loading
Loading