Skip to content

Commit

Permalink
[blockscout-stack] Adding separate indexer and api deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
nzenchik committed Jun 4, 2024
1 parent 8cfc702 commit 62d7533
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 6 deletions.
6 changes: 6 additions & 0 deletions charts/blockscout-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ChangeLog

## 1.6.0

### Features

- Adding possibility to run separate api and indexer deployment. More information on this can be found [here](https://docs.blockscout.com/for-developers/information-and-settings/separate-indexer-web-app-and-api). The minimum required backend version is 6.6.0

## 1.5.1

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion charts/blockscout-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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: 1.5.1
version: 1.6.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
Expand Down
138 changes: 137 additions & 1 deletion charts/blockscout-stack/templates/blockscout-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ metadata:
app: {{ .Release.Name }}-blockscout
{{- include "blockscout-stack.labels" . | nindent 4 }}
spec:
{{- if .Values.blockscout.separateApi.enabled }}
replicas: {{ .Values.blockscout.separateApi.replicaCount }}
{{- else }}
replicas: {{ .Values.blockscout.replicaCount }}
{{- end }}
selector:
matchLabels:
app: {{ .Release.Name }}-blockscout
Expand All @@ -29,7 +33,7 @@ spec:
serviceAccountName: {{ include "blockscout-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.blockscout.podSecurityContext | nindent 8 }}
{{- if .Values.blockscout.init.enabled }}
{{- if and .Values.blockscout.init.enabled (not .Values.blockscout.separateApi.enabled) }}
initContainers:
- name: init-migrations
image: "{{ .Values.blockscout.image.repository }}:{{ .Values.blockscout.image.tag }}"
Expand Down Expand Up @@ -90,9 +94,17 @@ spec:
- name: {{ .Chart.Name }}-blockscout
securityContext:
{{- toYaml .Values.blockscout.securityContext | nindent 12 }}
{{- if .Values.blockscout.separateApi.enabled }}
image: "{{ .Values.blockscout.image.repository }}:{{ .Values.blockscout.image.tag }}-api"
{{- else }}
image: "{{ .Values.blockscout.image.repository }}:{{ .Values.blockscout.image.tag }}"
{{- end }}
resources:
{{- if .Values.blockscout.separateApi.enabled }}
{{- toYaml .Values.blockscout.separateApi.resources | nindent 12 }}
{{- else}}
{{- toYaml .Values.blockscout.resources | nindent 12 }}
{{- end }}
imagePullPolicy: {{ .Values.blockscout.image.pullPolicy }}
{{- with .Values.blockscout.command }}
command: {{ . | toYaml | nindent 12 }}
Expand Down Expand Up @@ -131,6 +143,129 @@ spec:
- name: BLOCKSCOUT_HOST
value: {{ .Values.blockscout.ingress.hostname | quote }}
{{- end }}
{{- if .Values.blockscout.separateApi.enabled }}
- name: DISABLE_INDEXER
value: "true"
- name: DISABLE_WEBAPP
value: "true"
{{- end }}
{{- range $key, $value := .Values.blockscout.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range .Values.blockscout.extraEnv }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- if or .Values.blockscout.envFromSecret .Values.blockscout.envFrom }}
envFrom:
{{- if .Values.blockscout.envFromSecret }}
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-env
{{- end }}
{{- range .Values.blockscout.envFrom }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- end }}
{{- if .Values.blockscout.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.blockscout.readinessProbe.path }}
port: http
scheme: HTTP
{{- with .Values.blockscout.readinessProbe.params }}
{{- . | toYaml | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.blockscout.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.blockscout.livenessProbe.path }}
port: http
scheme: HTTP
{{- with .Values.blockscout.livenessProbe.params }}
{{- . | toYaml | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.blockscout.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ . | toYaml | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
---
{{- if .Values.blockscout.separateApi.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-indexer
labels:
app: {{ .Release.Name }}-blockscout-indexer
{{- include "blockscout-stack.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.blockscout.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-blockscout-indexer
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/blockscout-secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: {{ .Release.Name }}-blockscout-indexer
{{- include "blockscout-stack.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "blockscout-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.blockscout.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-blockscout
securityContext:
{{- toYaml .Values.blockscout.securityContext | nindent 12 }}
image: "{{ .Values.blockscout.image.repository }}:{{ .Values.blockscout.image.tag }}-indexer"
resources:
{{- toYaml .Values.blockscout.resources | nindent 12 }}
imagePullPolicy: {{ .Values.blockscout.image.pullPolicy }}
{{- with .Values.blockscout.command }}
command: {{ . | toYaml | nindent 12 }}
{{- end }}
{{- with .Values.blockscout.args }}
args: {{ . | toYaml | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 4000
protocol: TCP
env:
- name: PORT
value: "4000"
- name: CHAIN_ID
value: {{ .Values.config.network.id | quote }}
- name: DISABLE_WEBAPP
value: "true"
- name: API_V1_READ_METHODS_DISABLED
value: "true"
- name: API_V1_WRITE_METHODS_DISABLED
value: "true"
{{- if and .Values.config.network.currency.symbol (not .Values.config.network.currency.dualToken) }}
- name: COIN
value: {{ .Values.config.network.currency.symbol | quote }}
{{- end }}
{{- range $key, $value := .Values.blockscout.env }}
- name: {{ $key }}
value: {{ $value | quote }}
Expand Down Expand Up @@ -183,4 +318,5 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
92 changes: 92 additions & 0 deletions charts/blockscout-stack/templates/blockscout-migration-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{{- if .Values.blockscout.separateApi.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-migrations
annotations:
helm.sh/hook: pre-install,pre-upgrade
helm.sh/hook-weight: "-5"
helm.sh/hook-delete-policy: hook-succeeded
labels:
{{- include "blockscout-stack.labels" . | nindent 4 }}
spec:
template:
spec:
containers:
- name: blockscout-migrations
image: "{{ .Values.blockscout.image.repository }}:{{ .Values.blockscout.image.tag }}"
imagePullPolicy: {{ .Values.blockscout.image.pullPolicy }}
{{- with .Values.blockscout.init.command }}
command: {{ . | toYaml | nindent 12 }}
{{- end }}
{{- with .Values.blockscout.init.args }}
args: {{ . | toYaml | nindent 12 }}
{{- end }}
env:
- name: PORT
value: "4000"
- name: CHAIN_ID
value: {{ .Values.config.network.id | quote }}
{{- if and .Values.config.network.currency.symbol (not .Values.config.network.currency.dualToken) }}
- name: COIN
value: {{ .Values.config.network.currency.symbol | quote }}
- name: COIN_NAME
value: {{ .Values.config.network.currency.symbol | quote }}
{{- end }}
{{- if .Values.config.account.enabled }}
- name: ACCOUNT_ENABLED
value: "true"
{{- end }}
{{- if .Values.config.testnet }}
- name: SHOW_TESTNET_LABEL
value: "true"
{{- end }}
{{- if .Values.frontend.enabled }}
- name: API_V2_ENABLED
value: "true"
{{- end }}
{{- if .Values.blockscout.ingress.enabled }}
- name: BLOCKSCOUT_HOST
value: {{ .Values.blockscout.ingress.hostname | quote }}
{{- end }}
{{- if .Values.blockscout.separateApi.enabled }}
- name: DISABLE_INDEXER
value: "true"
- name: DISABLE_WEBAPP
value: "true"
{{- end }}
{{- range $key, $value := .Values.blockscout.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range .Values.blockscout.extraEnv }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- if or .Values.blockscout.envFromSecret .Values.blockscout.envFrom }}
envFrom:
{{- if .Values.blockscout.envFromSecret }}
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-env
{{- end }}
{{- range .Values.blockscout.envFrom }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- end }}
restartPolicy: OnFailure
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.blockscout.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ . | toYaml | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
backoffLimit: 4
{{- end }}
21 changes: 17 additions & 4 deletions charts/blockscout-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ config:
account:
enabled: false
testnet: false

## If set to true will create service monitors for blockscout and stats
##
prometheus:
Expand All @@ -37,7 +38,7 @@ config:
##
blockscout:
enabled: true
## Currently only one replica is supported
## Replica count for indexer (if separate api is not used this replica count for deployment containing both indexer and api). Currently only one replica is supported
##
replicaCount: 1
## Image parametes
Expand All @@ -55,6 +56,18 @@ blockscout:
args:
- -c
- bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"
## Run API service as separate deployment
##
separateApi:
enabled: false
replicaCount: 2
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 500m
memory: 1Gi
## Blockscout ENV vars
## ref: https://docs.blockscout.com/for-developers/information-and-settings/env-variables
##
Expand Down Expand Up @@ -143,11 +156,11 @@ blockscout:

resources:
limits:
cpu: 2
memory: 4Gi
requests:
cpu: 1
memory: 2Gi
requests:
cpu: 500m
memory: 1Gi
## Configuration options for frontend
##
frontend:
Expand Down

0 comments on commit 62d7533

Please sign in to comment.