From 6078890792c6af7b101c17d5c29c8bc9c9d636c7 Mon Sep 17 00:00:00 2001 From: Fedor Nikolaev Date: Thu, 24 Oct 2024 15:59:17 +0400 Subject: [PATCH] feat: cosmos-exporter chart COSMOS-2655 --- charts/cosmos-exporter/.helmignore | 23 ++++++ charts/cosmos-exporter/.releaserc.js | 17 ++++ charts/cosmos-exporter/Chart.yaml | 6 ++ charts/cosmos-exporter/examples/values.yaml | 8 ++ charts/cosmos-exporter/templates/_helpers.tpl | 71 +++++++++++++++++ .../cosmos-exporter/templates/deployment.yaml | 56 ++++++++++++++ charts/cosmos-exporter/templates/sa.yaml | 15 ++++ charts/cosmos-exporter/templates/secret.yaml | 11 +++ charts/cosmos-exporter/templates/svc.yaml | 15 ++++ charts/cosmos-exporter/values.yaml | 77 +++++++++++++++++++ 10 files changed, 299 insertions(+) create mode 100644 charts/cosmos-exporter/.helmignore create mode 100644 charts/cosmos-exporter/.releaserc.js create mode 100644 charts/cosmos-exporter/Chart.yaml create mode 100644 charts/cosmos-exporter/examples/values.yaml create mode 100644 charts/cosmos-exporter/templates/_helpers.tpl create mode 100644 charts/cosmos-exporter/templates/deployment.yaml create mode 100644 charts/cosmos-exporter/templates/sa.yaml create mode 100644 charts/cosmos-exporter/templates/secret.yaml create mode 100644 charts/cosmos-exporter/templates/svc.yaml create mode 100644 charts/cosmos-exporter/values.yaml diff --git a/charts/cosmos-exporter/.helmignore b/charts/cosmos-exporter/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/cosmos-exporter/.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/cosmos-exporter/.releaserc.js b/charts/cosmos-exporter/.releaserc.js new file mode 100644 index 0000000..784e969 --- /dev/null +++ b/charts/cosmos-exporter/.releaserc.js @@ -0,0 +1,17 @@ +const chartName = 'cosmos-exporter'; +const chartPath = __dirname; + +module.exports = { + extends: '../.github/chart-release.config.js', + tagFormat: 'cosmos-exporter-v${version}', + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + '@semantic-release/changelog', + '@semantic-release/git', + '@semantic-release/github', + ['@semantic-release/exec', { + prepareCmd: 'sed -i "s/^version:.*$/version: ${nextRelease.version}/" Chart.yaml && helm package . --version ${nextRelease.version} --app-version ${nextRelease.version} && mv *.tgz ../' + }] + ] +}; diff --git a/charts/cosmos-exporter/Chart.yaml b/charts/cosmos-exporter/Chart.yaml new file mode 100644 index 0000000..b7a9115 --- /dev/null +++ b/charts/cosmos-exporter/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: cosmos-exporter +description: A Helm chart for validator signatures verification in a specific cosmos network +type: application +version: 1.0.0 +appVersion: "0.2.4" diff --git a/charts/cosmos-exporter/examples/values.yaml b/charts/cosmos-exporter/examples/values.yaml new file mode 100644 index 0000000..45b97d0 --- /dev/null +++ b/charts/cosmos-exporter/examples/values.yaml @@ -0,0 +1,8 @@ +--- +appEnv: + - name: VALIDATOR_ADDRESS + value: CA4B5F01CE47C34EE16C3A831C6143BAAFED0140 + - name: REST_ENDPOINTS + value: https://dydx-dao-api.polkachu.com,https://dydx-mainnet-full-lcd.public.blastapi.io,https://dydx-rest.kingnodes.com,https://rest.lavenderfive.com/dydx,https://dydx-mainnet-lcd.autostake.com,https://rest-dydx.ecostake.com,https://dydx-rest.publicnode.com,https://dydx-lcd.enigma-validator.com,https://dydx-api.noders.services,https://dydx-rest.interstellar-lounge.org + - name: RPC_ENDPOINTS + value: https://dydx-rpc.kingnodes.com,https://dydx-dao-rpc.polkachu.com,https://dydx-mainnet-full-rpc.public.blastapi.io,https://rpc.lavenderfive.com/dydx,https://dydx-mainnet-rpc.autostake.com,https://rpc-dydx.ecostake.com,https://dydx-rpc.publicnode.com,https://dydx-rpc.enigma-validator.com,https://dydx-rpc.noders.services,https://dydx.interstellar-lounge.org,https://rpc.dydx-mainnet.tm.p2p.org diff --git a/charts/cosmos-exporter/templates/_helpers.tpl b/charts/cosmos-exporter/templates/_helpers.tpl new file mode 100644 index 0000000..728571b --- /dev/null +++ b/charts/cosmos-exporter/templates/_helpers.tpl @@ -0,0 +1,71 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "cosmos-exporter.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 "cosmos-exporter.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 "cosmos-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "cosmos-exporter.labels" -}} +helm.sh/chart: {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }} +app.kubernetes.io/name: {{ $.Values.appName }} +app.kubernetes.io/instance: {{ $.Release.Name }} +app.kubernetes.io/version: {{ $.Chart.AppVersion }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "cosmos-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ $.Values.appName }} +app.kubernetes.io/instance: {{ $.Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "cosmos-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "cosmos-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Docker configuration file for use as the Secret's payload +*/}} +{{- define "imagePullSecret" }} +{{- with .Values.imageCredentials }} +{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }} +{{- end }} +{{- end }} + diff --git a/charts/cosmos-exporter/templates/deployment.yaml b/charts/cosmos-exporter/templates/deployment.yaml new file mode 100644 index 0000000..c3a4eb7 --- /dev/null +++ b/charts/cosmos-exporter/templates/deployment.yaml @@ -0,0 +1,56 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $.Values.appName }} + labels: + {{- include "cosmos-exporter.labels" $ | nindent 4 }} + k8s-app: {{ $.Values.appName }} +spec: + replicas: {{ .Values.replicas }} + revisionHistoryLimit: 10 + serviceName: "{{ $.Values.appName }}" + updateStrategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 20% + selector: + matchLabels: + {{- include "cosmos-exporter.selectorLabels" $ | nindent 6 }} + k8s-app: {{ $.Values.appName }} + template: + metadata: + labels: + {{- include "cosmos-exporter.labels" . | nindent 8 }} + k8s-app: {{ $.Values.appName }} + annotations: + rollme: {{ randAlphaNum 5 | quote }} + reloader.stakater.com/auto: "true" + spec: + containers: + - name: {{ $.Values.appName }} + image: "{{ $.Values.appImage.repo }}:{{ $.Values.appImage.tag }}" + imagePullPolicy: {{ $.Values.appImage.pullPolicy }} + env: + {{- range $.Values.appEnv }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end }} + ports: + {{- range $.Values.services.ports }} + - containerPort: {{ .port }} + protocol: {{ .protocol }} + {{- end }} + {{- if $.Values.appProbes }} + {{- toYaml $.Values.appProbes | nindent 10 }} + {{- end }} + {{- with $.Values.appResources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + imagePullSecrets: + {{- toYaml $.Values.imagePullSecrets | nindent 8 }} + serviceAccountName: {{ include "cosmos-exporter.serviceAccountName" . }} + affinity: + {{- toYaml $.Values.affinity | nindent 8 }} + tolerations: + {{- toYaml $.Values.tolerations | nindent 8 }} diff --git a/charts/cosmos-exporter/templates/sa.yaml b/charts/cosmos-exporter/templates/sa.yaml new file mode 100644 index 0000000..b343b59 --- /dev/null +++ b/charts/cosmos-exporter/templates/sa.yaml @@ -0,0 +1,15 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "cosmos-exporter.serviceAccountName" . }} + labels: + {{- include "cosmos-exporter.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "-10" + "helm.sh/hook-delete-policy": before-hook-creation + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/cosmos-exporter/templates/secret.yaml b/charts/cosmos-exporter/templates/secret.yaml new file mode 100644 index 0000000..f5d1b39 --- /dev/null +++ b/charts/cosmos-exporter/templates/secret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: registry + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "-10" + "helm.sh/hook-delete-policy": before-hook-creation +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: {{ template "imagePullSecret" . }} diff --git a/charts/cosmos-exporter/templates/svc.yaml b/charts/cosmos-exporter/templates/svc.yaml new file mode 100644 index 0000000..bec798b --- /dev/null +++ b/charts/cosmos-exporter/templates/svc.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: "{{ $.Values.appName }}" + labels: + {{- include "cosmos-exporter.labels" $ | nindent 4 }} + k8s-app: {{ $.Values.appName }} +spec: + type: {{ $.Values.services.type | default "ClusterIP" }} + ports: + {{- toYaml $.Values.services.ports | nindent 2 }} + selector: + {{- include "cosmos-exporter.selectorLabels" $ | nindent 4 }} + k8s-app: {{ $.Values.appName }} diff --git a/charts/cosmos-exporter/values.yaml b/charts/cosmos-exporter/values.yaml new file mode 100644 index 0000000..5cfaa7d --- /dev/null +++ b/charts/cosmos-exporter/values.yaml @@ -0,0 +1,77 @@ +appName: cosmos-exporter +networkType: mainnet +replicas: 1 + +appImage: + repo: ghcr.io/p2p-org/rcosmos-exporter + pullPolicy: Always + tag: &appTag v0.2.4 + +appEnv: + - name: LOGGING_LEVEL + value: DEBUG + - name: PROMETHEUS_IP + value: 0.0.0.0 + - name: PROMETHEUS_PORT + value: &cosmosExporterPort 9100 + - name: BLOCK_WINDOW + value: 500 + - name: VALIDATOR_ADDRESS + value: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + - name: REST_ENDPOINTS + value: http://127.0.0.1:1317 + - name: RPC_ENDPOINTS + value: http://127.0.0.1:26657 + +services: + type: ClusterIP + ports: + - name: prometheus + port: *cosmosExporterPort + targetPort: *cosmosExporterPort + protocol: TCP + +appProbes: + livenessProbe: + tcpSocket: + port: *cosmosExporterPort + initialDelaySeconds: 60 + periodSeconds: 20 + timeoutSeconds: 5 + failureThreshold: 3 + readinessProbe: + tcpSocket: + port: *cosmosExporterPort + periodSeconds: 5 + timeoutSeconds: 1 + failureThreshold: 3 + +imagePullSecrets: +- name: registry + +serviceAccount: + create: true + annotations: {} + name: "" + +affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: blch + operator: In + values: + - "true" + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + +imageCredentials: + registry: ghcr.io + username: cosmos + password: secret + email: cosmos-security@p2p.org