Skip to content

Commit

Permalink
initial oss challenger release (#189)
Browse files Browse the repository at this point in the history
* initial oss challenger release

* use only Go version

* adds tx-type

* final tweaks
  • Loading branch information
WesleyCharlesBlake authored Dec 17, 2024
1 parent a79e3a4 commit 171f3ec
Show file tree
Hide file tree
Showing 16 changed files with 604 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/
32 changes: 32 additions & 0 deletions charts/challenger/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v2
name: challenger
description: A Helm chart for deploying the OpPoke Challenger Go Bot on Kubernetes
home: https://github.com/chronicleprotocol/challenger
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"
68 changes: 68 additions & 0 deletions charts/challenger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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 Go Bot on Kubernetes

**Homepage:** <https://github.com/chronicleprotocol/challenger>

## 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.image | string | `nil` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"ghcr.io/chronicleprotocol/challenger-go"` | |
| image.tag | string | `"0.1.0"` | `latest` tag if not specified. |
| imagePullSecrets | list | `[]` | |
| livenessProbe.initialDelaySeconds | int | `60` | |
| livenessProbe.periodSeconds | int | `120` | |
| livenessProbe.tcpSocket.port | int | `9090` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| readinessProbe.initialDelaySeconds | int | `10` | |
| readinessProbe.periodSeconds | int | `10` | |
| readinessProbe.tcpSocket.port | int | `9090` | |
| 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 | `[]` | |
| transactionType | string | `""` | Transaction type definition, possible values are: legacy, eip1559 or none (default "none") |

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

contractAddresses:
# Chronicle_ETH_USD_3
- 0x46ef0071b1E2fF6B42d36e5A177EA43Ae5917f4E

ethConfig:
ethKeys:
existingSecret: "dev-eth-keys"
key: "ethKeyStore"
ethPass:
existingSecret: "dev-eth-keys"
key: "ethPass"
# -- 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.image.tag | default "latest" }}"
args:
- "run"
{{- 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 .Values.transactionType }}
- "--tx-type"
- "{{ .Values.transactionType | default "legacy" }}"
{{- end }}
{{- if .Values.subscriptionUrl }}
- "--subscription-url"
- "{{ .Values.subscriptionUrl }}"
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}

livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}

readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}


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
17 changes: 17 additions & 0 deletions charts/challenger/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "challenger.fullname" . }}
labels:
{{- include "challenger.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
{{- range $key, $val := .Values.service.ports }}
- port: {{ $val.port }}
targetPort: {{ $val.port }}
protocol: {{ $val.protocol }}
name: {{ $key }}
{{- end }}
selector:
{{- include "challenger.selectorLabels" . | nindent 4 }}
4 changes: 4 additions & 0 deletions charts/challenger/templates/serviceaccount-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "challenger.fullname" . }}-test
Loading

0 comments on commit 171f3ec

Please # to comment.