Skip to content

Commit

Permalink
feat(helm): create charts for deployment (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
cebidhem authored Aug 17, 2023
1 parent ef041fd commit f9933bf
Show file tree
Hide file tree
Showing 29 changed files with 468 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Run tests
run: poetry run pytest --cov eth_validator_watcher --cov-report xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v3
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__
.mypy_cache
.coverage
.coverage
.idea
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: ^docs/
- id: end-of-file-fixer
exclude: ^docs/
- id: check-added-large-files
exclude: ^docs/
- id: check-yaml
exclude: ^charts/
- repo: https://github.com/norwoodj/helm-docs
rev: v1.11.0
hooks:
- id: helm-docs
args:
# Make the tool search for charts only under the `example-charts` directory
- --chart-search-root=charts

# The `./` makes it relative to the chart-search-root set above
- --template-files=./_templates.gotmpl

# Repeating the flag adds this to the list, now [./_templates.gotmpl, README.md.gotmpl]
# A base filename makes it relative to each chart directory found
- --template-files=README.md.gotmpl
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- id: helm-docs
args: []
description: Uses 'helm-docs' to create documentation from the Helm chart's 'values.yaml' file, and inserts the result into a corresponding 'README.md' file.
entry: git-hook/helm-docs
files: (README\.md\.gotmpl|(Chart|requirements|values)\.yaml)$
language: script
name: Helm Docs
require_serial: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ COPY liveness_check.py /usr/local/bin/liveness_check.py

ENV PYTHONPATH=/usr/local/lib/python3.9/site-packages

ENTRYPOINT [ "python", "/usr/local/bin/eth-validator-watcher" ]
ENTRYPOINT [ "python", "/usr/local/bin/eth-validator-watcher" ]
9 changes: 9 additions & 0 deletions charts/eth-validator-watcher/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
description: A Helm chart for running eth-validator-watcher
name: eth-validator-watcher
type: application
version: 1.0.0
maintainers:
- name: Alluvial
email: [email protected]
url: https://alluvial.finance
62 changes: 62 additions & 0 deletions charts/eth-validator-watcher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# eth-validator-watcher

![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

A Helm chart for running eth-validator-watcher

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Alluvial | <[email protected]> | <https://alluvial.finance> |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| args | list | `[]` | Specifies the arguments to the command line Please refer to https://github.com/kilnfi/eth-validator-watcher/blob/main/README.md#description |
| env | object | `{}` | |
| envFrom | object | `{}` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"ghcr.io/kilnfi/eth-validator-watcher"` | |
| image.tag | string | `"latest"` | |
| imagePullSecrets | list | `[]` | |
| livenessProbe.exec.command[0] | string | `"/usr/bin/python3.9"` | |
| livenessProbe.exec.command[1] | string | `"/usr/local/bin/liveness_check.py"` | |
| livenessProbe.exec.command[2] | string | `"/tmp/liveness"` | |
| livenessProbe.failureThreshold | int | `10` | |
| livenessProbe.initialDelaySeconds | int | `120` | |
| livenessProbe.periodSeconds | int | `60` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| readinessProbe.exec.command[0] | string | `"/usr/bin/python3.9"` | |
| readinessProbe.exec.command[1] | string | `"/usr/local/bin/liveness_check.py"` | |
| readinessProbe.exec.command[2] | string | `"/tmp/liveness"` | |
| readinessProbe.failureThreshold | int | `10` | |
| readinessProbe.initialDelaySeconds | int | `30` | |
| readinessProbe.periodSeconds | int | `60` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| serviceMonitor.additionalLabels | object | `{}` | |
| serviceMonitor.enabled | bool | `false` | |
| serviceMonitor.metricRelabelings | list | `[]` | |
| serviceMonitor.namespace | string | `""` | |
| serviceMonitor.namespaceSelector | object | `{}` | |
| serviceMonitor.scrapeInterval | string | `"60s"` | |
| serviceMonitor.targetLabels | list | `[]` | |
| startupProbe | object | `{}` | |
| tolerations | list | `[]` | |
| volumeMounts | list | `[]` | |
| volumes | list | `[]` | |
| watchedKeys | list | `[]` | List of public keys to watch. See https://github.com/kilnfi/eth-validator-watcher/blob/main/README.md#command-lines-examples |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
62 changes: 62 additions & 0 deletions charts/eth-validator-watcher/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "eth-validator-watcher.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 "eth-validator-watcher.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 "eth-validator-watcher.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "eth-validator-watcher.labels" -}}
helm.sh/chart: {{ include "eth-validator-watcher.chart" . }}
{{ include "eth-validator-watcher.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "eth-validator-watcher.selectorLabels" -}}
app.kubernetes.io/name: {{ include "eth-validator-watcher.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "eth-validator-watcher.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "eth-validator-watcher.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/eth-validator-watcher/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.watchedKeys }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "eth-validator-watcher.fullname" . }}
labels:
{{- include "eth-validator-watcher.labels" . | nindent 4 }}
data:
watched-keys.txt: |
{{- range .Values.watchedKeys }}
{{- . | nindent 4 }}
{{- end }}
{{- end }}
103 changes: 103 additions & 0 deletions charts/eth-validator-watcher/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "eth-validator-watcher.fullname" . }}
labels:
{{- include "eth-validator-watcher.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "eth-validator-watcher.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "eth-validator-watcher.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "eth-validator-watcher.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: eth-validator-watcher
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
{{- if .Values.watchedKeys }}
- --pubkeys-file-path=/data/keys/watched-keys.txt
{{- end }}
{{- with .Values.args }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: metrics
containerPort: 8000
protocol: TCP
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.startupProbe }}
startupProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.env .Values.envFrom }}
env:
{{- with .Values.envFrom }}
{{- range $key, $value := . }}
- name: {{ $key }}
{{- toYaml $value | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.env }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.watchedKeys }}
volumeMounts:
- name: "watched-keys"
mountPath: "/data/keys"
readOnly: true
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.watchedKeys }}
volumes:
- name: "watched-keys"
configMap:
name: {{ include "eth-validator-watcher.fullname" . }}
{{- end }}
{{- with .Values.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 }}
15 changes: 15 additions & 0 deletions charts/eth-validator-watcher/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "eth-validator-watcher.fullname" . }}
labels:
{{- include "eth-validator-watcher.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- name: metrics
port: 8000
targetPort: metrics
protocol: TCP
selector:
{{- include "eth-validator-watcher.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/eth-validator-watcher/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "eth-validator-watcher.serviceAccountName" . }}
labels:
{{- include "eth-validator-watcher.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
40 changes: 40 additions & 0 deletions charts/eth-validator-watcher/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- if .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "eth-validator-watcher.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace | quote }}
{{- end }}
labels:
{{- include "eth-validator-watcher.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.additionalLabels }}
{{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: metrics
interval: {{ .Values.serviceMonitor.scrapeInterval }}
{{- if .Values.serviceMonitor.honorLabels }}
honorLabels: true
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings: {{ toYaml .Values.serviceMonitor.metricRelabelings | nindent 8 }}
{{- end }}
{{- if .Values.serviceMonitor.namespaceSelector }}
namespaceSelector: {{ toYaml .Values.serviceMonitor.namespaceSelector | nindent 4 }}
{{ else }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
{{- if .Values.serviceMonitor.targetLabels }}
targetLabels:
{{- range .Values.serviceMonitor.targetLabels }}
- {{ . }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "eth-validator-watcher.selectorLabels" . | nindent 6 }}
{{- end }}
Loading

0 comments on commit f9933bf

Please sign in to comment.