Skip to content

Commit

Permalink
Support for tezos-reward-distributor
Browse files Browse the repository at this point in the history
  • Loading branch information
novalis committed Apr 29, 2022
1 parent 679e772 commit 623435a
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/tezos-reward-distributor/.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/
24 changes: 24 additions & 0 deletions charts/tezos-reward-distributor/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: tezos-reward-distributor
description: A chart for tezos-reward-distributor

# 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.0.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: "10.0"
62 changes: 62 additions & 0 deletions charts/tezos-reward-distributor/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "tezos-reward-distributor.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 "tezos-reward-distributor.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 "tezos-reward-distributor.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "tezos-reward-distributor.selectorLabels" -}}
app.kubernetes.io/name: {{ include "tezos-reward-distributor.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "tezos-reward-distributor.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "tezos-reward-distributor.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions charts/tezos-reward-distributor/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: tezos-reward-distributor-config
data:
config.yaml: |2+
{{ toYaml $.Values.trd_config |nindent 4}}
61 changes: 61 additions & 0 deletions charts/tezos-reward-distributor/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "tezos-reward-distributor.fullname" . }}
labels:
{{- include "tezos-reward-distributor.labels" . | nindent 4 }}
spec:

# important to prevent launch of concurrent payout processes
concurrencyPolicy: Forbid

schedule: {{ .Values.schedule }}
jobTemplate:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "tezos-reward-distributor.selectorLabels" . | nindent 8 }}
spec:
template:
spec:
securityContext:
fsGroup: 1000
volumes:
- name: storage
persistentVolumeClaim:
claimName: tezos-reward-distributor-volume
- name: config-volume
configMap:
name: tezos-reward-distributor-config
initContainers:
# Work around a bug where fsGroup is ignored
- name: change-ownership-container
image: {{ .Values.images.tezos_reward_distributor }}
command:
- /bin/sh
- -c
- "mkdir -p /trd/cfg && chown -R 1000:1000 /trd"
securityContext:
runAsUser: 0
privileged: true
volumeMounts:
- mountPath: /trd
name: storage
containers:
- name: tezos-reward-distributor-cron-job
image: {{ .Values.images.tezos_reward_distributor }}
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /trd
name: storage
- mountPath: /trd/cfg/config.yaml
name: config-volume
subPath: config.yaml
command:
- /bin/sh
- -c
- python src/main.py -M 2 --reward_data_provider {{ .Values.reward_data_provider }} --node_addr_public {{ .Values.tezos_node_addr }} --node_endpoint {{ .Values.tezos_node_addr }} --base_directory /trd --signer_endpoint {{ .Values.signer_addr }} {{ .Values.extra_trd_args }} -N ITHACANET
restartPolicy: OnFailure
11 changes: 11 additions & 0 deletions charts/tezos-reward-distributor/templates/volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: "v1"
kind: PersistentVolumeClaim
metadata:
name: tezos-reward-distributor-volume
spec:
storageClassName:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
96 changes: 96 additions & 0 deletions charts/tezos-reward-distributor/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
images:
tezos_reward_distributor: trdo/tezos-reward-distributor:latest

# The node endpoint. It must be an archive node.
# May start with https://
# Default value will connect to a tezos-k8s private chain running in the same workspace, with
# default parameters.
tezos_node_addr: archive-baking-node-0.archive-baking-node:8732

# The signer endpoint. Must be able to sign for the TRD payment address configured below.
# May start with https://
# Default value will connect to a tezos-k8s private chain running in the same workspace, with
# default parameters.
signer_addr: tezos-signer-0.tezos-signer:6732

# The schedule for reward distribution cron job. By default, runs every 6 hours.
# When there is nothing to pay, it just exits.
schedule: "0 */6 * * *"

# Where TRD gets its payout data from.
# Defaults to rpc. When using rpc, you must set `tezos_node_addr` to an archive node.
#
# Pick one of "rpc", "tzstats", "tzkt"
reward_data_provider: "rpc"

extra_trd_args: "--do_not_publish_stats"

# This is an example of TRD config. Customize to your needs.
# For details, please consult TRD documentation:
# https://tezos-reward-distributor-organization.github.io/tezos-reward-distributor/
trd_config:
version: 1.0
baking_address: tz1WrZpjVRpsmjv8VL3781RhyLi5JyHsGXK2
payment_address: tz1WrZpjVRpsmjv8VL3781RhyLi5JyHsGXK2
rewards_type: actual
service_fee: 4.5
founders_map:
{'tz1WrZpjVRpsmjv8VL3781RhyLi5JyHsGXK2' : 1.0}
owners_map:
{'tz1eawTP2ueRCqsYZq3DebwW9PkthdCqcZa8' : 0.3,
'tz1WrZpjVRpsmjv8VL3781RhyLi5JyHsGXK2' : 0.7}
specials_map: {}
supporters_set: {}
min_delegation_amt: 100
reactivate_zeroed: True
delegator_pays_xfer_fee: True
delegator_pays_ra_fee: True
pay_denunciation_rewards: True
rules_map:
KT1MMhmTkUoHez4u58XMZL7NkpU9FWY4QLn3: KT1MMhmTkUoHez4u58XMZL7NkpU9FWY4QLn0
KT1D33n8zp1bqBkViiQtLLPLEGRW9xcqihY3: KT1MMhmTkUoHez4u58XMZL7NkpU9FWY4QLn0
KT1Ao8UXNJ9Dz71Wx3m8yzYNdnNQp2peqtM0: TOE
KT1VyxJWhe9oz3v4qwTp2U6Rb17ocHGpJmW0: TOB
KT19cJWfbDNXT4azVbgTBvtLMeqweuHH8W20: TOF
KT1DextebDNXT4azVbgTBvtLMeqweuHH8W20: Dexter
mindelegation: TOB
plugins:
enabled:
- webhook
email:
smtp_user: user@example.com
smtp_pass: horsebatterystaple2
smtp_host: smtp.example.com
smtp_port: 587
smtp_tls: true
smtp_sender: trdnotice@example.com
smtp_recipients:
- bob@example.com
- alice@example.com
telegram:
admin_chat_ids:
- 123456789
payouts_chat_ids:
- -13134455
bot_api_key: 988877766:SKDJFLSJDFJLJSKDFJLKSDJFLKJDF
telegram_text: >
Rewards for cycle %CYCLE% are completed.
We paid out %TREWARDS% tez in rewards to %NDELEGATORS% delegators.
twitter:
api_key: XXXXXXXX
api_secret: ZZZZZZZZ
access_token: YYYYYYYY
access_secret: WWWWWWWW
extra_tags:
- "our_baker"
- "tezos"
- "rewards"
webhook:
endpoint: https://example.com/webhook.php
token: Xynl6svphysd3BhjLP6IS
discord:
endpoint: https://discord.com/api/webhooks/9876543212345678/OmAfadfasdfasdfasdfasdfasdfasfsdf
send_admin: False
discord_text: >
Rewards for cycle %CYCLE% are completed.
We paid out %TREWARDS% tez in rewards to %NDELEGATORS% delegators.

0 comments on commit 623435a

Please sign in to comment.