Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: boilerplate helm chart #121

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions charts/hedera-network/.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/
4 changes: 4 additions & 0 deletions charts/hedera-network/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: hedera-network
description: A Helm chart for the Hedera network
version: 0.1.0
2 changes: 2 additions & 0 deletions charts/hedera-network/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. Get the application URL by running these commands:
...
17 changes: 17 additions & 0 deletions charts/hedera-network/templates/configmaps.yaml
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions charts/hedera-network/templates/network-node-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
59 changes: 59 additions & 0 deletions charts/hedera-network/templates/proxy-deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
21 changes: 21 additions & 0 deletions charts/hedera-network/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like it would be better to use github secrets, even if this is an example and not a real secret.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should actually just generate these pseudo-randomly via Helm and then we can retrieve the secret from the K8S cluster.

Copy link
Member

@nathanklick nathanklick Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a side note, this is just a boilerplate/template. @jeromy-cannon Your point is valid we should never commit actual secrets to a repository, but for expediency we should go ahead and treat this as an intentionally committed toss away secret.

Changing this to a generated secret is outside the scope of this issue/PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes there are just for completeness sake, we should never checkin real secrets

secret2: "c2VjcmV0"
14 changes: 14 additions & 0 deletions charts/hedera-network/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
43 changes: 43 additions & 0 deletions charts/hedera-network/values.yaml
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +3 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a list construct, but changing this is outside the scope of this issue/PR.


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