From 70c66ca4c851a5a4961e3b5d19527bc477f8c0ae Mon Sep 17 00:00:00 2001 From: Deepak Mishra <107930718+deepak-swirlds@users.noreply.github.com> Date: Wed, 28 Jun 2023 09:58:59 +0530 Subject: [PATCH] feat: boilerplate helm chart (#121) Signed-off-by: Deepak Mishra --- charts/hedera-network/.helmignore | 23 ++++++++ charts/hedera-network/Chart.yaml | 4 ++ charts/hedera-network/templates/NOTES.txt | 2 + .../hedera-network/templates/configmaps.yaml | 17 ++++++ .../templates/network-node-statefulset.yaml | 52 ++++++++++++++++ .../templates/proxy-deployment.yaml | 59 +++++++++++++++++++ charts/hedera-network/templates/secrets.yaml | 21 +++++++ charts/hedera-network/templates/service.yaml | 14 +++++ charts/hedera-network/values.yaml | 43 ++++++++++++++ 9 files changed, 235 insertions(+) create mode 100644 charts/hedera-network/.helmignore create mode 100644 charts/hedera-network/Chart.yaml create mode 100644 charts/hedera-network/templates/NOTES.txt create mode 100644 charts/hedera-network/templates/configmaps.yaml create mode 100644 charts/hedera-network/templates/network-node-statefulset.yaml create mode 100644 charts/hedera-network/templates/proxy-deployment.yaml create mode 100644 charts/hedera-network/templates/secrets.yaml create mode 100644 charts/hedera-network/templates/service.yaml create mode 100644 charts/hedera-network/values.yaml diff --git a/charts/hedera-network/.helmignore b/charts/hedera-network/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/charts/hedera-network/.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/charts/hedera-network/Chart.yaml b/charts/hedera-network/Chart.yaml new file mode 100644 index 000000000..f90115fac --- /dev/null +++ b/charts/hedera-network/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: hedera-network +description: A Helm chart for the Hedera network +version: 0.1.0 diff --git a/charts/hedera-network/templates/NOTES.txt b/charts/hedera-network/templates/NOTES.txt new file mode 100644 index 000000000..5a4cefdbc --- /dev/null +++ b/charts/hedera-network/templates/NOTES.txt @@ -0,0 +1,2 @@ +1. Get the application URL by running these commands: +... \ No newline at end of file diff --git a/charts/hedera-network/templates/configmaps.yaml b/charts/hedera-network/templates/configmaps.yaml new file mode 100644 index 000000000..609ea1483 --- /dev/null +++ b/charts/hedera-network/templates/configmaps.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: uploader-mirror-config +data: + # add your data here + property1: value1 + property2: value2 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: backup-config +data: + # add your data here + property1: value1 + property2: value2 diff --git a/charts/hedera-network/templates/network-node-statefulset.yaml b/charts/hedera-network/templates/network-node-statefulset.yaml new file mode 100644 index 000000000..3ac5949b5 --- /dev/null +++ b/charts/hedera-network/templates/network-node-statefulset.yaml @@ -0,0 +1,52 @@ + +{{ range $nodeName, $nodeConfig := ($.Values.hedera.nodes) }} +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: network-{{ $nodeName }} + labels: + app: network-{{ $nodeName }} +spec: + replicas: 1 + serviceName: "network-node-{{ $nodeName }}" + selector: + matchLabels: + app: network-{{ $nodeName }} + template: + metadata: + labels: + app: network-{{ $nodeName }} + spec: + containers: + - name: root-container + image: {{ $.Values.infrastructure.docker.registry }}/{{ $.Values.infrastructure.docker.images.root }} + resources: + requests: + memory: 50Mi + cpu: {{ index (index $.Values.hedera.nodes $nodeName) "cpu" }} + limits: + memory: 100Mi + cpu: 100m + - name: record-stream-uploader + image: {{ $.Values.infrastructure.docker.registry }}/{{ $.Values.infrastructure.docker.images.streamuploader }} + envFrom: + - configMapRef: + name: uploader-mirror-config + - secretRef: + name: uploader-mirror-secrets + - name: event-stream-uploader + image: {{ $.Values.infrastructure.docker.registry }}/{{ $.Values.infrastructure.docker.images.streamuploader }} + envFrom: + - configMapRef: + name: uploader-mirror-config + - secretRef: + name: uploader-mirror-secrets + - name: backup-uploader + image: {{ $.Values.infrastructure.docker.registry }}/{{ $.Values.infrastructure.docker.images.backupuploader }} + envFrom: + - configMapRef: + name: backup-config + - secretRef: + name: backup-secrets +{{ end }} \ No newline at end of file diff --git a/charts/hedera-network/templates/proxy-deployment.yaml b/charts/hedera-network/templates/proxy-deployment.yaml new file mode 100644 index 000000000..2424d0b75 --- /dev/null +++ b/charts/hedera-network/templates/proxy-deployment.yaml @@ -0,0 +1,59 @@ +{{ range $nodeName, $nodeConfig := ($.Values.hedera.nodes) }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: haproxy-{{ $nodeName }} +spec: + replicas: {{ $.Values.haproxyReplicaCount }} + selector: + matchLabels: + app: haproxy-{{ $nodeName }} + template: + metadata: + labels: + app: haproxy-{{ $nodeName }} + spec: + containers: + - name: haproxy + image: {{ $.Values.infrastructure.docker.registry }}/{{ $.Values.infrastructure.docker.images.haproxy }} + imagePullPolicy: Always +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: envoy-proxy-{{ $nodeName }} +spec: + replicas: {{ $.Values.envoyProxyReplicaCount }} + selector: + matchLabels: + app: envoy-proxy-{{ $nodeName }} + template: + metadata: + labels: + app: envoy-proxy-{{ $nodeName }} + spec: + containers: + - name: envoy-proxy + image: {{ $.Values.infrastructure.docker.registry }}/{{ $.Values.infrastructure.docker.images.envoyproxy }} + imagePullPolicy: Always +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: json-rpc-relay-{{ $nodeName }} +spec: + replicas: 1 + selector: + matchLabels: + app: json-rpc-relay-{{ $nodeName }} + template: + metadata: + labels: + app: json-rpc-relay-{{ $nodeName }} + spec: + containers: + - name: json-rpc-relay + image: {{ $.Values.infrastructure.docker.registry }}/{{ $.Values.infrastructure.docker.images.jsonrpcrelay }} + imagePullPolicy: Always +{{- end }} \ No newline at end of file diff --git a/charts/hedera-network/templates/secrets.yaml b/charts/hedera-network/templates/secrets.yaml new file mode 100644 index 000000000..de748a07f --- /dev/null +++ b/charts/hedera-network/templates/secrets.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Secret +metadata: + name: uploader-mirror-secrets +type: Opaque +data: + # add your secrets here + # Note: Kubernetes secrets should be base64 encoded + secret1: "c2VjcmV0" + secret2: "c2VjcmV0" +--- +apiVersion: v1 +kind: Secret +metadata: + name: backup-secrets +type: Opaque +data: + # add your secrets here + # Note: Kubernetes secrets should be base64 encoded + secret1: "c2VjcmV0" + secret2: "c2VjcmV0" diff --git a/charts/hedera-network/templates/service.yaml b/charts/hedera-network/templates/service.yaml new file mode 100644 index 000000000..5ec3578e8 --- /dev/null +++ b/charts/hedera-network/templates/service.yaml @@ -0,0 +1,14 @@ +{{ range $nodeName, $nodeConfig := ($.Values.hedera.nodes) }} +--- +apiVersion: v1 +kind: Service +metadata: + name: service-network-{{ $nodeName }} +spec: + selector: + app: network-{{ $nodeName }} + ports: + - protocol: TCP + port: 50211 + targetPort: 50211 +{{- end }} diff --git a/charts/hedera-network/values.yaml b/charts/hedera-network/values.yaml new file mode 100644 index 000000000..74bf032aa --- /dev/null +++ b/charts/hedera-network/values.yaml @@ -0,0 +1,43 @@ +hedera: + # TODO: do we need an easy way (to avoid repetition) to create multiple notes if they all have the same configuration? + nodes: + node-1: + # TODO: Configuration like address ( and similar ), can be autogenerated by helm, do we need to think about this ? + address: 0.0.1 + cpu: 1 + memory: 1GB + latency: 10ms + bandwidth: 1 Mbps + node-2: + address: 0.0.2 + cpu: 1 + memory: 1GB + latency: 10ms + bandwidth: 2 Mbps + node-3: + address: 0.0.3 + cpu: 1 + memory: 1GB + latency: 10ms + bandwidth: 3 Mbps + +infrastructure: + docker: + registry: docker.io + images: + root: docker:24.0.2-dind + envoyproxy: envoyproxy/envoy:v1.26-latest + haproxy: haproxy:lts-alpine3.18 + jsonrpcrelay: jsonrpcrelay + streamuploader: ubuntu + backupuploader: ubuntu + + proxies: + # 1 Haproxy Deployment is created for 1 hedera network node (StatefulSet) + # This controls how many replicas within a deployment are needed, in production we use 3 + haproxyReplicas: 1 + envoyProxyReplicas: 1 + + + +