Skip to content

Commit

Permalink
initial oss challenger release
Browse files Browse the repository at this point in the history
  • Loading branch information
WesleyCharlesBlake committed Dec 16, 2024
1 parent a79e3a4 commit f2c16ff
Show file tree
Hide file tree
Showing 17 changed files with 624 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/challenger/.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/
31 changes: 31 additions & 0 deletions charts/challenger/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v2
name: challenger
description: A Helm chart for deploying the OpPoke Challenger Bot on Kubernetes
maintainers:
- name: WesleyCharlesBlake
url: https://github.com/WesleyCharlesBlake
- name: chronicleprotocol
url: https://github.com/chronicleprotocol

icon: https://avatars.githubusercontent.com/u/87739326

# 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.1

# 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: "0.1.0"
65 changes: 65 additions & 0 deletions charts/challenger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# challenger

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

A Helm chart for deploying the OpPoke Challenger Bot on Kubernetes

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| WesleyCharlesBlake | | <https://github.com/WesleyCharlesBlake> |
| chronicleprotocol | | <https://github.com/chronicleprotocol> |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| contractAddresses | list | `[]` | Oracle Contract address to listen to. |
| env | object | `{"normal":{}}` | non encrypted variables |
| ethChainId | string | `"1"` | mainnet eth or sepolia eth |
| ethConfig | object | `{}` | Provide ETH keys from existing secrets |
| ethRpcUrl | string | `""` | mainnet or sepolia RPC endpoint |
| extraObjects | list | `[]` | Extra K8s manifests to deploy |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"ghcr.io/chronicleprotocol"` | |
| image.tag | string | `"0.1.0-alpine"` | tag must correspond to what is available at {{ .Values.image.repository }}/{{.Values.implementation}}. `latest` tag if not specified. |
| imagePullSecrets | list | `[]` | |
| implementation | string | `"challenger"` | Which implementation to use, can be one of `challenger-go` or `challenger` (rust impl) (default `challenger`) |
| livenessProbe.initialDelaySeconds | int | `60` | |
| livenessProbe.periodSeconds | int | `120` | |
| livenessProbe.tcpSocket.port | string | `"challenger"` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| readinessProbe.initialDelaySeconds | int | `10` | |
| readinessProbe.periodSeconds | int | `10` | |
| readinessProbe.tcpSocket.port | string | `"challenger"` | |
| replicaCount | int | `1` | how many replicas to run (default 1) |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| service.ports.challenger.port | int | `9090` | |
| service.ports.challenger.protocol | string | `"TCP"` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| serviceMonitor.annotations | object | `{}` | Additional ServiceMonitor annotations |
| serviceMonitor.enabled | bool | `false` | If true, a ServiceMonitor CRD is created for a prometheus operator https://github.com/coreos/prometheus-operator |
| serviceMonitor.interval | string | `"30s"` | ServiceMonitor scrape interval |
| serviceMonitor.labels | object | `{}` | Additional ServiceMonitor labels |
| serviceMonitor.namespace | string | `nil` | Alternative namespace for ServiceMonitor |
| serviceMonitor.path | string | `"/metrics"` | Path to scrape |
| serviceMonitor.port | string | `"challenger"` | port to scrape |
| serviceMonitor.relabelings | list | `[]` | ServiceMonitor relabelings |
| serviceMonitor.scheme | string | `"http"` | ServiceMonitor scheme |
| serviceMonitor.scrapeTimeout | string | `"30s"` | ServiceMonitor scrape timeout |
| serviceMonitor.tlsConfig | object | `{}` | ServiceMonitor TLS configuration |
| subscriptionUrl | string | `""` | If challenger-go, we can also provide a wss endpoint (OPTIONAL) |
| tolerations | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
24 changes: 24 additions & 0 deletions charts/challenger/ci/challenger-go-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# challenger go implementation
implementation: challenger-go

image:
tag: "0.1.0"

ethRpcUrl: "https://eth.drpc.org"
subscriptionUrl: "wss://eth.drpc.org"

contractAddresses:
# Chronicle_ETH_USD_3
- 0x46ef0071b1E2fF6B42d36e5A177EA43Ae5917f4E

ethConfig: {}
# ethKeys:
# existingSecret: "eth-keystore"
# key: "keystore.son"
# ethPass:
# existingSecret: "eth-password"
# key: "password.txt"
# -- OR you can supply only ETH private key:
# ethPrivateKey:
# existingSecret: "eth-private-key"
# key: "ethPrivateKey"
18 changes: 18 additions & 0 deletions charts/challenger/ci/challenger-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# challenger rust implementation (default values)
ethRpcUrl: "https://eth-mainnet.public.blastapi.io"

contractAddresses:
# Chronicle_ETH_USD_3
- 0x46ef0071b1E2fF6B42d36e5A177EA43Ae5917f4E

ethConfig: {}
# ethKeys:
# existingSecret: "eth-keystore"
# key: "keystore.son"
# ethPass:
# existingSecret: "eth-password"
# key: "password.txt"
# -- OR you can supply only ETH private key:
# ethPrivateKey:
# existingSecret: "eth-private-key"
# key: "ethPrivateKey"
4 changes: 4 additions & 0 deletions charts/challenger/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1. Get the application pods by running these commands:

export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "challenger.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl logs $POD_NAME --namespace {{ .Release.Namespace }}
72 changes: 72 additions & 0 deletions charts/challenger/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "challenger.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 "challenger.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 "challenger.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "challenger.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "challenger.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create normal env vars from list
*/}}
{{- define "helpers.list-env-variables"}}
{{- range $key, $val := .Values.env.normal }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- end }}
118 changes: 118 additions & 0 deletions charts/challenger/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "challenger.fullname" . }}
labels:
{{- include "challenger.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount | default 1 }}
selector:
matchLabels:
{{- include "challenger.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "challenger.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "challenger.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}/{{ .Values.implementation }}:{{ .Values.image.tag | default "latest" }}"
args:
{{- if eq .Values.implementation "challenger-go" }}
- "run"
{{- end }}
{{- range $address := .Values.contractAddresses }}
- "-a"
- "{{ $address }}"
{{- end }}
- "--rpc-url"
- "{{ .Values.ethRpcUrl }}"
{{- if .Values.ethConfig.ethPrivateKey }}
- "--secret-key"
- "${ETH_SECRET_KEY}"
{{- end }}
{{- if .Values.ethConfig.ethKeys }}
- "--keystore"
- "/keystore/keystore.json"
- "--password-file"
- "/password/password.txt"
{{- end }}
- "--chain-id"
- "{{ .Values.ethChainId }}"
{{- if eq .Values.implementation "challenger-go" }}
- "--subscription-url"
- "{{ .Values.subscriptionUrl }}"
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}

livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http

env:
{{- if .Values.ethConfig.ethPrivateKey }}
- name: ETH_SECRET_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.ethConfig.ethPrivateKey.existingSecret }}
key: {{ .Values.ethConfig.ethPrivateKey.key }}
{{- end }}
{{- include "helpers.list-env-variables" . | indent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- if .Values.ethConfig.ethKeys }}
- name: keystore
mountPath: /keystore/
- name: password
mountPath: /password/
{{- end }}
volumes:
{{- if .Values.ethConfig.ethKeys }}
- name: keystore
secret:
secretName: {{ .Values.ethConfig.ethKeys.existingSecret }}
items:
- key: {{ .Values.ethConfig.ethKeys.key }}
path: keystore.json
{{- end }}
{{- if .Values.ethConfig.ethPass }}
- name: password
secret:
secretName: {{ .Values.ethConfig.ethPass.existingSecret }}
items:
- key: {{ .Values.ethConfig.ethPass.key }}
path: password.txt
{{- 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 }}
4 changes: 4 additions & 0 deletions charts/challenger/templates/extra-manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ range .Values.extraObjects }}
---
{{ tpl (toYaml .) $ }}
{{ end }}
8 changes: 8 additions & 0 deletions charts/challenger/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "challenger.fullname" . }}-test
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
11 changes: 11 additions & 0 deletions charts/challenger/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "challenger.fullname" . }}-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "challenger.fullname" . }}-test
subjects:
- kind: ServiceAccount
name: {{ include "challenger.fullname" . }}-test
Loading

0 comments on commit f2c16ff

Please sign in to comment.