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 10 commits into
base: master
Choose a base branch
from
Open
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: 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
4 changes: 3 additions & 1 deletion helm/charts/besu-genesis/templates/genesis-job-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ 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
completions: 1
Expand Down
12 changes: 12 additions & 0 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,6 +19,10 @@ 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"]
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 Down
12 changes: 12 additions & 0 deletions helm/charts/besu-genesis/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
---

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

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
71 changes: 0 additions & 71 deletions helm/charts/besu-node/templates/node-storage.yaml

This file was deleted.

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
10 changes: 10 additions & 0 deletions playground/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# HELM examples

This showcases examples using the helm charts with minikube.


## Usage

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

Alternatively, you can check out `quorum-besu/deploy.sh` to examine an example that uses subcharts.
2 changes: 2 additions & 0 deletions playground/helm/quorum-besu/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
charts/besu*
charts/blockscout
23 changes: 23 additions & 0 deletions playground/helm/quorum-besu/.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/
46 changes: 46 additions & 0 deletions playground/helm/quorum-besu/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
version: 0.1.0
appVersion: 0.1.0
name: besu-minikube
description: Besu nodes for a POA network
keywords:
- ethereum
- besu
- 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: besu-genesis
repository: "file://charts/besu-genesis"
version: 0.1.0
alias: genesis
- name: besu-node
repository: "file://charts/besu-node"
version: 0.1.0
alias: validator-1
- name: besu-node
repository: "file://charts/besu-node"
version: 0.1.0
alias: validator-2
- name: besu-node
repository: "file://charts/besu-node"
version: 0.1.0
alias: validator-3
- name: besu-node
repository: "file://charts/besu-node"
version: 0.1.0
alias: validator-4
- name: blockscout
repository: "file://charts/blockscout"
version: 0.1.0
alias: blockscout

16 changes: 16 additions & 0 deletions playground/helm/quorum-besu/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/besu-genesis
rm -rf charts/besu-node
rm -rf charts/blockscout

mkdir -p charts
cp -r ../../../helm/charts/besu-genesis charts/.
cp -r ../../../helm/charts/besu-node charts/.
cp -r ../../../helm/charts/blockscout charts/.

helm dependency update

helm upgrade besu-minikube --install --create-namespace --namespace besu-minikube .
15 changes: 15 additions & 0 deletions playground/helm/quorum-besu/deploy_flat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

helm upgrade genesis --install --namespace besu-minikube --create-namespace \
--values deploy_flat_values.yaml ../../../helm/charts/besu-genesis
helm upgrade validator-1 --install --namespace besu-minikube ../../../helm/charts/besu-node
helm upgrade validator-2 --install --namespace besu-minikube ../../../helm/charts/besu-node
helm upgrade validator-3 --install --namespace besu-minikube ../../../helm/charts/besu-node
helm upgrade validator-4 --install --namespace besu-minikube ../../../helm/charts/besu-node
helm dependency update ../../../helm/charts/besu-node
helm upgrade blockscout --install --namespace besu-minikube \
--set blockscout.ethereum_jsonrpc_endpoint="besu-node-validator-1" \
../../../helm/charts/blockscout
kubectl apply --namespace besu-minikube -f templates/ingress.yaml
23 changes: 23 additions & 0 deletions playground/helm/quorum-besu/deploy_flat_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
rawGenesisConfig:
genesis:
includeQuickStartAccounts: "false"

serviceAccountRole:
annotations:
helm.sh/hook: pre-install,pre-delete,post-delete
helm.sh/hook-weight: "-2"

serviceAccountRoleBinding:
annotations:
helm.sh/hook: pre-install,pre-delete,post-delete
helm.sh/hook-weight: "-1"

serviceAccount:
annotations:
helm.sh/hook: pre-install,pre-delete,post-delete
helm.sh/hook-weight: "-1"

initJob:
annotations:
helm.sh/hook: pre-install
helm.sh/hook-weight: "0"
18 changes: 18 additions & 0 deletions playground/helm/quorum-besu/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: besu-ingress
spec:
ingressClassName: nginx
rules:
- host: blockscout.test
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: blockscout
port:
number: 4000
Loading