Skip to content

Commit

Permalink
feat: Simulator helm chart (#442)
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 authored Jan 13, 2025
1 parent 01a0e00 commit 9a2e8f9
Show file tree
Hide file tree
Showing 22 changed files with 348 additions and 20 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/release-push-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,12 @@ jobs:
- name: Push helm chart
run: |
helm push block-node-helm-chart-${{ env.VERSION }}.tgz oci://ghcr.io/hashgraph/hedera-block-node
- name: Simulator Chart - Package helm chart
run: |
helm dependency update charts/blockstream-simulator
helm package charts/blockstream-simulator
- name: Simulator Chart - Push helm chart
run: |
helm push bblockstream-simulator-chart-${{ env.VERSION }}.tgz oci://ghcr.io/hashgraph/hedera-block-node
23 changes: 23 additions & 0 deletions charts/blockstream-simulator/.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/
19 changes: 19 additions & 0 deletions charts/blockstream-simulator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: Apache-2.0
apiVersion: v2
appVersion: 0.3.0-SNAPSHOT
description: A Helm chart for Hedera Blockstream Simulator.
home: https://github.com/hashgraph/hedera-block-node
keywords:
- blocknode
- dlt
- hedera
- hashgraph
- blockstream
- simulator
maintainers:
- name: Hedera Block Node Team
email: [email protected]
name: blockstream-simulator-chart
sources:
- https://github.com/hashgraph/hedera-block-node
version: 0.3.0-SNAPSHOT
62 changes: 62 additions & 0 deletions charts/blockstream-simulator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# BlockStream Simulator Helm Chart

Installs the BlockStream Simulator on a Kubernetes cluster.

## Prerequisites

- Helm 3+
- Kubernetes 1.29+

Set Release name and version to install.

```bash
export RELEASE="blockStreamSimulator"
export VERSION="0.3.0-SNAPSHOT"
```

## Template

To generate the K8 manifest files without installing the chart, you need to clone this repo and navigate to `/charts` folder.

```bash
helm template --name-template my-bs blockstream-simulator/ --dry-run --output-dir out
```

## Install using a published chart

To pull the packaged chart from the public repo:

```bash
helm pull oci://ghcr.io/hashgraph/hedera-block-node/charts/blockstream-simulator-chart--version "${VERSION}"
```

## Install using a local chart cloned from the repo

```bash
git clone [email protected]:hashgraph/hedera-block-node.git
cd hedera-block-node
helm install "${RELEASE}" charts/blockstream-simulator -f <path-to-custom-values-file>
```

## Configure

The chart comes with a set of default `Values.yaml` file that sets it in ProducerMode and looks for GRPC BN Server with the following service name `hedera-block-node-grpc-service` within the same cluster, ready to start streaming blocks.
However, is also possible to use the simulator in ConsumerMode, to do so, you need to set the following values in the `values.yaml` file:

```yaml
simulator:
config:
BLOCK_STREAM_SIMULATOR_MODE: "CONSUMER"
# Further custom configuration...
<ENV_VARIABLE>: "<Value>"
```
and if your BlockNode RELEASE name is different from the assumed: `blkNod`, you need to set the following value in the `values.yaml` file:

```yaml
simulator:
config:
GRPC_SERVER_ADDRESS: "<BlockNode_HostName(K8 ServiceName)>"
```

Refer to the Simulator configuration for further configuration options, any configuration that can be changed via ENV variables should be set in the `values.yaml` file under the `config' section in a directory for config and a separate one for secrets (if needed).
5 changes: 5 additions & 0 deletions charts/blockstream-simulator/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BlockStream Simulator Chart has been deployed successfully.
The simulator does not expose any services or API, but it automatically starts to work with the provided documentation.

The configuration can be overridden by providing a custom values.yaml with the following dictionary:
simulator.config
65 changes: 65 additions & 0 deletions charts/blockstream-simulator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

{{/*
Expand the name of the chart.
*/}}
{{- define "blockstream-simulator-chart.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 "blockstream-simulator-chart.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 "blockstream-simulator-chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
This function returns the image tag from the values.yaml file if provided.
If the tag is not provided, it defaults to the AppVersion specified in the Chart.yaml file.
Usage: {{ include "image.AppVersion" . }}
*/}}
{{- define "blockstream-simulator-chart.image.tag" -}}
{{- default .Chart.AppVersion .Values.image.tag -}}
{{- end -}}

12 changes: 12 additions & 0 deletions charts/blockstream-simulator/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "blockstream-simulator-chart.fullname" . }}-config
data:
{{- range $key, $value := .Values.simulator.config }}
{{ $key }}: {{ $value | quote }}
{{- end }}
63 changes: 63 additions & 0 deletions charts/blockstream-simulator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "blockstream-simulator-chart.fullname" . }}
labels:
{{- include "blockstream-simulator-chart.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "blockstream-simulator-chart.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "blockstream-simulator-chart.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
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 }}
ports:
- name: metrics
containerPort: 9999
protocol: TCP
envFrom:
- configMapRef:
name: {{ include "blockstream-simulator-chart.fullname" . }}-config
- secretRef:
name: {{ include "blockstream-simulator-chart.fullname" . }}-secret
{{- with .Values.resources }}
resources:
requests:
memory: {{ .requests.memory }}
cpu: {{ .requests.cpu }}
{{- 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 }}
13 changes: 13 additions & 0 deletions charts/blockstream-simulator/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

apiVersion: v1
kind: Secret
metadata:
name: {{ include "blockstream-simulator-chart.fullname" . }}-secret
type: Opaque
data:
{{- range $key, $value := .Values.simulator.secret }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/blockstream-simulator/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
image:
repository: ghcr.io/hashgraph/hedera-block-node/simulator-image
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
podAnnotations: {}
podSecurityContext: {}
securityContext: {}
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}

simulator:
config:
# either CONSUMER or PUBLISHER
BLOCK_STREAM_SIMULATOR_MODE: "PUBLISHER"
GRPC_SERVER_ADDRESS: "blkNod-block-node-helm-chart"
secret:
PRIVATE_KEY: "fake_private_key"
1 change: 1 addition & 0 deletions charts/hedera-block-node/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
apiVersion: v2
appVersion: 0.3.0-SNAPSHOT
description: A Helm chart for Hedera Block Node
Expand Down
4 changes: 4 additions & 0 deletions charts/hedera-block-node/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
19 changes: 11 additions & 8 deletions charts/hedera-block-node/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -48,16 +52,15 @@ spec:
- secretRef:
name: {{ include "hedera-block-node.fullname" . }}-secret
volumeMounts:
- name: logging-config
mountPath: /app/logs/config
readOnly: true
- name: logging-config
mountPath: /app/logs/config
readOnly: true
{{- with .Values.resources }}
resources:
requests:
memory: {{ .Values.blockNode.resources.requests.memory }}
cpu: {{ .Values.blockNode.resources.requests.cpu }}
limits:
memory: {{ .Values.blockNode.resources.limits.memory }}
cpu: {{ .Values.blockNode.resources.limits.cpu }}
memory: {{ .requests.memory }}
cpu: {{ .requests.cpu }}
{{- end }}
livenessProbe:
httpGet:
path: {{ .Values.blockNode.health.liveness.endpoint }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

{{ if .Values.kubepromstack.enabled }}
apiVersion: v1
kind: ConfigMap
Expand Down
4 changes: 4 additions & 0 deletions charts/hedera-block-node/templates/grafana-datasource.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

{{ if .Values.kubepromstack.enabled }}
apiVersion: v1
kind: ConfigMap
Expand Down
4 changes: 4 additions & 0 deletions charts/hedera-block-node/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "hedera-block-node.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
Expand Down
4 changes: 4 additions & 0 deletions charts/hedera-block-node/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

apiVersion: v1
kind: Secret
metadata:
Expand Down
4 changes: 4 additions & 0 deletions charts/hedera-block-node/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- /*
SPDX-License-Identifier: Apache-2.0
*/}}

apiVersion: v1
kind: Service
metadata:
Expand Down
Loading

0 comments on commit 9a2e8f9

Please sign in to comment.