Skip to content

Commit

Permalink
feat: add hedera node explorer as a conditional sub chart (#275)
Browse files Browse the repository at this point in the history
Signed-off-by: Deepak Mishra <[email protected]>
Signed-off-by: Lenin Mehedy <[email protected]>
Co-authored-by: Lenin Mehedy <[email protected]>
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
2 people authored and jeromy-cannon committed Sep 14, 2023
1 parent 58c7bd9 commit 720b017
Show file tree
Hide file tree
Showing 14 changed files with 547 additions and 1 deletion.
6 changes: 6 additions & 0 deletions charts/hedera-network/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: tenant
repository: https://operator.min.io/
version: 5.0.6
digest: sha256:d1145f65bba0cb295b33e94b0fdc79d80bf06d22cf2606061d0c1462800d3ae7
generated: "2023-08-09T09:52:59.515466+10:00"
5 changes: 5 additions & 0 deletions charts/hedera-network/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ appVersion: "0.7.0"
kubeVersion: ">=1.25.0"

dependencies:
- name: hedera-explorer
version: 0.2.0
condition: cloud.minio.enable

- name: hedera-mirror
alias: hedera-mirror-node
version: 0.86.0
Expand All @@ -38,3 +42,4 @@ dependencies:
version: 5.0.7
repository: https://operator.min.io/
condition: cloud.minio.enable

9 changes: 9 additions & 0 deletions charts/hedera-network/charts/hedera-explorer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
appVersion: 23.8.0
description: Hedera Mirror Node Explorer for the Hedera Hashgraph DLT
home: https://github.com/hashgraph/hedera-mirror-node-explorer
name: hedera-explorer
sources:
- https://github.com/hashgraph/hedera-mirror-node-explorer
version: 0.2

20 changes: 20 additions & 0 deletions charts/hedera-network/charts/hedera-explorer/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Get the application URL by running these commands:

{{- if contains "NodePort" .Values.service.type }}

export NODE_PORT=$(kubectl get -n {{ include "hedera-explorer.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "hedera-explorer.fullname" . }})
export NODE_IP=$(kubectl get nodes -n {{ include "hedera-explorer.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
open http://${NODE_IP}:${NODE_PORT}

{{- else if contains "LoadBalancer" .Values.service.type }}

export SERVICE_IP=$(kubectl get svc -n {{ include "hedera-explorer.namespace" . }} {{ include "hedera-explorer.fullname" . }} -o jsonpath="{.items[0].status.loadBalancer.ingress[0].ip}")
open http://${SERVICE_IP}:{{ .Values.service.port }}

{{- else if contains "ClusterIP" .Values.service.type }}

export POD_NAME=$(kubectl get pods -n {{ include "hedera-explorer.namespace" . }} -l "app.kubernetes.io/name={{ include "hedera-explorer.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
open http://127.0.0.1:8080
kubectl -n {{ include "hedera-explorer.namespace" . }} port-forward $POD_NAME 8080:8080

{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "hedera-explorer.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "hedera-explorer.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "hedera-explorer.labels" -}}
{{ include "hedera-explorer.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: hedera-explorer
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
helm.sh/chart: {{ include "hedera-explorer.chart" . }}
{{- if .Values.labels }}
{{ toYaml .Values.labels }}
{{- end }}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
{{- define "hedera-explorer.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Namespace
*/}}
{{- define "hedera-explorer.namespace" -}}
{{- default .Release.Namespace .Values.global.namespaceOverride -}}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "hedera-explorer.selectorLabels" -}}
app.kubernetes.io/component: hedera-explorer
app.kubernetes.io/name: {{ include "hedera-explorer.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "hedera-explorer.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{- default (include "hedera-explorer.fullname" .) .Values.serviceAccount.name -}}
{{- else -}}
{{- default "default" .Values.serviceAccount.name -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hedera-explorer.fullname" . }}-config
annotations: {{ toYaml .Values.annotations | nindent 4 }}
labels: {{ include "hedera-explorer.labels" . | nindent 4 }}
namespace: {{ include "hedera-explorer.namespace" . }}
data:
nginx.conf: |
worker_processes 1;
error_log stderr warn;
pid /var/cache/nginx/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /app;
index index.html;
try_files $uri $uri/ /index.html;
}
location = /index.html {
root /app;
expires 30s;
}
{{- if .Values.proxyPass }}
{{- range $path, $backend := .Values.proxyPass }}
location {{ $path }} {
proxy_pass {{ $backend }};
}
{{- end }}
{{- end }}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
networks-config.json: {{ .Values.config | toJson }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations: {{ toYaml .Values.annotations | nindent 4 }}
labels: {{ include "hedera-explorer.labels" . | nindent 4 }}
name: {{ include "hedera-explorer.fullname" . }}
namespace: {{ include "hedera-explorer.namespace" . }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicas }}
{{- end }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
matchLabels: {{ include "hedera-explorer.selectorLabels" . | nindent 6 }}
strategy: {{ toYaml .Values.updateStrategy | nindent 4 }}
template:
metadata:
annotations: {{- tpl (.Values.podAnnotations | toYaml) $ | nindent 8 }}
labels: {{ include "hedera-explorer.selectorLabels" . | nindent 8 }}
spec:
affinity: {{ toYaml .Values.affinity | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
env:
{{- range $name, $value := .Values.env }}
- name: {{ $name }}
{{- if kindIs "string" $value }}
value: {{ tpl $value $ | quote }}
{{- else }}
{{- tpl (toYaml $value) $ | nindent 14 }}
{{- end }}
{{- end }}
envFrom: {{ tpl (toYaml .Values.envFrom) . | nindent 12 }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }}
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe: {{ toYaml .Values.readinessProbe | nindent 12 }}
resources: {{ toYaml .Values.resources | nindent 12 }}
securityContext: {{ toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- range $name, $config := . }}
- name: {{ $name }}
{{- toYaml $config | nindent 14 }}
{{- end }}
{{- end }}
imagePullSecrets: {{ toYaml .Values.image.pullSecrets | nindent 8 }}
nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
priorityClassName: {{ .Values.priorityClassName }}
securityContext: {{ toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccountName: {{ include "hedera-explorer.serviceAccountName" . }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
tolerations: {{ toYaml .Values.tolerations | nindent 8 }}
{{- with .Values.volumes }}
volumes:
{{- range $name, $config := . }}
- name: {{ $name }}
{{- tpl (toYaml $config) $ | nindent 10 }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/hedera-network/charts/hedera-explorer/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.autoscaling.enabled -}}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
labels: {{ include "hedera-explorer.labels" . | nindent 4 }}
name: {{ include "hedera-explorer.fullname" . }}
namespace: {{ include "hedera-explorer.namespace" . }}
spec:
behavior: {{ toYaml .Values.autoscaling.behavior | nindent 4 }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics: {{ tpl (toYaml .Values.autoscaling.metrics) . | nindent 4 }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "hedera-explorer.fullname" . }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "hedera-explorer.fullname" $ -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
{{- if .Values.ingress.annotations }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
labels: {{ include "hedera-explorer.labels" . | nindent 4 }}
name: {{ $fullName }}
namespace: {{ include "hedera-explorer.namespace" . }}
spec:
{{- with .Values.ingress.className }}
ingressClassName: {{ . }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | default .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $.Values.service.port }}
{{- end }}
{{- end }}
{{- with .Values.ingress.tls }}
tls:
{{- range . }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.podDisruptionBudget.enabled -}}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
labels: {{ include "hedera-explorer.labels" . | nindent 4 }}
name: {{ include "hedera-explorer.fullname" . }}
namespace: {{ include "hedera-explorer.namespace" . }}
spec:
{{- with .Values.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- with .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ . }}
{{- end }}
selector:
matchLabels: {{ include "hedera-explorer.selectorLabels" . | nindent 6 }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
annotations: {{ toYaml .Values.service.annotations | nindent 4 }}
labels: {{ include "hedera-explorer.labels" . | nindent 4 }}
name: {{ include "hedera-explorer.fullname" . }}
namespace: {{ include "hedera-explorer.namespace" . }}
spec:
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector: {{ include "hedera-explorer.selectorLabels" . | nindent 4 }}
type: {{ .Values.service.type }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels: {{ include "hedera-explorer.labels" . | nindent 4 }}
name: {{ include "hedera-explorer.serviceAccountName" . }}
namespace: {{ include "hedera-explorer.namespace" . }}
{{- end -}}
Loading

0 comments on commit 720b017

Please sign in to comment.