Skip to content

Commit

Permalink
PM-1911 add backend ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
simisimis committed Jul 26, 2024
1 parent baf059f commit 1a6a7b8
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 36 deletions.
16 changes: 11 additions & 5 deletions mina-payout-reports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -64,6 +59,11 @@ helmfile status
| 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 |
Expand All @@ -84,11 +84,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.backendExternalUrl | string | `"localhost:5000"` | Payout reports backend 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 |
Expand Down
2 changes: 2 additions & 0 deletions mina-payout-reports/files/entrypoint_initdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

set -x

pushd ..
invoke create-database
popd || exit
3 changes: 2 additions & 1 deletion mina-payout-reports/templates/deployment-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {{ .backendExternalUrl | quote }}

{{- if .extraEnvVars }}
{{- toYaml .extraEnvVars | nindent 12 }}
{{- end }}
Expand Down
62 changes: 62 additions & 0 deletions mina-payout-reports/templates/ingress-api.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
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 }}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{- if .Values.ingress.enabled -}}
{{- if .Values.payoutReportsApi.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.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 -}}
Expand All @@ -19,17 +19,17 @@ metadata:
labels:
{{- include "mina-payout-reports.labels" . | nindent 4 }}
{{- include "mina-payout-reports.selectorLabelsWeb" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
{{- with .Values.payoutReportsApi.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.payoutReportsApi.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.payoutReportsApi.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
{{- if .Values.payoutReportsApi.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
{{- range .Values.payoutReportsApi.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
Expand All @@ -38,7 +38,7 @@ spec:
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
{{- range .Values.payoutReportsApi.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
Expand Down
63 changes: 43 additions & 20 deletions mina-payout-reports/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ serviceAccount:

# Configuration options for `mina-payout-reports` frontend deployment
payoutReportsWeb:
# -- Payout reports backend url accessible from the client
backendExternalUrl: localhost:5000
# -- The number of replicas
replicaCount: 1

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -202,23 +225,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

0 comments on commit 1a6a7b8

Please sign in to comment.