diff --git a/charts/validator-exporter/.helmignore b/charts/validator-exporter/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/validator-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/validator-exporter/Chart.yaml b/charts/validator-exporter/Chart.yaml new file mode 100644 index 0000000..d3ddfcc --- /dev/null +++ b/charts/validator-exporter/Chart.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v2 +name: validator-exporter +description: A Helm chart for validator-exporter +type: application +version: 1.0.0 +appVersion: 1.0.0 diff --git a/charts/validator-exporter/README.md b/charts/validator-exporter/README.md new file mode 100644 index 0000000..5d147c6 --- /dev/null +++ b/charts/validator-exporter/README.md @@ -0,0 +1,53 @@ +# Validator Exporter + +Prometheus exporter for cosmos validators metrics - [validator-exporter](https://github.com/archway-network/validator-exporter) + +## Prerequisites + +Kubernetes 1.16+ + +## Get Repository Info + +```console +helm repo add archway-network https://archway-network.github.io/helm-charts +helm repo update +``` + +_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._ + +## Install Chart + +```console +helm install [RELEASE_NAME] archway-network/validator-exporter +``` + +_See [configuration](#configuration) below._ + +_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ + +## Uninstall Chart + +```console +helm uninstall [RELEASE_NAME] +``` + +This removes all the Kubernetes components associated with the chart and deletes the release. + +_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ + +## Upgrading Chart + +```console +helm upgrade [RELEASE_NAME] [CHART] --install +``` + +_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ + +## Configuration + +See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). +To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands: + +```console +helm show values archway-network/validator-exporter +``` diff --git a/charts/validator-exporter/templates/_helpers.tpl b/charts/validator-exporter/templates/_helpers.tpl new file mode 100644 index 0000000..f981bf8 --- /dev/null +++ b/charts/validator-exporter/templates/_helpers.tpl @@ -0,0 +1,92 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "validator-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 "validator-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 "validator-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "validator-exporter.labels" -}} +helm.sh/chart: {{ include "validator-exporter.chart" . }} +{{ include "validator-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "validator-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "validator-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "validator-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "validator-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Given a dictionary of variable=value pairs, render a container env block. +Environment variables are sorted alphabetically +*/}} +{{- define "validator-exporter.renderEnv" -}} + +{{- $dict := . -}} + +{{- range keys . | sortAlpha }} +{{- $val := pluck . $dict | first -}} +{{- $valueType := printf "%T" $val -}} +{{ if eq $valueType "map[string]interface {}" }} +- name: {{ . }} +{{ toYaml $val | indent 2 -}} +{{- else if eq $valueType "string" }} +{{- if regexMatch "valueFrom" $val }} +- name: {{ . }} +{{ $val | indent 2 }} +{{- else }} +- name: {{ . }} + value: {{ $val | quote }} +{{- end }} +{{- else }} +- name: {{ . }} + value: {{ $val | quote }} +{{- end }} +{{- end -}} + +{{- end -}} diff --git a/charts/validator-exporter/templates/deployment.yaml b/charts/validator-exporter/templates/deployment.yaml new file mode 100644 index 0000000..42903d1 --- /dev/null +++ b/charts/validator-exporter/templates/deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "validator-exporter.fullname" . }} + labels: + {{- include "validator-exporter.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "validator-exporter.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "validator-exporter.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.containerSecurityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - -p={{ .Values.service.port }} + - --log-level={{ .Values.logLevel }} + env: + {{- include "validator-exporter.renderEnv" .Values.env | nindent 12 }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/validator-exporter/templates/service.yaml b/charts/validator-exporter/templates/service.yaml new file mode 100644 index 0000000..1edc185 --- /dev/null +++ b/charts/validator-exporter/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "validator-exporter.fullname" . }} + labels: + {{- include "validator-exporter.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "validator-exporter.selectorLabels" . | nindent 4 }} diff --git a/charts/validator-exporter/templates/serviceMonitor.yaml b/charts/validator-exporter/templates/serviceMonitor.yaml new file mode 100644 index 0000000..2c419f7 --- /dev/null +++ b/charts/validator-exporter/templates/serviceMonitor.yaml @@ -0,0 +1,40 @@ +{{- if.Values.serviceMonitor.enabled -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "validator-exporter.fullname" . }} + labels: + {{- include "validator-exporter.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + jobLabel: {{ .Release.Name }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "validator-exporter.selectorLabels" . | nindent 6 }} + endpoints: + - port: http + path: {{ .Values.serviceMonitor.telemetryPath }} + {{- with .Values.serviceMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + {{- if .Values.serviceMonitor.metricRelabelings }} + metricRelabelings: {{ toYaml .Values.serviceMonitor.metricRelabelings | nindent 6 }} + {{- end }} + {{- if .Values.serviceMonitor.relabelings }} + relabelings: {{ toYaml .Values.serviceMonitor.relabelings | nindent 6 }} + {{- end }} + {{- if .Values.serviceMonitor.targetLabels }} + targetLabels: + {{- range .Values.serviceMonitor.targetLabels }} + - {{ . }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/validator-exporter/values.yaml b/charts/validator-exporter/values.yaml new file mode 100644 index 0000000..aeea22b --- /dev/null +++ b/charts/validator-exporter/values.yaml @@ -0,0 +1,50 @@ +image: + repository: ghcr.io/archway-network/validator-exporter + pullPolicy: IfNotPresent + tag: "" + +replicaCount: 1 + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +podSecurityContext: + runAsNonRoot: true + runAsGroup: 65532 + runAsUser: 65532 + fsGroup: 65532 + seccompProfile: + type: RuntimeDefault +containerSecurityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + privileged: false + +service: + type: ClusterIP + port: 8008 + +# env: +# GRPC_ADDR: grpc.titus.archway.io:443 + +resources: {} +nodeSelector: {} +tolerations: [] +affinity: {} + +serviceMonitor: + enabled: false + additionalLabels: {} + interval: 1m + scrapeTimeout: 10s + telemetryPath: /metrics + targetLabels: [] + metricRelabelings: [] + relabelings: [] + +logLevel: info