Skip to content

Commit

Permalink
Add new Cronjob - pools-extractor (#54)
Browse files Browse the repository at this point in the history
* Add new Cronjob - pools-extractor
  • Loading branch information
alik-agaev authored Jan 6, 2025
1 parent 46e22a8 commit c15eb8b
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/blockscout-admin/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.2.0
version: 1.3.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
20 changes: 20 additions & 0 deletions charts/blockscout-admin/templates/pools-extractor-configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.poolsExtractor.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: pools-{{ include "blockscout-admin.fullname" . }}-config
labels:
{{- include "blockscout-admin.labels" . | nindent 4 }}
data:
networks.json: |
{
"networks": {
{{- $len := len .Values.config.network }}
{{- range $i, $value := .Values.config.network }}
"{{ .id }}": {
"coingecko_terminal_network_id": "{{ .coingecko_terminal_network_id }}"
}{{- if ne (sub $len 1) $i }},{{- end }}
{{- end }}
}
}
{{- end }}
59 changes: 59 additions & 0 deletions charts/blockscout-admin/templates/pools-extractor-cronjob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if .Values.poolsExtractor.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: pools-extractor-{{ include "blockscout-admin.fullname" . }}
spec:
schedule: {{ .Values.poolsExtractor.schedule | quote }}
concurrencyPolicy: "Forbid"
jobTemplate:
spec:
backoffLimit: 6
completions: 1
parallelism: 1
template:
spec:
restartPolicy: Never
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}
containers:
- name: {{ .Release.Name }}-pools-extractor
image: "{{ .Values.poolsExtractor.image.repository }}:{{ .Values.poolsExtractor.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: Always
env:
- name: POOLS_EXTRACTOR__CONTRACTS_INFO__URL
value: http://contracts-info-{{ include "blockscout-admin.fullname" . }}:{{ .Values.contractsInfo.service.port }}
{{- range .Values.poolsExtractor.environment }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
envFrom:
- secretRef:
name: pools-extractor-{{ include "blockscout-admin.fullname" . }}-env
resources:
{{- toYaml .Values.poolsExtractor.resources | nindent 16 }}
volumeMounts:
- name: config
mountPath: /app/config/networks.json
subPath: networks.json
volumes:
- configMap:
name: pools-{{ include "blockscout-admin.fullname" . }}-config
defaultMode: 0777
name: config
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
---
{{- end}}
14 changes: 14 additions & 0 deletions charts/blockscout-admin/templates/pools-extractor-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.poolsExtractor.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: pools-extractor-{{ include "blockscout-admin.fullname" . }}-env
labels:
{{- include "blockscout-admin.labels" . | nindent 4 }}
type: Opaque
data:
{{- range .Values.poolsExtractor.envFromSecret }}
{{ .name }}: {{ .value | b64enc }}
{{- end }}
{{- end }}
---
21 changes: 21 additions & 0 deletions charts/blockscout-admin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,27 @@ tokenInfoExtractor:
memory: "96Mi"
cpu: "100m"

poolsExtractor:
enabled: false
image:
repository: ghcr.io/blockscout/pools-extractor
# Overrides the image tag whose default is the chart appVersion.
tag: ""
schedule: "0 0 * * *"
environment: {}
#- name: SOME_ENV
# value: value
envFromSecret: {}
#- name: SOME_SECRET_ENV
# value: secret_value
resources:
limits:
memory: "256Mi"
cpu: "250m"
requests:
memory: "96Mi"
cpu: "100m"

livenessProbe:
params:
initialDelaySeconds: 100
Expand Down

0 comments on commit c15eb8b

Please sign in to comment.