From 0322e1c9fa063c4bfbb5d813f9e2922afe7a68f6 Mon Sep 17 00:00:00 2001 From: Nick Zenchik Date: Fri, 24 Jan 2025 12:21:32 +0400 Subject: [PATCH] Adding zilliqa-validators-indexer helm chart --- charts/zilliqa-validators-indexer/.helmignore | 23 +++++ charts/zilliqa-validators-indexer/Chart.yaml | 24 +++++ .../templates/_helpers.tpl | 62 ++++++++++++ .../templates/deployment.yaml | 87 +++++++++++++++++ .../templates/secret.yaml | 10 ++ .../templates/serviceaccount.yaml | 13 +++ charts/zilliqa-validators-indexer/values.yaml | 95 +++++++++++++++++++ 7 files changed, 314 insertions(+) create mode 100644 charts/zilliqa-validators-indexer/.helmignore create mode 100644 charts/zilliqa-validators-indexer/Chart.yaml create mode 100644 charts/zilliqa-validators-indexer/templates/_helpers.tpl create mode 100644 charts/zilliqa-validators-indexer/templates/deployment.yaml create mode 100644 charts/zilliqa-validators-indexer/templates/secret.yaml create mode 100644 charts/zilliqa-validators-indexer/templates/serviceaccount.yaml create mode 100644 charts/zilliqa-validators-indexer/values.yaml diff --git a/charts/zilliqa-validators-indexer/.helmignore b/charts/zilliqa-validators-indexer/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/zilliqa-validators-indexer/.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/charts/zilliqa-validators-indexer/Chart.yaml b/charts/zilliqa-validators-indexer/Chart.yaml new file mode 100644 index 0000000..11882fe --- /dev/null +++ b/charts/zilliqa-validators-indexer/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: zilliqa-validators-indexer +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/charts/zilliqa-validators-indexer/templates/_helpers.tpl b/charts/zilliqa-validators-indexer/templates/_helpers.tpl new file mode 100644 index 0000000..a4e721d --- /dev/null +++ b/charts/zilliqa-validators-indexer/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "zilliqa-validators-indexer.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 "zilliqa-validators-indexer.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 "zilliqa-validators-indexer.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "zilliqa-validators-indexer.labels" -}} +helm.sh/chart: {{ include "zilliqa-validators-indexer.chart" . }} +{{ include "zilliqa-validators-indexer.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "zilliqa-validators-indexer.selectorLabels" -}} +app.kubernetes.io/name: {{ include "zilliqa-validators-indexer.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "zilliqa-validators-indexer.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "zilliqa-validators-indexer.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/zilliqa-validators-indexer/templates/deployment.yaml b/charts/zilliqa-validators-indexer/templates/deployment.yaml new file mode 100644 index 0000000..3a1d84c --- /dev/null +++ b/charts/zilliqa-validators-indexer/templates/deployment.yaml @@ -0,0 +1,87 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "zilliqa-validators-indexer.fullname" . }} + labels: + {{- include "zilliqa-validators-indexer.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "zilliqa-validators-indexer.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "zilliqa-validators-indexer.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "zilliqa-validators-indexer.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: ETH_RPC_BLOCKS_BATCH_SIZE + value: {{ .Values.config.ethRpcBlocksBatchSize | quote }} + - name: CONTRACT_ADDRESS + value: {{ .Values.config.contractAddress | quote }} + - name: FROM_BLOCK_NUMBER + value: {{ .Values.config.fromBlockNumber | quote }} + envFrom: + - secretRef: + name: {{ include "zilliqa-validators-indexer.fullname" . }}-env + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/zilliqa-validators-indexer/templates/secret.yaml b/charts/zilliqa-validators-indexer/templates/secret.yaml new file mode 100644 index 0000000..4eba5f2 --- /dev/null +++ b/charts/zilliqa-validators-indexer/templates/secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "zilliqa-validators-indexer.fullname" . }}-env + labels: + {{- include "zilliqa-validators-indexer.labels" . | nindent 4 }} +type: Opaque +data: + ETH_RPC_URL: {{ .Values.config.ethRpcUrl | b64enc }} + DB_URL: {{ .Values.config.dbUrl | b64enc }} diff --git a/charts/zilliqa-validators-indexer/templates/serviceaccount.yaml b/charts/zilliqa-validators-indexer/templates/serviceaccount.yaml new file mode 100644 index 0000000..708218c --- /dev/null +++ b/charts/zilliqa-validators-indexer/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "zilliqa-validators-indexer.serviceAccountName" . }} + labels: + {{- include "zilliqa-validators-indexer.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/zilliqa-validators-indexer/values.yaml b/charts/zilliqa-validators-indexer/values.yaml new file mode 100644 index 0000000..eafa791 --- /dev/null +++ b/charts/zilliqa-validators-indexer/values.yaml @@ -0,0 +1,95 @@ +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: ghcr.io/blockscout/zilliqa-stakers-squid + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + +config: + ethRpcUrl: https://api.zq2-prototestnet.zilliqa.com + ethRpcBlocksBatchSize: '10000' + contractAddress: 0x00000000005A494C4445504F53495450524F5859 + fromBlockNumber: '7522968' + dbUrl: postgresql://postgres:postgres@localhost:5432/zilliqa + +service: + type: ClusterIP + port: 80 + +# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: 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: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +resources: + limits: + cpu: 500m + memory: 1Gi + requests: + cpu: 200m + memory: 256Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: {} + #httpGet: + # path: / + # port: http +readinessProbe: {} + #httpGet: + # path: / + # port: http + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {}