Skip to content

Commit

Permalink
feat: cosmos-exporter chart
Browse files Browse the repository at this point in the history
COSMOS-2655
  • Loading branch information
felichita committed Oct 24, 2024
1 parent 0f34eb0 commit 6078890
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/cosmos-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
17 changes: 17 additions & 0 deletions charts/cosmos-exporter/.releaserc.js
Original file line number Diff line number Diff line change
@@ -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 ../'
}]
]
};
6 changes: 6 additions & 0 deletions charts/cosmos-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions charts/cosmos-exporter/examples/values.yaml
Original file line number Diff line number Diff line change
@@ -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
71 changes: 71 additions & 0 deletions charts/cosmos-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
56 changes: 56 additions & 0 deletions charts/cosmos-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 15 additions & 0 deletions charts/cosmos-exporter/templates/sa.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
11 changes: 11 additions & 0 deletions charts/cosmos-exporter/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -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" . }}
15 changes: 15 additions & 0 deletions charts/cosmos-exporter/templates/svc.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
77 changes: 77 additions & 0 deletions charts/cosmos-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -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: [email protected]

0 comments on commit 6078890

Please sign in to comment.