Skip to content

Commit 20c9872

Browse files
committed
create explorer
1 parent 0881368 commit 20c9872

20 files changed

+1007
-0
lines changed

explorer/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

explorer/Chart.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v2
2+
appVersion: 1.16.0
3+
description: A Helm chart for Kubernetes
4+
maintainers:
5+
- email: devops@bc-labs.net
6+
name: InfraBlockchain
7+
url: https://github.com/InfraBlockchain/helm-charts
8+
name: explorer
9+
type: application
10+
version: 0.1.0

explorer/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Explorer Helm Chart
2+
3+
The helm chart installs the [Infrablockspace](https://github.com/InfraBlockchain/infrablockspace-sdk).
4+
5+
![Version: 1.0.4](https://img.shields.io/badge/Version-1.0.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
6+
7+
## Maintainers
8+
9+
| Name | Email | Url |
10+
| ---- | ------ | --- |
11+
| devops | <devops@bc-labs.net> | <https://github.com/InfraBlockspace/helm-charts> |
12+
13+
## Installing the chart
14+
15+
```console
16+
helm repo add infrablockchain https://infrablockchain.github.io/helm-charts/
17+
helm install explorer infrablockchain/explorer
18+
```
19+
20+
21+
## Values
22+
23+
| Key | Type | Default | Description |
24+
|-----|------|---------|-------------|
25+
| affinity | object | `{}` | |
26+
| autoscaling.enabled | bool | `false` | |
27+
| autoscaling.maxReplicas | int | `100` | |
28+
| autoscaling.minReplicas | int | `1` | |
29+
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
30+
| fullnameOverride | string | `""` | |
31+
| image.pullPolicy | string | `"IfNotPresent"` | |
32+
| image.tag | string | `"1"` | |
33+
| imagePullSecrets | list | `[]` | |
34+
| ingress.annotations | object | `{}` | |
35+
| ingress.className | string | `""` | |
36+
| ingress.enabled | bool | `false` | |
37+
| ingress.hosts[0].host | string | `"chart-example.local"` | |
38+
| ingress.hosts[0].paths[0].path | string | `"/"` | |
39+
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
40+
| ingress.tls | list | `[]` | |
41+
| nameOverride | string | `""` | |
42+
| nodeSelector | object | `{}` | |
43+
| podAnnotations | object | `{}` | |
44+
| podSecurityContext | object | `{}` | |
45+
| reader.config.api.blockLimit | int | `50000` | |
46+
| reader.config.api.db.name | string | `""` | |
47+
| reader.config.api.nodeId | int | `1000` | |
48+
| reader.config.api.redisUrl | string | `"redis://localhost:6679"` | |
49+
| reader.config.api.sentry.dsn | string | `""` | |
50+
| reader.config.api.sentry.name | string | `""` | |
51+
| reader.config.api.sentry.server | string | `""` | |
52+
| reader.config.configMapRef | string | `""` | |
53+
| reader.config.db.connection | string | `""` | |
54+
| reader.config.db.database | string | `""` | |
55+
| reader.config.db.harvesterName | string | `""` | |
56+
| reader.config.db.host | string | `""` | |
57+
| reader.config.db.password | string | `""` | |
58+
| reader.config.db.port | string | `""` | |
59+
| reader.config.db.sqlaUrl | string | `""` | |
60+
| reader.config.db.username | string | `""` | |
61+
| reader.config.dbConfigMapRef | string | `""` | |
62+
| reader.config.enable | bool | `true` | |
63+
| reader.config.harvester.blockStart | string | `"0"` | |
64+
| reader.config.harvester.db.InstalledEtl | string | `""` | |
65+
| reader.config.harvester.db.name | string | `""` | |
66+
| reader.config.harvester.substrate.SS58Format | string | `nil` | |
67+
| reader.config.harvester.substrate.url | string | `"ws://localhost:9944"` | |
68+
| reader.config.secretDBRef | string | `""` | |
69+
| replicaCount | int | `1` | |
70+
| resources | object | `{}` | |
71+
| securityContext | object | `{}` | |
72+
| service.port | int | `80` | |
73+
| service.type | string | `"ClusterIP"` | |
74+
| serviceAccount.annotations | object | `{}` | |
75+
| serviceAccount.create | bool | `true` | |
76+
| serviceAccount.name | string | `""` | |
77+
| tolerations | list | `[]` | |
78+
| ui.affinity | object | `{}` | |
79+
| ui.autoscaling.enabled | bool | `false` | |
80+
| ui.autoscaling.maxReplicas | int | `100` | |
81+
| ui.autoscaling.minReplicas | int | `1` | |
82+
| ui.autoscaling.targetCPUUtilizationPercentage | int | `80` | |
83+
| ui.config.data | string | `"{\n \"InfraRelay\": {\n \"relayChain\": \"InfraRelay\",\n \"image\": \"infra-relay.png\",\n \"substrateRpcUrlArray\": [\n \"wss://relay.stage.infrablockspace.net\"\n ],\n \"explorerWsUrlArray\": [\n \"wss://explorer-api.stage.infrablockspace.net/graphql-ws\"\n ]\n }\n}"` | |
84+
| ui.config.generate | bool | `true` | |
85+
| ui.enable | bool | `false` | |
86+
| ui.image.tag | int | `3` | |
87+
| ui.ingress.annotations | object | `{}` | |
88+
| ui.ingress.className | string | `""` | |
89+
| ui.ingress.enabled | bool | `false` | |
90+
| ui.ingress.hosts[0].host | string | `"chart-example.local"` | |
91+
| ui.ingress.hosts[0].paths[0].path | string | `"/"` | |
92+
| ui.ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
93+
| ui.ingress.tls | list | `[]` | |
94+
| ui.nodeSelector | object | `{}` | |
95+
| ui.resources | object | `{}` | |
96+
| ui.service.port | int | `80` | |
97+
| ui.service.type | string | `"ClusterIP"` | |
98+
| ui.tolerations | list | `[]` | |
99+
100+
----------------------------------------------
101+
Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3)

explorer/README.md.gotmpl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Explorer Helm Chart
2+
3+
The helm chart installs the [Infrablockspace](https://github.com/InfraBlockchain/infrablockspace-sdk).
4+
5+
![Version: 1.0.4](https://img.shields.io/badge/Version-1.0.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
6+
7+
## Maintainers
8+
9+
| Name | Email | Url |
10+
| ---- | ------ | --- |
11+
| devops | <devops@bc-labs.net> | <https://github.com/InfraBlockspace/helm-charts> |
12+
13+
## Installing the chart
14+
15+
16+
```console
17+
helm repo add infrablockchain https://infrablockchain.github.io/helm-charts/
18+
helm install explorer infrablockchain/explorer
19+
```
20+
21+
22+
{{ template "chart.requirementsSection" . }}
23+
24+
{{ template "chart.valuesSection" . }}
25+
26+
{{ template "helm-docs.versionFooter" . }}

explorer/templates/NOTES.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "explorer.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "explorer.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "explorer.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "explorer.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}

explorer/templates/_helpers.tpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "explorer.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "explorer.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "explorer.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "explorer.labels" -}}
37+
helm.sh/chart: {{ include "explorer.chart" . }}
38+
{{ include "explorer.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "explorer.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "explorer.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "explorer.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "explorer.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

explorer/templates/api.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Release.Name }}-api
5+
labels:
6+
{{- include "explorer.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: api
8+
spec:
9+
{{- if not .Values.autoscaling.enabled }}
10+
replicas: {{ .Values.replicaCount }}
11+
{{- end }}
12+
selector:
13+
matchLabels:
14+
{{- include "explorer.selectorLabels" . | nindent 6 }}
15+
app: {{ .Release.Name }}-api
16+
template:
17+
metadata:
18+
{{- with .Values.podAnnotations }}
19+
annotations:
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
labels:
23+
{{- include "explorer.selectorLabels" . | nindent 8 }}
24+
app: {{ .Release.Name }}-api
25+
spec:
26+
{{- with .Values.imagePullSecrets }}
27+
imagePullSecrets:
28+
{{- toYaml . | nindent 8 }}
29+
{{- end }}
30+
serviceAccountName: {{ include "explorer.serviceAccountName" . }}
31+
{{- with .Values.podSecurityContext }}
32+
securityContext:
33+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
34+
{{- end }}
35+
containers:
36+
- name: api
37+
{{- with .Values.securityContext }}
38+
securityContext:
39+
{{- toYaml .Values.securityContext | nindent 12 }}
40+
{{- end }}
41+
image: "069134836620.dkr.ecr.ap-northeast-2.amazonaws.com/dev-explorer-api:{{ .Values.image.apiTag | default 3}}"
42+
command:
43+
- /bin/bash
44+
- -c
45+
- |
46+
{{- if or (eq .Values.reader.config.db.username "root") (eq .Values.reader.config.db.username "admin") }}
47+
/usr/src/start-api.sh
48+
{{- else }}
49+
alembic upgrade head
50+
python app/import_assets.py
51+
exec uvicorn --host 0.0.0.0 --port 8000 --log-level info "app.main:app" --forwarded-allow-ips='*' --proxy-headers
52+
{{- end }}
53+
envFrom:
54+
{{ if eq .Values.reader.config.enable true}}
55+
- secretRef:
56+
name: {{ .Release.Name }}-explorer-db-secret
57+
- configMapRef:
58+
name: {{ .Release.Name }}-explorer-api-config
59+
- configMapRef:
60+
name: {{ .Release.Name }}-explorer-db-config
61+
{{- else}}
62+
- secretRef:
63+
name: {{.Values.reader.config.secretDBRef}}
64+
- configMapRef:
65+
name: {{.Values.reader.config.configMapRef}}
66+
- configMapRef:
67+
name: {{.Values.reader.config.dbConfigMapRef}}
68+
{{- end }}
69+
imagePullPolicy: {{ .Values.image.pullPolicy }}
70+
{{- with .Values.podLifecycle }}
71+
livenessProbe:
72+
httpGet:
73+
path: {{ .Values.podLifecycle.livenessProbe.path | default "/"}}
74+
port: 8000
75+
readinessProbe:
76+
httpGet:
77+
path: {{ .Values.podLifecycle.readinessProbe.path | default "/"}}
78+
port: 8000
79+
{{- end}}
80+
resources:
81+
{{- toYaml .Values.resources | nindent 12 }}
82+
{{- with .Values.nodeSelector }}
83+
nodeSelector:
84+
{{- toYaml . | nindent 8 }}
85+
{{- end }}
86+
{{- with .Values.affinity }}
87+
affinity:
88+
{{- toYaml . | nindent 8 }}
89+
{{- end }}
90+
{{- with .Values.tolerations }}
91+
tolerations:
92+
{{- toYaml . | nindent 8 }}
93+
{{- end }}

explorer/templates/configMap.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- if eq .Values.reader.config.enable true }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ .Release.Name }}-explorer-db-config
6+
namespace: explorer
7+
labels:
8+
app: {{ .Release.Name }}-explorer-db-config
9+
data:
10+
DB_USERNAME: {{.Values.reader.config.db.username}}
11+
DB_HOST: {{.Values.reader.config.db.host}}
12+
DB_PORT: {{.Values.reader.config.db.port | quote}}
13+
DB_HARVESTER_NAME: {{.Values.reader.config.db.harvesterName}}
14+
---
15+
apiVersion: v1
16+
kind: ConfigMap
17+
metadata:
18+
name: {{ .Release.Name }}-explorer-api-config
19+
labels:
20+
app: {{ .Release.Name }}-explorer-api-config
21+
data:
22+
DOMAIN: root
23+
SERVER_ADDR: 0.0.0.0
24+
SERVER_PORT: "8000"
25+
WEBSOCKET_URI: ws://0.0.0.0:8000
26+
BACKEND_CORS_ORIGINS: "[]"
27+
BROADCAST_URI: {{ default "redis://redis:6379" .Values.reader.config.api.redisUrl }}
28+
CHAIN_ID: {{default "default" .Values.reader.config.api.nodeId }}
29+
BLOCK_LIMIT_COUNT: {{ default "50000" .Values.reader.config.api.blockLimit | quote}}
30+
DB_NAME: {{ default "infrablockspace" .Values.reader.config.api.db.name }}
31+
SENTRY_PROJECT_NAME: {{default "" .Values.reader.config.api.sentry.name }}
32+
SENTRY_SERVER_NAME: {{ default "" .Values.reader.config.api.sentry.server }}
33+
SENTRY_DSN: {{default "" .Values.reader.config.api.sentry.dsn }}
34+
---
35+
apiVersion: v1
36+
kind: ConfigMap
37+
metadata:
38+
name: {{ .Release.Name }}-explorer-harvester-config
39+
labels:
40+
app: {{ .Release.Name }}-explorer-harvester-config
41+
data:
42+
SUBSTRATE_RPC_URL: {{default "ws://localhost:9944" .Values.reader.config.harvester.substrate.url }}
43+
NODE_TYPE: archive
44+
SUBSTRATE_SS58_FORMAT: {{ default "42" .Values.reader.config.harvester.substrate.SS58Format | quote}}
45+
BLOCK_START: {{ default "0" .Values.reader.config.harvester.blockStart | quote }}
46+
INSTALLED_ETL_DATABASES: {{ default "" .Values.reader.config.harvester.db.InstalledEtl }}
47+
DB_NAME: {{ default "" .Values.reader.config.harvester.db.name }}
48+
CUSTOM_TYPE_REGISTRY: |
49+
{"types":{"VoteAccountId":"AccountId32","SystemTokenId":{"type":"struct","type_mapping":[["para_id","Compact<u32>"],["pallet_id","Compact<u8>"],["asset_id","Compact<u32>"]]},"runtime_common::pallet_system_token_tx_payment::ChargeSystemToken":{"type":"struct","type_mapping":[["tip","Compact<Balance>"],["system_token_id","Option<SystemTokenId>"],["vote_candidate","Option<VoteAccountId>"]]}}}
50+
{{- end}}

0 commit comments

Comments
 (0)