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

Add helm-charts for explorer-db & explorer #353

Open
wants to merge 6 commits into
base: main
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
68 changes: 68 additions & 0 deletions helm-charts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## Prerequisites

- Kubernetes 1.9+
- A running Hyperledger Fabric network on kubernetes.

## Installing the Chart

To install the chart with the release name `explorer`:

```bash
$ helm install explorer/ --name explorer
```

The command deploys the Blockchain Explorer & Explorer-DB on the Kubernetes cluster in the default configuration. The [Configuration](#configuration) section lists the parameters that can be configured during installation.

## Test the Chart

To test the chart with the release name `explorer`:

```bash
$ helm test explorer
```

The command tests the Blockchain Explorer & Explorer-DB on the Kubernetes cluster.

## Uninstalling the Chart

To uninstall/delete the `explorer` deployment:

```bash
$ helm delete explorer
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the Blockchain Explorer & Explorer-DB chart and default values.

| Parameter | Description | Default |
| --------------------------------- | ------------------------------------------------- | ------------------------- |
| `explorer.image.repository` | `explorer` image repository | `hyperledger/explorer` |
| `explorer.image.tag` | `explorer` image tag | `latest` |
| `explorer.username` | `explorer` username | ` ` |
| `explorer.password` | `explorer` password | ` ` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `db.image.repository` | `explorer-db` image repository | `hyperledger/explorer-db` |
| `db.image.tag` | `explorer-db` image tag | `latest` |
| `db.DATABASE_DATABASE` | `explorer-db` DATABASE_DATABASE name | ` ` |
| `db.DATABASE_USERNAME` | `explorer-db` DATABASE_USERNAME name | ` ` |
| `db.DATABASE_PASSWORD` | `explorer-db` DATABASE_PASSWORD name | ` ` |
| `explorer.service.port` | TCP port for requests to explorer | `8080` |
| `explorer.service.type` | K8S service type exposing ports, e.g. `ClusterIP` | `ClusterIP` |
| `explorer.ingress.enabled` | If true, Ingress will be created | `false` |
| `explorer.ingress.annotations` | Ingress annotations | `{}` |
| `explorer.ingress.path` | Ingress path | `/` |
| `explorer.ingress.hosts` | Ingress hostnames | ` ` |
| `db.service.port` | TCP port for requests to explorer-db | `5432` |
| `db.service.type` | K8S service type exposing ports, e.g. `ClusterIP` | `ClusterIP` |
| `resources` | CPU/Memory resource requests/limits | `{}` |
| `replicaCount` | Replicacount of pods | `1` |
| `network.channel` | HLF network channel name | ` ` |
| `network.mspid` | HLF network peer org mspid | ` ` |
| `network.peername` | HLF network peername | ` ` |
| `network.peerurl` | HLF network peerurl | ` ` |
| `network.adminPrivateKey` | HLF network peer adminPrivateKey | ` ` |
| `network.signedCert` | HLF network peer signedCert | ` ` |
| `network.tlsCACerts` | HLF network peer tlsCACerts | ` ` |
23 changes: 23 additions & 0 deletions helm-charts/explorer/.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/
20 changes: 20 additions & 0 deletions helm-charts/explorer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v2
name: blockchain-explorer
description: A Helm chart for blockchain explorer

type: application

version: 0.1.0

appVersion: "1.16.0"

keywords:
- blockchain
- hyperledger
- explorer
- explorer-db

sources:
- https://github.com/hyperledger-labs/blockchain-explorer


87 changes: 87 additions & 0 deletions helm-charts/explorer/templates/explorer-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: explorer-config
namespace: {{ $.Values.namespace }}
labels:
name: {{ .Release.Name }}-app
app.kubernetes.io/name: {{ .Release.Name }}-app
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
annotations:
{{- toYaml .Values.annotations | nindent 6 }}
data:

fabric-network.json: |-
{
"name": "fabric-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "{{ .Values.explorer.username | default "exploreradmin"}}",
"password": "{{ .Values.explorer.password | default "exploreradminpw"}}"
},
"enableAuthentication": true,
"organization": "{{ .Values.network.mspid}}",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"{{ .Values.network.channel}}": {
"peers": {
"{{ .Values.network.peername}}": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
Copy link
Member

Choose a reason for hiding this comment

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

Something to improve upon later: One instance of Explorer can be used for multiple organizations. There can be a different user login session seeing altogether a different network configuration. This section shall be more flexible to handle that.

"{{ .Values.network.mspid}}": {
"mspid": "{{ .Values.network.mspid}}",
"adminPrivateKey": {
"path": "/etc/adminprivatekey/adminPrivateKey.pem"

},
"peers": [
"{{ .Values.network.peername}}"
],
"signedCert": {
"path": "/etc/signedcert/signedCert.pem"
}
}
},
"peers": {
"{{ .Values.network.peername}}": {
"tlsCACerts": {
"path": "/etc/tlscacerts/tlsCACerts.pem"
},
"url": "{{ .Values.network.peerurl}}"
}
}
}

config.json: |-
{
"network-configs": {
"fabric-network": {
"name": "fabric-network",
"profile": "./fabric-network.json"
}
},
"license": "Apache-2.0"
}
56 changes: 56 additions & 0 deletions helm-charts/explorer/templates/explorer-db-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-db
namespace: {{ $.Values.namespace }}
labels:
name: {{ .Release.Name }}-db
app.kubernetes.io/name: {{ .Release.Name }}-db
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
annotations:
{{- toYaml .Values.annotations | nindent 6 }}
spec:
serviceName: {{ .Release.Name }}-db
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-db
app.kubernetes.io/name: {{ .Release.Name }}-db
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}-db
app.kubernetes.io/name: {{ .Release.Name }}-db
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.db.image.repository }}:{{ .Values.db.image.tag }}"
imagePullPolicy: {{ .Values.pullPolicy }}
envFrom:
- secretRef:
name: explorer-db-env
resources:
{{- toYaml .Values.resources | nindent 12 }}

ports:
- containerPort: {{ .Values.db.service.port | default 5432 }}
volumeMounts:
- name: {{ .Release.Name }}-db
mountPath: /var/lib/postgresql/data

volumeClaimTemplates:
- metadata:
name: {{ .Release.Name }}-db
spec:
storageClassName: {{ .Values.db.storage.class | default "standard" | quote }}
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.db.storage.capacity | default "5Gi" }}

20 changes: 20 additions & 0 deletions helm-charts/explorer/templates/explorer-db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-db
namespace: {{ $.Values.namespace }}
labels:
name: {{ .Release.Name }}-db
app.kubernetes.io/name: {{ .Release.Name }}-db
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
annotations:
{{- toYaml .Values.annotations | nindent 6 }}
spec:
type: {{ .Values.db.service.type }}
selector:
app: {{ .Release.Name }}-db
ports:
- port: {{ .Values.db.service.port | default 5432 }}
targetPort: {{ .Values.db.service.port | default 5432 }}
75 changes: 75 additions & 0 deletions helm-charts/explorer/templates/explorer-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-app
namespace: {{ $.Values.namespace }}
labels:
name: {{ .Release.Name }}-app
app.kubernetes.io/name: {{ .Release.Name }}-app
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
annotations:
{{- toYaml .Values.annotations | nindent 6 }}

spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-app
app.kubernetes.io/name: {{ .Release.Name }}-app
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}-app
app.kubernetes.io/name: {{ .Release.Name }}-app
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
volumes:
- name: explorer-config
configMap:
name: explorer-config
items:
- key: config.json
path: config.json
- key: fabric-network.json
path: fabric-network.json
- name: config-adminprivatekey
secret:
secretName: adminprivatekey
- name: config-signedcert
secret:
secretName: signedcert
- name: config-tlscacerts
secret:
secretName: tlscacerts

containers:
- name: {{ .Release.Name }}-app
image: "{{ .Values.explorer.image.repository }}:{{ .Values.explorer.image.tag }}"
imagePullPolicy: {{ .Values.pullPolicy }}
envFrom:
- secretRef:
name: explorer-env
resources:
{{- toYaml .Values.resources | nindent 12 }}

ports:
- containerPort: {{ .Values.explorer.service.port | default (8080) }}

volumeMounts:
- mountPath: /opt/explorer/app/platform/fabric/config.json
name: explorer-config
subPath: config.json
- mountPath: /opt/explorer/app/platform/fabric/fabric-network.json
name: explorer-config
subPath: fabric-network.json
- name: config-adminprivatekey
mountPath: /etc/adminprivatekey
- name: config-signedcert
mountPath: /etc/signedcert
- name: config-tlscacerts
mountPath: /etc/tlscacerts
29 changes: 29 additions & 0 deletions helm-charts/explorer/templates/explorer-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

{{- if .Values.explorer.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}-app-ingress
namespace: {{ $.Values.namespace }}
labels:
name: {{ .Release.Name }}-app
app.kubernetes.io/name: {{ .Release.Name }}-app
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
annotations: {{- toYaml .Values.explorer.ingress.annotations | nindent 6 }}

spec:

rules:
- host: {{ .Values.explorer.ingress.hosts }}
http:
paths:
- backend:
service:
name: {{ .Release.Name }}-app
port:
number: {{ .Values.explorer.service.port | default 8080 }}
path: {{ .Values.explorer.ingress.path | default ("/")}}
pathType: Prefix
{{- end }}
Loading