From e07846356b5af28403afad4f89f7103d1d148f4d Mon Sep 17 00:00:00 2001 From: Simonas Narbutas Date: Tue, 23 Jul 2024 18:39:49 +0300 Subject: [PATCH 1/6] PM-1911 create mina-payout-reports helm chart --- .pre-commit-config.yaml | 2 +- mina-payout-reports/.helmignore | 23 ++ mina-payout-reports/Chart.yaml | 24 +++ mina-payout-reports/README.md | 99 +++++++++ .../files/entrypoint_initdb.sh | 5 + mina-payout-reports/templates/_helpers.tpl | 62 ++++++ mina-payout-reports/templates/configmap.yaml | 7 + .../templates/deployment-api.yaml | 143 ++++++++++++ .../templates/deployment-web.yaml | 67 ++++++ mina-payout-reports/templates/ingress.yaml | 61 ++++++ mina-payout-reports/templates/secret.yaml | 9 + mina-payout-reports/templates/service.yaml | 15 ++ .../templates/serviceaccount.yaml | 13 ++ mina-payout-reports/values.yaml | 203 ++++++++++++++++++ 14 files changed, 732 insertions(+), 1 deletion(-) create mode 100644 mina-payout-reports/.helmignore create mode 100644 mina-payout-reports/Chart.yaml create mode 100644 mina-payout-reports/README.md create mode 100644 mina-payout-reports/files/entrypoint_initdb.sh create mode 100644 mina-payout-reports/templates/_helpers.tpl create mode 100644 mina-payout-reports/templates/configmap.yaml create mode 100644 mina-payout-reports/templates/deployment-api.yaml create mode 100644 mina-payout-reports/templates/deployment-web.yaml create mode 100644 mina-payout-reports/templates/ingress.yaml create mode 100644 mina-payout-reports/templates/secret.yaml create mode 100644 mina-payout-reports/templates/service.yaml create mode 100644 mina-payout-reports/templates/serviceaccount.yaml create mode 100644 mina-payout-reports/values.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ed636e7..95ee8048 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/mina-payout-reports/.helmignore b/mina-payout-reports/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/mina-payout-reports/.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/mina-payout-reports/Chart.yaml b/mina-payout-reports/Chart.yaml new file mode 100644 index 00000000..22737c4e --- /dev/null +++ b/mina-payout-reports/Chart.yaml @@ -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" diff --git a/mina-payout-reports/README.md b/mina-payout-reports/README.md new file mode 100644 index 00000000..13eedd97 --- /dev/null +++ b/mina-payout-reports/README.md @@ -0,0 +1,99 @@ +# 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 | +| 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 | + diff --git a/mina-payout-reports/files/entrypoint_initdb.sh b/mina-payout-reports/files/entrypoint_initdb.sh new file mode 100644 index 00000000..c62e0f62 --- /dev/null +++ b/mina-payout-reports/files/entrypoint_initdb.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -x + +invoke create-database diff --git a/mina-payout-reports/templates/_helpers.tpl b/mina-payout-reports/templates/_helpers.tpl new file mode 100644 index 00000000..4fcf30c2 --- /dev/null +++ b/mina-payout-reports/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +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" . }} +{{ include "mina-payout-reports.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "mina-payout-reports.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mina-payout-reports.name" . }} +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 }} diff --git a/mina-payout-reports/templates/configmap.yaml b/mina-payout-reports/templates/configmap.yaml new file mode 100644 index 00000000..50efc031 --- /dev/null +++ b/mina-payout-reports/templates/configmap.yaml @@ -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 }} diff --git a/mina-payout-reports/templates/deployment-api.yaml b/mina-payout-reports/templates/deployment-api.yaml new file mode 100644 index 00000000..472c1568 --- /dev/null +++ b/mina-payout-reports/templates/deployment-api.yaml @@ -0,0 +1,143 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "mina-payout-reports.fullname" . }}-api + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }}-api +spec: + {{- with .Values.payoutReportsApi }} + replicas: {{ .replicaCount }} + selector: + matchLabels: + {{- include "mina-payout-reports.selectorLabels" $ | nindent 6 }}-api + template: + metadata: + {{- with .podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "mina-payout-reports.selectorLabels" $ | nindent 8 }}-api + 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 }}" + 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: leaderboard-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 }} diff --git a/mina-payout-reports/templates/deployment-web.yaml b/mina-payout-reports/templates/deployment-web.yaml new file mode 100644 index 00000000..4caeb38a --- /dev/null +++ b/mina-payout-reports/templates/deployment-web.yaml @@ -0,0 +1,67 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "mina-payout-reports.fullname" . }}-web + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }}-web +spec: + {{- with .Values.payoutReportsWeb }} + replicas: {{ .replicaCount }} + selector: + matchLabels: + {{- include "mina-payout-reports.selectorLabels" $ | nindent 6 }}-web + template: + metadata: + {{- with .podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "mina-payout-reports.selectorLabels" $ | nindent 8 }}-web + spec: + {{- with .imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "mina-payout-reports.serviceAccountName" $ }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - name: leaderboard-web + securityContext: + {{- toYaml .securityContext | nindent 12 }} + image: "{{ .image.repository }}:{{ .image.tag | default $.Chart.AppVersion }}" + imagePullPolicy: {{ .image.pullPolicy }} + env: + - name: REACT_APP_API_URL + value: "{{ include "mina-payout-reports.fullname" . }}-api:{{ $.Values.payoutReportsApi.service.port }}" + {{- if .extraEnvVars }} + {{- toYaml .extraEnvVars | nindent 12 }} + {{- end }} + 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 }} + {{- end }} diff --git a/mina-payout-reports/templates/ingress.yaml b/mina-payout-reports/templates/ingress.yaml new file mode 100644 index 00000000..6c0a6451 --- /dev/null +++ b/mina-payout-reports/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "mina-payout-reports.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/mina-payout-reports/templates/secret.yaml b/mina-payout-reports/templates/secret.yaml new file mode 100644 index 00000000..cb4bb7bd --- /dev/null +++ b/mina-payout-reports/templates/secret.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "mina-payout-reports.fullname" . }} + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }} +data: + gcp-sa-json: {{ .Values.payoutReportsApi.gcpServiceAccount | toString | b64enc }} diff --git a/mina-payout-reports/templates/service.yaml b/mina-payout-reports/templates/service.yaml new file mode 100644 index 00000000..126dd1f1 --- /dev/null +++ b/mina-payout-reports/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "mina-payout-reports.fullname" . }} + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "mina-payout-reports.selectorLabels" . | nindent 4 }} diff --git a/mina-payout-reports/templates/serviceaccount.yaml b/mina-payout-reports/templates/serviceaccount.yaml new file mode 100644 index 00000000..36b1e201 --- /dev/null +++ b/mina-payout-reports/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "mina-payout-reports.serviceAccountName" . }} + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/mina-payout-reports/values.yaml b/mina-payout-reports/values.yaml new file mode 100644 index 00000000..c72a0fa0 --- /dev/null +++ b/mina-payout-reports/values.yaml @@ -0,0 +1,203 @@ +# Default values for mina-payout-reports. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# -- The release name override +nameOverride: "" +# -- The full release name override +fullnameOverride: "" + +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: "" + +# Configuration options for `mina-payout-reports` frontend deployment +payoutReportsWeb: + # -- The number of replicas + replicaCount: 1 + + image: + # -- The repository of the image + repository: 673156464838.dkr.ecr.us-west-2.amazonaws.com/mina-payout-reports + # -- The pullPolicy used when pulling the image + pullPolicy: IfNotPresent + # -- The tag of the image + tag: "" + + # -- The secrets used to pull the image + imagePullSecrets: [] + + # -- Annotations to add to the pods + podAnnotations: {} + + # -- The Pod Security Context + podSecurityContext: {} + # fsGroup: 2000 + + # -- The Security Context + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + # -- The type of service to create + type: ClusterIP + # -- The port of the service + port: 3000 + + # -- Additional list of Environment Variables + extraEnvVars: [] + # See Application's README(or source code). + # - name: FOO + # value: FOO + # - name: BAR + # valueFrom: + # secretKeyRef: + # name: mySecret + # key: bar offline: + + # -- Resource limitations for the pods + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + # -- Node selector labels + nodeSelector: {} + + # -- Tolerations + tolerations: [] + + # -- Affinity rules + affinity: {} + +# Configuration options for `mina-payout-reports` backend deployment +payoutReportsApi: + payoutsDB: + # -- Delegation Program Payouts Database Host + host: "localhost" + # -- Delegation Program Payouts Database Port + port: "5432" + # -- Delegation Program Payouts Database User + user: "postgres" + # -- Delegation Program Payouts Database Password + password: "postgres" + # -- Delegation Program Payouts Database Name + name: "postgres" + archiveDB: + # -- Mina Archive Database Host + host: "localhost" + # -- Mina Archive Database Port + port: "5432" + # -- Mina Archive Database User + user: "postgres" + # -- Mina Archive Database Password + password: "postgres" + # -- Mina Archive Database Name + name: "postgres" + # -- A token to use SendGrid email API + sendgridToken: "" + # -- GCP ServiceAccount json data to create a secret from + gcpServiceAccount: "" + # -- Google spreadsheet containing contact details + contactDetailsSpreadsheetName: "" + # -- Staking ledgers bucket name(GCS) + stakingLedgersBucket: mina-staking-ledgers + # -- Google's public spreadsheet url containing wallet mappings + walletMappingSpreadsheetUrl: "" + # -- Google's public spreadsheet sheet(tab) name + walletMappingSpreadsheetTab: "" + # -- S3 bucket where to store reports + s3Bucket: "" + aws: + # -- AWS Region + region: "us-west-2" + # -- AWS access key ID(leave empty to assume role) + accessKeyID: "" + # -- AWS access key secret(leave empty to assume role) + secretAccessKey: "" + + # -- The number of replicas + replicaCount: 1 + + image: + # -- The repository of the image + repository: 673156464838.dkr.ecr.us-west-2.amazonaws.com/mina-payout-reports + # -- The pullPolicy used when pulling the image + pullPolicy: IfNotPresent + # -- The tag of the image + tag: "" + + # -- The secrets used to pull the image + imagePullSecrets: [] + + # -- Annotations to add to the pods + podAnnotations: {} + + # -- The Pod Security Context + podSecurityContext: {} + # fsGroup: 2000 + + # -- The Security Context + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + # -- The type of service to create + type: ClusterIP + # -- The port of the service + port: 5000 + + # -- Extra Environment Variables + extraEnvVars: {} + # See Application's README(or source code). + # - name: FOO + # value: FOO + # - name: BAR + # valueFrom: + # secretKeyRef: + # name: mySecret + # key: bar offline: + + # -- Resource limitations for the pods + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + # -- Node selector labels + nodeSelector: {} + + # -- Tolerations + tolerations: [] + + # -- Affinity rules + affinity: {} From 986d76d856bbebca3bea6e809e7a62c1b37d08ce Mon Sep 17 00:00:00 2001 From: Simonas Date: Wed, 24 Jul 2024 08:30:02 +0300 Subject: [PATCH 2/6] Update mina-payout-reports/templates/deployment-api.yaml Co-authored-by: John Marcou <18156208+johnmarcou@users.noreply.github.com> --- mina-payout-reports/templates/deployment-api.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mina-payout-reports/templates/deployment-api.yaml b/mina-payout-reports/templates/deployment-api.yaml index 472c1568..ee13feac 100644 --- a/mina-payout-reports/templates/deployment-api.yaml +++ b/mina-payout-reports/templates/deployment-api.yaml @@ -128,14 +128,14 @@ spec: volumes: - name: entrypoint-initdb configMap: - name: {{ include "mina-payout-reports.fullname" . }}-initdb + 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" . }} + secretName: {{ include "mina-payout-reports.fullname" $ }} defaultMode: 0600 items: - key: gcp-sa-json From 72711610a5c680d6afa848d74b8b774ce543f1a7 Mon Sep 17 00:00:00 2001 From: Simonas Date: Wed, 24 Jul 2024 08:30:17 +0300 Subject: [PATCH 3/6] Update mina-payout-reports/templates/deployment-web.yaml Co-authored-by: John Marcou <18156208+johnmarcou@users.noreply.github.com> --- mina-payout-reports/templates/deployment-web.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mina-payout-reports/templates/deployment-web.yaml b/mina-payout-reports/templates/deployment-web.yaml index 4caeb38a..c36a88c9 100644 --- a/mina-payout-reports/templates/deployment-web.yaml +++ b/mina-payout-reports/templates/deployment-web.yaml @@ -34,7 +34,7 @@ spec: imagePullPolicy: {{ .image.pullPolicy }} env: - name: REACT_APP_API_URL - value: "{{ include "mina-payout-reports.fullname" . }}-api:{{ $.Values.payoutReportsApi.service.port }}" + value: "{{ include "mina-payout-reports.fullname" $ }}-api:{{ $.Values.payoutReportsApi.service.port }}" {{- if .extraEnvVars }} {{- toYaml .extraEnvVars | nindent 12 }} {{- end }} From d495c4b9d8196855d557e209d92c6da11720d90d Mon Sep 17 00:00:00 2001 From: Simonas Narbutas Date: Wed, 24 Jul 2024 10:35:27 +0300 Subject: [PATCH 4/6] PM-1911 fix labels for payout reports chart --- mina-payout-reports/README.md | 5 +++++ mina-payout-reports/templates/_helpers.tpl | 15 +++++++++---- .../templates/deployment-api.yaml | 9 ++++---- .../templates/deployment-web.yaml | 7 ++++--- mina-payout-reports/templates/ingress.yaml | 7 ++++--- .../{secret.yaml => secret-api.yaml} | 2 +- .../templates/service-api.yaml | 16 ++++++++++++++ .../templates/service-web.yaml | 16 ++++++++++++++ mina-payout-reports/templates/service.yaml | 15 ------------- .../templates/serviceaccount.yaml | 2 ++ mina-payout-reports/values.yaml | 21 +++++++++++++++++++ 11 files changed, 85 insertions(+), 30 deletions(-) rename mina-payout-reports/templates/{secret.yaml => secret-api.yaml} (77%) create mode 100644 mina-payout-reports/templates/service-api.yaml create mode 100644 mina-payout-reports/templates/service-web.yaml delete mode 100644 mina-payout-reports/templates/service.yaml diff --git a/mina-payout-reports/README.md b/mina-payout-reports/README.md index 13eedd97..dee5efa2 100644 --- a/mina-payout-reports/README.md +++ b/mina-payout-reports/README.md @@ -42,6 +42,11 @@ helmfile status | 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 | diff --git a/mina-payout-reports/templates/_helpers.tpl b/mina-payout-reports/templates/_helpers.tpl index 4fcf30c2..e76b7b26 100644 --- a/mina-payout-reports/templates/_helpers.tpl +++ b/mina-payout-reports/templates/_helpers.tpl @@ -35,7 +35,6 @@ Common labels */}} {{- define "mina-payout-reports.labels" -}} helm.sh/chart: {{ include "mina-payout-reports.chart" . }} -{{ include "mina-payout-reports.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -43,10 +42,18 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{/* -Selector labels +Selector labels for backend */}} -{{- define "mina-payout-reports.selectorLabels" -}} -app.kubernetes.io/name: {{ include "mina-payout-reports.name" . }} +{{- 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 }} diff --git a/mina-payout-reports/templates/deployment-api.yaml b/mina-payout-reports/templates/deployment-api.yaml index ee13feac..dbfec30c 100644 --- a/mina-payout-reports/templates/deployment-api.yaml +++ b/mina-payout-reports/templates/deployment-api.yaml @@ -3,13 +3,14 @@ kind: Deployment metadata: name: {{ include "mina-payout-reports.fullname" . }}-api labels: - {{- include "mina-payout-reports.labels" . | nindent 4 }}-api + {{- 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.selectorLabels" $ | nindent 6 }}-api + {{- include "mina-payout-reports.selectorLabelsApi" $ | nindent 6 }} template: metadata: {{- with .podAnnotations }} @@ -17,7 +18,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "mina-payout-reports.selectorLabels" $ | nindent 8 }}-api + {{- include "mina-payout-reports.selectorLabelsApi" $ | nindent * }} spec: {{- with .imagePullSecrets }} imagePullSecrets: @@ -28,7 +29,7 @@ spec: {{- toYaml .podSecurityContext | nindent 8 }} initContainers: - name: initdb - image: "{{ .image.repository }}:{{ .image.tag }}" + image: "{{ .image.repository }}:{{ .image.tag | default $.Chart.AppVersion }}" env: - name: POSTGRES_PAYOUT_HOST value: {{ .payoutsDB.host | quote }} diff --git a/mina-payout-reports/templates/deployment-web.yaml b/mina-payout-reports/templates/deployment-web.yaml index c36a88c9..ffbebc15 100644 --- a/mina-payout-reports/templates/deployment-web.yaml +++ b/mina-payout-reports/templates/deployment-web.yaml @@ -3,13 +3,14 @@ kind: Deployment metadata: name: {{ include "mina-payout-reports.fullname" . }}-web labels: - {{- include "mina-payout-reports.labels" . | nindent 4 }}-web + {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }} spec: {{- with .Values.payoutReportsWeb }} replicas: {{ .replicaCount }} selector: matchLabels: - {{- include "mina-payout-reports.selectorLabels" $ | nindent 6 }}-web + {{- include "mina-payout-reports.selectorLabelsWeb" $ | nindent 6 }} template: metadata: {{- with .podAnnotations }} @@ -17,7 +18,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "mina-payout-reports.selectorLabels" $ | nindent 8 }}-web + {{- include "mina-payout-reports.selectorLabelsWeb" $ | nindent 8 }} spec: {{- with .imagePullSecrets }} imagePullSecrets: diff --git a/mina-payout-reports/templates/ingress.yaml b/mina-payout-reports/templates/ingress.yaml index 6c0a6451..152970c7 100644 --- a/mina-payout-reports/templates/ingress.yaml +++ b/mina-payout-reports/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "mina-payout-reports.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.payoutReportsWeb.service.port -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} @@ -18,6 +18,7 @@ metadata: name: {{ $fullName }} labels: {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }} {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} @@ -49,11 +50,11 @@ spec: backend: {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} service: - name: {{ $fullName }} + name: {{ $fullName }}-web port: number: {{ $svcPort }} {{- else }} - serviceName: {{ $fullName }} + serviceName: {{ $fullName }}-web servicePort: {{ $svcPort }} {{- end }} {{- end }} diff --git a/mina-payout-reports/templates/secret.yaml b/mina-payout-reports/templates/secret-api.yaml similarity index 77% rename from mina-payout-reports/templates/secret.yaml rename to mina-payout-reports/templates/secret-api.yaml index cb4bb7bd..8c3563a0 100644 --- a/mina-payout-reports/templates/secret.yaml +++ b/mina-payout-reports/templates/secret-api.yaml @@ -1,9 +1,9 @@ ---- apiVersion: v1 kind: Secret metadata: name: {{ include "mina-payout-reports.fullname" . }} labels: {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsApi" . | nindent 4 }} data: gcp-sa-json: {{ .Values.payoutReportsApi.gcpServiceAccount | toString | b64enc }} diff --git a/mina-payout-reports/templates/service-api.yaml b/mina-payout-reports/templates/service-api.yaml new file mode 100644 index 00000000..e9d78f6b --- /dev/null +++ b/mina-payout-reports/templates/service-api.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "mina-payout-reports.fullname" . }}-api + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsApi" . | nindent 4 }} +spec: + type: {{ .Values.leaderboardApi.service.type }} + ports: + - port: {{ .Values.leaderboardApi.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "mina-payout-reports.selectorLabelsApi" . | nindent 4 }} diff --git a/mina-payout-reports/templates/service-web.yaml b/mina-payout-reports/templates/service-web.yaml new file mode 100644 index 00000000..3b5108f4 --- /dev/null +++ b/mina-payout-reports/templates/service-web.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "mina-payout-reports.fullname" . }}-web + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }} +spec: + type: {{ .Values.leaderboardWeb.service.type }} + ports: + - port: {{ .Values.leaderboardWeb.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }} diff --git a/mina-payout-reports/templates/service.yaml b/mina-payout-reports/templates/service.yaml deleted file mode 100644 index 126dd1f1..00000000 --- a/mina-payout-reports/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "mina-payout-reports.fullname" . }} - labels: - {{- include "mina-payout-reports.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "mina-payout-reports.selectorLabels" . | nindent 4 }} diff --git a/mina-payout-reports/templates/serviceaccount.yaml b/mina-payout-reports/templates/serviceaccount.yaml index 36b1e201..1caf212c 100644 --- a/mina-payout-reports/templates/serviceaccount.yaml +++ b/mina-payout-reports/templates/serviceaccount.yaml @@ -5,6 +5,8 @@ metadata: name: {{ include "mina-payout-reports.serviceAccountName" . }} labels: {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsApi" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/mina-payout-reports/values.yaml b/mina-payout-reports/values.yaml index c72a0fa0..b9c8e2d0 100644 --- a/mina-payout-reports/values.yaml +++ b/mina-payout-reports/values.yaml @@ -201,3 +201,24 @@ payoutReportsApi: # -- Affinity rules affinity: {} + +ingress: + # -- Whether to create a frontend Ingress + enabled: false + # -- The Ingress Class Name to use + className: "" + # -- The Ingress Annotations + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # -- The Ingress Hosts + hosts: [] + # - host: chart-example.local + # paths: + # - path: / + # pathType: ImplementationSpecific + # -- The TLS configuration + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local From baf059f8d064b4d48a00619130ae907bb5d4049f Mon Sep 17 00:00:00 2001 From: Simonas Narbutas Date: Thu, 25 Jul 2024 00:01:29 +0300 Subject: [PATCH 5/6] PM-1911 fix invalid names for payout reports --- mina-payout-reports/templates/deployment-api.yaml | 6 +++--- mina-payout-reports/templates/deployment-web.yaml | 2 +- mina-payout-reports/templates/service-api.yaml | 4 ++-- mina-payout-reports/templates/service-web.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mina-payout-reports/templates/deployment-api.yaml b/mina-payout-reports/templates/deployment-api.yaml index dbfec30c..00fe564a 100644 --- a/mina-payout-reports/templates/deployment-api.yaml +++ b/mina-payout-reports/templates/deployment-api.yaml @@ -18,7 +18,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "mina-payout-reports.selectorLabelsApi" $ | nindent * }} + {{- include "mina-payout-reports.selectorLabelsApi" $ | nindent 8 }} spec: {{- with .imagePullSecrets }} imagePullSecrets: @@ -46,7 +46,7 @@ spec: - name: entrypoint-initdb mountPath: "/bin/entrypoint" containers: - - name: leaderboard-api + - name: payout-reports-api securityContext: {{- toYaml .securityContext | nindent 12 }} image: "{{ .image.repository }}:{{ .image.tag | default $.Chart.AppVersion }}" @@ -85,7 +85,7 @@ spec: - name: BP_WALLET_MAPPING_TAB value: {{ .walletMappingSpreadsheetTab | quote }} - name: AWS_BUCKET_NAME - value: {{ .s3bucket | quote }} + value: {{ .s3Bucket | quote }} - name: AWS_REGION value: {{ .aws.region | quote }} - name: AWS_ACCESS_KEY_ID diff --git a/mina-payout-reports/templates/deployment-web.yaml b/mina-payout-reports/templates/deployment-web.yaml index ffbebc15..02ba63c7 100644 --- a/mina-payout-reports/templates/deployment-web.yaml +++ b/mina-payout-reports/templates/deployment-web.yaml @@ -28,7 +28,7 @@ spec: securityContext: {{- toYaml .podSecurityContext | nindent 8 }} containers: - - name: leaderboard-web + - name: payout-reports-web securityContext: {{- toYaml .securityContext | nindent 12 }} image: "{{ .image.repository }}:{{ .image.tag | default $.Chart.AppVersion }}" diff --git a/mina-payout-reports/templates/service-api.yaml b/mina-payout-reports/templates/service-api.yaml index e9d78f6b..58149d45 100644 --- a/mina-payout-reports/templates/service-api.yaml +++ b/mina-payout-reports/templates/service-api.yaml @@ -6,9 +6,9 @@ metadata: {{- include "mina-payout-reports.labels" . | nindent 4 }} {{- include "mina-payout-reports.selectorLabelsApi" . | nindent 4 }} spec: - type: {{ .Values.leaderboardApi.service.type }} + type: {{ .Values.payoutReportsApi.service.type }} ports: - - port: {{ .Values.leaderboardApi.service.port }} + - port: {{ .Values.payoutReportsApi.service.port }} targetPort: http protocol: TCP name: http diff --git a/mina-payout-reports/templates/service-web.yaml b/mina-payout-reports/templates/service-web.yaml index 3b5108f4..2aa65cea 100644 --- a/mina-payout-reports/templates/service-web.yaml +++ b/mina-payout-reports/templates/service-web.yaml @@ -6,9 +6,9 @@ metadata: {{- include "mina-payout-reports.labels" . | nindent 4 }} {{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }} spec: - type: {{ .Values.leaderboardWeb.service.type }} + type: {{ .Values.payoutReportsWeb.service.type }} ports: - - port: {{ .Values.leaderboardWeb.service.port }} + - port: {{ .Values.payoutReportsWeb.service.port }} targetPort: http protocol: TCP name: http From 2edebd7b5b3f34b412ca8d37169eada56dbda384 Mon Sep 17 00:00:00 2001 From: Simonas Narbutas Date: Fri, 26 Jul 2024 11:02:04 +0300 Subject: [PATCH 6/6] PM-1911 add backend ingress --- mina-payout-reports/README.md | 17 +++-- .../files/entrypoint_initdb.sh | 2 + .../templates/deployment-api.yaml | 2 +- .../templates/deployment-web.yaml | 5 +- .../templates/ingress-api.yaml | 62 ++++++++++++++++++ .../{ingress.yaml => ingress-web.yaml} | 22 +++---- mina-payout-reports/values.yaml | 65 +++++++++++++------ 7 files changed, 137 insertions(+), 38 deletions(-) create mode 100644 mina-payout-reports/templates/ingress-api.yaml rename mina-payout-reports/templates/{ingress.yaml => ingress-web.yaml} (64%) diff --git a/mina-payout-reports/README.md b/mina-payout-reports/README.md index dee5efa2..3f5c9086 100644 --- a/mina-payout-reports/README.md +++ b/mina-payout-reports/README.md @@ -42,11 +42,6 @@ helmfile status | 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 | @@ -59,11 +54,17 @@ helmfile status | 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.frontendPublicUrl | string | `"localhost:3000"` | Payout reports frontend public url accessible from the client | | 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.ingress.annotations | object | `{}` | The Ingress Annotations | +| payoutReportsApi.ingress.className | string | `""` | The Ingress Class Name to use | +| payoutReportsApi.ingress.enabled | bool | `false` | Whether to create a backend Ingress | +| payoutReportsApi.ingress.hosts | list | `[]` | The Ingress Hosts | +| payoutReportsApi.ingress.tls | list | `[]` | The TLS configuration | | 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 | @@ -84,11 +85,17 @@ helmfile status | 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.backendPublicUrl | string | `"localhost:5000"` | Payout reports backend public url accessible from the client | | 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.ingress.annotations | object | `{}` | The Ingress Annotations | +| payoutReportsWeb.ingress.className | string | `""` | The Ingress Class Name to use | +| payoutReportsWeb.ingress.enabled | bool | `false` | Whether to create a frontend Ingress | +| payoutReportsWeb.ingress.hosts | list | `[]` | The Ingress Hosts | +| payoutReportsWeb.ingress.tls | list | `[]` | The TLS configuration | | payoutReportsWeb.nodeSelector | object | `{}` | Node selector labels | | payoutReportsWeb.podAnnotations | object | `{}` | Annotations to add to the pods | | payoutReportsWeb.podSecurityContext | object | `{}` | The Pod Security Context | diff --git a/mina-payout-reports/files/entrypoint_initdb.sh b/mina-payout-reports/files/entrypoint_initdb.sh index c62e0f62..867ee1db 100644 --- a/mina-payout-reports/files/entrypoint_initdb.sh +++ b/mina-payout-reports/files/entrypoint_initdb.sh @@ -2,4 +2,6 @@ set -x +pushd .. invoke create-database +popd || exit diff --git a/mina-payout-reports/templates/deployment-api.yaml b/mina-payout-reports/templates/deployment-api.yaml index 00fe564a..bf2c252d 100644 --- a/mina-payout-reports/templates/deployment-api.yaml +++ b/mina-payout-reports/templates/deployment-api.yaml @@ -93,7 +93,7 @@ spec: - name: AWS_SECRET_ACCESS_KEY value: {{ .aws.secretAccessKey }} - name: SERVER_ALLOWED_ORIGINS - value: "*" + value: {{ .frontendPublicUrl }} {{- if .extraEnvVars }} {{- toYaml .extraEnvVars | nindent 12 }} {{- end }} diff --git a/mina-payout-reports/templates/deployment-web.yaml b/mina-payout-reports/templates/deployment-web.yaml index 02ba63c7..1e0b21b5 100644 --- a/mina-payout-reports/templates/deployment-web.yaml +++ b/mina-payout-reports/templates/deployment-web.yaml @@ -35,7 +35,8 @@ spec: imagePullPolicy: {{ .image.pullPolicy }} env: - name: REACT_APP_API_URL - value: "{{ include "mina-payout-reports.fullname" $ }}-api:{{ $.Values.payoutReportsApi.service.port }}" + value: {{ .backendPublicUrl | quote }} + {{- if .extraEnvVars }} {{- toYaml .extraEnvVars | nindent 12 }} {{- end }} @@ -47,10 +48,12 @@ spec: httpGet: path: /health port: http + initialDelaySeconds: 120 readinessProbe: httpGet: path: /health port: http + initialDelaySeconds: 120 resources: {{- toYaml .resources | nindent 12 }} {{- with .nodeSelector }} diff --git a/mina-payout-reports/templates/ingress-api.yaml b/mina-payout-reports/templates/ingress-api.yaml new file mode 100644 index 00000000..11d212bb --- /dev/null +++ b/mina-payout-reports/templates/ingress-api.yaml @@ -0,0 +1,62 @@ +{{- if .Values.payoutReportsApi.ingress.enabled -}} +{{- $fullName := include "mina-payout-reports.fullname" . -}} +{{- $svcPort := .Values.payoutReportsApi.service.port -}} +{{- if and .Values.payoutReportsApi.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.payoutReportsApi.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.payoutReportsApi.ingress.annotations "kubernetes.io/ingress.class" .Values.payoutReportsApi.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }}-api + labels: + {{- include "mina-payout-reports.labels" . | nindent 4 }} + {{- include "mina-payout-reports.selectorLabelsApi" . | nindent 4 }} + {{- with .Values.payoutReportsApi.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.payoutReportsApi.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.payoutReportsApi.ingress.className }} + {{- end }} + {{- if .Values.payoutReportsApi.ingress.tls }} + tls: + {{- range .Values.payoutReportsApi.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.payoutReportsApi.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }}-api + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }}-api + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/mina-payout-reports/templates/ingress.yaml b/mina-payout-reports/templates/ingress-web.yaml similarity index 64% rename from mina-payout-reports/templates/ingress.yaml rename to mina-payout-reports/templates/ingress-web.yaml index 152970c7..f0e203a2 100644 --- a/mina-payout-reports/templates/ingress.yaml +++ b/mina-payout-reports/templates/ingress-web.yaml @@ -1,9 +1,9 @@ -{{- if .Values.ingress.enabled -}} +{{- if .Values.payoutReportsWeb.ingress.enabled -}} {{- $fullName := include "mina-payout-reports.fullname" . -}} {{- $svcPort := .Values.payoutReportsWeb.service.port -}} -{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} - {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} - {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} +{{- if and .Values.payoutReportsWeb.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.payoutReportsWeb.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.payoutReportsWeb.ingress.annotations "kubernetes.io/ingress.class" .Values.payoutReportsWeb.ingress.className}} {{- end }} {{- end }} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} @@ -15,21 +15,21 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: - name: {{ $fullName }} + name: {{ $fullName }}-web labels: {{- include "mina-payout-reports.labels" . | nindent 4 }} {{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }} - {{- with .Values.ingress.annotations }} + {{- with .Values.payoutReportsWeb.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: - {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} - ingressClassName: {{ .Values.ingress.className }} + {{- if and .Values.payoutReportsWeb.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.payoutReportsWeb.ingress.className }} {{- end }} - {{- if .Values.ingress.tls }} + {{- if .Values.payoutReportsWeb.ingress.tls }} tls: - {{- range .Values.ingress.tls }} + {{- range .Values.payoutReportsWeb.ingress.tls }} - hosts: {{- range .hosts }} - {{ . | quote }} @@ -38,7 +38,7 @@ spec: {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} + {{- range .Values.payoutReportsWeb.ingress.hosts }} - host: {{ .host | quote }} http: paths: diff --git a/mina-payout-reports/values.yaml b/mina-payout-reports/values.yaml index b9c8e2d0..4fd8bf8d 100644 --- a/mina-payout-reports/values.yaml +++ b/mina-payout-reports/values.yaml @@ -18,6 +18,8 @@ serviceAccount: # Configuration options for `mina-payout-reports` frontend deployment payoutReportsWeb: + # -- Payout reports backend public url accessible from the client + backendPublicUrl: localhost:5000 # -- The number of replicas replicaCount: 1 @@ -87,6 +89,27 @@ payoutReportsWeb: # -- Affinity rules affinity: {} + ingress: + # -- Whether to create a frontend Ingress + enabled: false + # -- The Ingress Class Name to use + className: "" + # -- The Ingress Annotations + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # -- The Ingress Hosts + hosts: [] + # - host: chart-example.local + # paths: + # - path: / + # pathType: ImplementationSpecific + # -- The TLS configuration + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + # Configuration options for `mina-payout-reports` backend deployment payoutReportsApi: payoutsDB: @@ -132,6 +155,8 @@ payoutReportsApi: accessKeyID: "" # -- AWS access key secret(leave empty to assume role) secretAccessKey: "" + # -- Payout reports frontend public url accessible from the client + frontendPublicUrl: localhost:3000 # -- The number of replicas replicaCount: 1 @@ -202,23 +227,23 @@ payoutReportsApi: # -- Affinity rules affinity: {} -ingress: - # -- Whether to create a frontend Ingress - enabled: false - # -- The Ingress Class Name to use - className: "" - # -- The Ingress Annotations - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - # -- The Ingress Hosts - hosts: [] - # - host: chart-example.local - # paths: - # - path: / - # pathType: ImplementationSpecific - # -- The TLS configuration - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local + ingress: + # -- Whether to create a backend Ingress + enabled: false + # -- The Ingress Class Name to use + className: "" + # -- The Ingress Annotations + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # -- The Ingress Hosts + hosts: [] + # - host: chart-example.local + # paths: + # - path: / + # pathType: ImplementationSpecific + # -- The TLS configuration + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local