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

Adding fullnameOverwrite and annotations for customising Genesis startup hooks #246

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ The current repo layout is:
│ ├── arm # azure ARM templates to deploy resources ie cluster, keyvault, identity etc
│ └── scripts # azure scripts to install CSI drivers on the AKS cluster and the like
├── playground # playground for users to get familiar with concepts and how to run and tweak things - START HERE
│ └── kubectl
│ ├── quorum-besu # use Hyperledger Besu as the block chain client
│ │ ├── clique
│ │ │ ├── ... # templates, config etc hidden here for brevity
│ │ ├── ethash
│ │ │ ├── ...
│ │ └── ibft2
│ │ └── ...
│ └── quorum-go # use GoQuorum as the block chain client
│ └── ibft
│ └── ...
│ ├── kubectl
│ │ ├── quorum-besu # use Hyperledger Besu as the block chain client
│ │ │ ├── clique
│ │ │ │ ├── ... # templates, config etc hidden here for brevity
│ │ │ ├── ethash
│ │ │ │ ├── ...
│ │ │ └── ibft2
│ │ │ └── ...
│ │ └── quorum-go # use GoQuorum as the block chain client
│ │ └── ibft
│ │ └── ...
│ └── helm # playground for helm-based deployments
├── helm
│ ├── charts
│ │ ├── ... # helm charts, hidden here for brevity
Expand Down
6 changes: 4 additions & 2 deletions helm/charts/besu-genesis/templates/genesis-job-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ metadata:
app.kubernetes.io/release: {{ .Release.Name }}
app.kubernetes.io/managed-by: helm
namespace: {{ .Release.Namespace }}
{{- if .Values.initJob.annotations }}
annotations:
helm.sh/hook-delete-policy: "hook-succeeded"
{{- toYaml .Values.initJob.annotations | nindent 4 }}
{{- end}}
spec:
# backoffLimit: 3
backoffLimit: 3
completions: 1
template:
metadata:
Expand Down
16 changes: 14 additions & 2 deletions helm/charts/besu-genesis/templates/genesis-service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ kind: ServiceAccount
metadata:
name: {{ include "besu-genesis.name" . }}-sa
namespace: {{ .Release.Namespace }}
{{- if .Values.serviceAccount.annotations }}
annotations:
{{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
{{- end }}

{{- end }}

Expand All @@ -15,10 +19,14 @@ kind: Role
metadata:
name: {{ include "besu-genesis.name" . }}-role
namespace: {{ .Release.Namespace }}
{{- if .Values.serviceAccountRole.annotations }}
annotations:
{{- toYaml .Values.serviceAccountRole.annotations | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["secrets", "configmaps"]
verbs: ["create", "get", "list", "update", "delete" ]
verbs: ["create", "get", "list", "update", "delete", "patch" ]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch" ]
Expand All @@ -29,6 +37,10 @@ kind: RoleBinding
metadata:
name: {{ include "besu-genesis.name" . }}-rb
namespace: {{ .Release.Namespace }}
{{- if .Values.serviceAccountRoleBinding.annotations }}
annotations:
{{- toYaml .Values.serviceAccountRoleBinding.annotations | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -42,4 +54,4 @@ subjects:
name: {{ .Values.aws.serviceAccountName }}
{{- else }}
name: {{ include "besu-genesis.name" . }}-sa
{{- end}}
{{- end}}
22 changes: 16 additions & 6 deletions helm/charts/besu-genesis/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
---
initJob:
annotations: {} # additional annotations to init job

serviceAccount:
annotations: {} # additional annotations for the service account

serviceAccountRole:
annotations: {} # additional annotations for the service account role

serviceAccountRoleBinding:
annotations: {} # additional annotations for the service account role binding

quorumFlags:
removeGenesisOnDelete: true

cluster:
provider: local # choose from: local | aws | azure
provider: local # choose from: local | aws | azure
cloudNativeServices: false # set to true to use Cloud Native Services (SecretsManager and IAM for AWS; KeyVault & Managed Identities for Azure)

aws:
Expand Down Expand Up @@ -34,15 +45,14 @@ rawGenesisConfig:
blockperiodseconds: 10
epochlength: 30000
requesttimeoutseconds: 20
gasLimit: '0xf7b760'
difficulty: '0x1'
coinbase: '0x0000000000000000000000000000000000000000'
gasLimit: "0xf7b760"
difficulty: "0x1"
coinbase: "0x0000000000000000000000000000000000000000"
blockchain:
nodes:
generate: true
count: 4
accountPassword: 'password'

accountPassword: "password"

image:
repository: consensys/quorum-k8s-hooks
Expand Down
4 changes: 3 additions & 1 deletion helm/charts/besu-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ If release name contains chart name it will be used as a full name.
*/}}
{{- define "besu-node.fullname" -}}
{{- $name := default .Chart.Name -}}
{{- if contains $name .Release.Name -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" $name .Release.Name | trunc 63 | trimSuffix "-" -}}
Expand Down
1 change: 0 additions & 1 deletion helm/charts/besu-node/templates/node-storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ spec:
path: "/tmp/{{ include "besu-node.fullname" . }}"

{{- end }}

4 changes: 3 additions & 1 deletion helm/charts/blockscout/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ If release name contains chart name it will be used as a full name.
*/}}
{{- define "blockscout.fullname" -}}
{{- $name := default .Chart.Name -}}
{{- if contains $name .Release.Name -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" $name .Release.Name | trunc 63 | trimSuffix "-" -}}
Expand Down
2 changes: 2 additions & 0 deletions helm/charts/blockscout/templates/blockscout-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ spec:
metadata:
labels:
app: {{ template "blockscout.fullname" . }}
app.kubernetes.io/part-of: {{ include "blockscout.fullname" . }}
app.kubernetes.io/namespace: {{ .Release.Namespace }}
spec:
serviceAccountName: {{ include "blockscout.fullname" . }}-sa
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ spec:
kubectl delete configmap --namespace {{ .Release.Namespace }} goquorum-peers

{{- end}}

4 changes: 3 additions & 1 deletion helm/charts/goquorum-genesis/templates/genesis-job-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ metadata:
app.kubernetes.io/namespace: {{ .Release.Namespace }}
app.kubernetes.io/managed-by: helm
namespace: {{ .Release.Namespace }}
{{- if .Values.initJob.annotations }}
annotations:
helm.sh/hook-delete-policy: "hook-succeeded"
{{- toYaml .Values.initJob.annotations | nindent 4 }}
{{- end}}
spec:
backoffLimit: 3
completions: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ kind: ServiceAccount
metadata:
name: {{ include "goquorum-genesis.name" . }}-sa
namespace: {{ .Release.Namespace }}
{{- if .Values.serviceAccount.annotations }}
annotations:
{{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
{{- end }}

{{- end }}

Expand All @@ -15,6 +19,10 @@ kind: Role
metadata:
name: {{ include "goquorum-genesis.name" . }}-role
namespace: {{ .Release.Namespace }}
{{- if .Values.serviceAccountRole.annotations }}
annotations:
{{- toYaml .Values.serviceAccountRole.annotations | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["secrets", "configmaps"]
Expand All @@ -29,6 +37,10 @@ kind: RoleBinding
metadata:
name: {{ include "goquorum-genesis.name" . }}-rb
namespace: {{ .Release.Namespace }}
{{- if .Values.serviceAccountRoleBinding.annotations }}
annotations:
{{- toYaml .Values.serviceAccountRoleBinding.annotations | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -43,5 +55,3 @@ subjects:
{{- else }}
name: {{ include "goquorum-genesis.name" . }}-sa
{{- end}}


27 changes: 19 additions & 8 deletions helm/charts/goquorum-genesis/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
---
initJob:
annotations: {} # additional annotations to init job

serviceAccount:
annotations: {} # additional annotations for the service account

serviceAccountRole:
annotations: {} # additional annotations for the service account role

serviceAccountRoleBinding:
annotations: {} # additional annotations for the service account role binding

quorumFlags:
removeGenesisOnDelete: true

cluster:
provider: local # choose from: local | aws | azure
provider: local # choose from: local | aws | azure
cloudNativeServices: false # set to true to use Cloud Native Services (SecretsManager and IAM for AWS; KeyVault & Managed Identities for Azure)

aws:
Expand All @@ -29,21 +40,21 @@ rawGenesisConfig:
genesis:
config:
chainId: 1337
algorithm:
algorithm:
consensus: qbft # choose from: ibft | qbft | raft | clique
blockperiodseconds: 10
emptyBlockPeriod: 60
epochlength: 30000
requesttimeoutseconds: 20
nonce: '0x0'
gasLimit: '0x47b760'
difficulty: '0x1'
coinbase: '0x0000000000000000000000000000000000000000'
nonce: "0x0"
gasLimit: "0x47b760"
difficulty: "0x1"
coinbase: "0x0000000000000000000000000000000000000000"
blockchain:
nodes: # refers to validators/signers
nodes: # refers to validators/signers
generate: true
count: 4
accountPassword: 'password'
accountPassword: "password"

image:
repository: consensys/quorum-k8s-hooks
Expand Down
4 changes: 3 additions & 1 deletion helm/charts/goquorum-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ If release name contains chart name it will be used as a full name.
*/}}
{{- define "goquorum-node.fullname" -}}
{{- $name := default .Chart.Name -}}
{{- if contains $name .Release.Name -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" $name .Release.Name | trunc 63 | trimSuffix "-" -}}
Expand Down
9 changes: 9 additions & 0 deletions playground/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# HELM examples

This showcases examples using the helm charts with minikube.

## Usage

You can use the `*/deploy_flat.sh` script to deploy a network with just 4 validator nodes using multiple helm releases.

Alternatively, you can check out `*/deploy.sh` to examine an example that uses subcharts.
3 changes: 3 additions & 0 deletions playground/helm/goquorum/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
charts/besu*
charts/blockscout
charts/goquorum*
23 changes: 23 additions & 0 deletions playground/helm/goquorum/.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
*~
generated_config/
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
45 changes: 45 additions & 0 deletions playground/helm/goquorum/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: v1
version: 0.1.0
appVersion: 0.1.0
name: goquorum-minikube
description: Go Quorum nodes for a POA network
keywords:
- ethereum
- goquorum
- hyperledger
- enterprise
- blockchain
- pegasys
- consensys
home: https://besu.hyperledger.org
sources:
- https://github.com/hyperledger/besu
maintainers:
- name: Joshua Fernandes
email: [email protected]
icon: http://besu.hyperledger.org/en/latest/favicon.ico
dependencies:
- name: goquorum-genesis
repository: "file://charts/goquorum-genesis"
version: 0.1.0
alias: genesis
- name: goquorum-node
repository: "file://charts/goquorum-node"
version: 0.1.0
alias: validator-1
- name: goquorum-node
repository: "file://charts/goquorum-node"
version: 0.1.0
alias: validator-2
- name: goquorum-node
repository: "file://charts/goquorum-node"
version: 0.1.0
alias: validator-3
- name: goquorum-node
repository: "file://charts/goquorum-node"
version: 0.1.0
alias: validator-4
- name: explorer
repository: "file://charts/explorer"
version: 0.1.0
alias: explorer
16 changes: 16 additions & 0 deletions playground/helm/goquorum/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -e

rm -rf charts/goquorum-genesis
rm -rf charts/goquorum-node
rm -rf charts/blockscout

mkdir -p charts
cp -r ../../../helm/charts/goquorum-genesis charts/.
cp -r ../../../helm/charts/goquorum-node charts/.
cp -r ../../../helm/charts/explorer charts/.

helm dependency update

helm upgrade goquorum-minikube --install --create-namespace --namespace goquorum-minikube .
Loading