diff --git a/openmina-p2p-replayer/.helmignore b/openmina-p2p-replayer/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/openmina-p2p-replayer/.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/openmina-p2p-replayer/Chart.yaml b/openmina-p2p-replayer/Chart.yaml new file mode 100644 index 0000000..accd82c --- /dev/null +++ b/openmina-p2p-replayer/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: openmina-p2p-replayer +description: A Helm chart for Kubernetes + +# 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.1.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: "1.16.0" diff --git a/openmina-p2p-replayer/README.md b/openmina-p2p-replayer/README.md new file mode 100644 index 0000000..a9171f7 --- /dev/null +++ b/openmina-p2p-replayer/README.md @@ -0,0 +1,73 @@ +# openmina-p2p-replayer + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square) + +A Helm chart for Kubernetes + +## Prerequisites + +Before using this Helm chart, you should have the following prerequisites: + +- Access to Kubernetes cluster (If needed contact your friendly neighbourhood DevOps engineer) +- Helm >= v3.14.3 +- (**Optional**) helmfile >= v0.162.0 to install this chart + +## Installation + +> Note: **examples** can be found in the repository + +To install this Helm chart, the easiest is to create a helmfile.yaml with needed values and run: + +``` +helmfile template +helmfile apply +``` + +Or use helmfile only to generate resources and apply them with kubectl like so: + +``` +helmfile template | kubectl -f - +``` + +Verify that the chart is deployed successfully: + +> Note: `kubectl` is a better suited tool for this + +``` +helmfile status +``` + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | The affinity | +| extraEnvVars | object | `{}` | | +| fullnameOverride | string | `""` | Full name override | +| image.pullPolicy | string | `"IfNotPresent"` | The image pull policy | +| image.repository | string | `"vladsimplestakingcom/bootstrap-rr"` | The image repository | +| image.tag | string | `"3.0.0-bullseye-devnet"` | Overrides the image tag whose default is the chart appVersion. | +| imagePullSecrets | list | `[]` | The secrets used to pull the image | +| livenessProbe | object | `{"initialDelaySeconds":15,"periodSeconds":10,"tcpSocket":{"port":8302}}` | Liveness check configuration | +| nameOverride | string | `""` | Name override | +| nodeSelector | object | `{}` | Node selector labels | +| podAnnotations | object | `{}` | Annotations to add to the pods | +| podLabels | object | `{}` | Label to add to the pods | +| podSecurityContext | object | `{}` | The Pod Security Context | +| readinessProbe | object | `{"initialDelaySeconds":15,"periodSeconds":10,"tcpSocket":{"port":8302}}` | Readiness check configuration | +| replayer.blockHeight | int | `328010` | The final height of the chain | +| replayer.chainId | string | `"/coda/0.0.1/29936104443aaf264a7f0192ac64b1c7173198c1ed404c1bcff5e562e05eb7f6"` | Chain ID | +| replayer.p2p.secretKey | string | `""` | | +| replicaCount | int | `1` | The number of replicas | +| resources | object | `{}` | The Resources | +| securityContext | object | `{}` | The Security Context | +| service.port | int | `8302` | Service port | +| service.type | string | `"ClusterIP"` | Service type | +| serviceAccount.annotations | object | `{}` | | +| serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? | +| serviceAccount.create | bool | `false` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | If not set and create is true, a name is generated using the fullname template | +| tolerations | list | `[]` | The tolerations | +| volumeMounts | list | `[]` | Additional volumeMounts on the output Deployment definition. | +| volumes | list | `[]` | Additional volumes on the output Deployment definition. | + diff --git a/openmina-p2p-replayer/templates/_helpers.tpl b/openmina-p2p-replayer/templates/_helpers.tpl new file mode 100644 index 0000000..7d48797 --- /dev/null +++ b/openmina-p2p-replayer/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openmina-p2p-replayer.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 "openmina-p2p-replayer.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 "openmina-p2p-replayer.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openmina-p2p-replayer.labels" -}} +helm.sh/chart: {{ include "openmina-p2p-replayer.chart" . }} +{{ include "openmina-p2p-replayer.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openmina-p2p-replayer.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openmina-p2p-replayer.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openmina-p2p-replayer.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openmina-p2p-replayer.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/openmina-p2p-replayer/templates/deployment.yaml b/openmina-p2p-replayer/templates/deployment.yaml new file mode 100644 index 0000000..1869ee6 --- /dev/null +++ b/openmina-p2p-replayer/templates/deployment.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openmina-p2p-replayer.fullname" . }} + {{- with .Values.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{- include "openmina-p2p-replayer.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "openmina-p2p-replayer.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openmina-p2p-replayer.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openmina-p2p-replayer.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 .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["openmina-bootstrap-sandbox"] + args: + - "--listen=/ip4/0.0.0.0/tcp/{{ .Values.service.port }}" + - "--chain-id={{ .Values.replayer.chainId }}" + - replay + - {{ .Values.replayer.blockHeight |quote}} + ports: + - name: external-port + containerPort: {{ .Values.service.port }} + protocol: TCP + env: + - name: OPENMINA_P2P_SEC_KEY + value: {{ .Values.replayer.p2p.secretKey }} + {{- if .Values.extraEnvVars }} + {{- toYaml .Values.extraEnvVars | nindent 12 }} + {{- end }} + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + 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 }} diff --git a/openmina-p2p-replayer/templates/service.yaml b/openmina-p2p-replayer/templates/service.yaml new file mode 100644 index 0000000..bc713f8 --- /dev/null +++ b/openmina-p2p-replayer/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openmina-p2p-replayer.fullname" . }} + labels: + {{- include "openmina-p2p-replayer.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: external-port + protocol: TCP + name: tcp-p2p + selector: + {{- include "openmina-p2p-replayer.selectorLabels" . | nindent 4 }} diff --git a/openmina-p2p-replayer/templates/serviceaccount.yaml b/openmina-p2p-replayer/templates/serviceaccount.yaml new file mode 100644 index 0000000..c4b3796 --- /dev/null +++ b/openmina-p2p-replayer/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openmina-p2p-replayer.serviceAccountName" . }} + labels: + {{- include "openmina-p2p-replayer.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/openmina-p2p-replayer/values.yaml b/openmina-p2p-replayer/values.yaml new file mode 100644 index 0000000..72f5c4c --- /dev/null +++ b/openmina-p2p-replayer/values.yaml @@ -0,0 +1,123 @@ +# Default values for openmina-p2p-replayer. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replayer: + p2p: + # -- Secret key(unencrypted, without password), can be generated with: cargo run --release -p cli misc p2p-key-pair + secretKey: "" + # -- Chain ID + chainId: "/coda/0.0.1/29936104443aaf264a7f0192ac64b1c7173198c1ed404c1bcff5e562e05eb7f6" + # -- The final height of the chain + blockHeight: 328010 + +service: + # -- Service type + type: ClusterIP + # -- Service port + port: 8302 + +## - Extra Environment variables +extraEnvVars: {} +# - name: FOO +# value: FOO +# - name: BAR +# valueFrom: +# secretKeyRef: +# name: mySecret +# key: bar + +# -- The number of replicas +replicaCount: 1 + +image: + # -- The image repository + repository: vladsimplestakingcom/bootstrap-rr + # -- The image pull policy + pullPolicy: IfNotPresent + # -- Overrides the image tag whose default is the chart appVersion. + tag: "3.0.0-bullseye-devnet" + +# -- The secrets used to pull the image +imagePullSecrets: [] +# -- Name override +nameOverride: "" +# -- Full name override +fullnameOverride: "" + +serviceAccount: + # -- Specifies whether a service account should be created + create: false + # -- Automatically mount a ServiceAccount's API credentials? + automount: true + # - Annotations to add to the service account + annotations: {} + # -- The name of the service account to use. + # -- If not set and create is true, a name is generated using the fullname template + name: "" + +# -- Annotations to add to the pods +podAnnotations: {} +# -- Label to add to the pods +podLabels: {} + +# -- The Pod Security Context +podSecurityContext: {} + # fsGroup: 2000 + +# -- The Security Context +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# -- The Resources +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# -- Liveness check configuration +livenessProbe: + tcpSocket: + port: 8302 + initialDelaySeconds: 15 + periodSeconds: 10 +# -- Readiness check configuration +readinessProbe: + tcpSocket: + port: 8302 + initialDelaySeconds: 15 + periodSeconds: 10 + +# -- Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# -- Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +# -- Node selector labels +nodeSelector: {} + +# -- The tolerations +tolerations: [] + +# -- The affinity +affinity: {}