Skip to content

Commit

Permalink
changed alias for kube-prometheus-stack to kubepromstack since on the…
Browse files Browse the repository at this point in the history
… templates is not allowed char '-' and on the servicemonitor metadata was not allowed capital cases.

Simpliefied the NOTES.txt to always use the service and also to include the grafana when the kubepromstack is enabled.

Added a conditional value to kube-prometheus-stack to only deploy if kubepromstack.enabled is set to true

further simplified and added new dashboard for pod stats.

Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Nov 21, 2024
1 parent ed83bf9 commit 40330ab
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 23 deletions.
2 changes: 2 additions & 0 deletions charts/hedera-block-node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ sources:
version: 0.3.0-SNAPSHOT
dependencies:
- name: kube-prometheus-stack
alias: kubepromstack
condition: kubePrometheusStack.enabled
version: "51.2.0" # Use the latest stable version
repository: "https://prometheus-community.github.io/helm-charts"
18 changes: 17 additions & 1 deletion charts/hedera-block-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ Installs the Hedera Block Node on a Kubernetes cluster.
- Helm 3+
- Kubernetes 1.29+

Set environment variables that will be used for the remainder of the document:
For Development and Test environment is recommended to use minikube with the following command (if want to deploy the kube-prometheus-stack for metrics visualization):
```bash
minikube delete && minikube start --kubernetes-version=v1.23.0 --memory=6g --bootstrapper=kubeadm --extra-config=kubelet.authentication-token-webhook=true --extra-config=kubelet.authorization-mode=Webhook --extra-config=scheduler.bind-address=0.0.0.0 --extra-config=controller-manager.bind-address=0.0.0.0
```

Set environment variables that will be used for the remainder of the document:
```bash
export RELEASE="bn1"
```
Expand Down Expand Up @@ -56,6 +60,18 @@ or passed at the command line:
helm install "${RELEASE}" hedera-block-node/hedera-block-node --set blockNode.secret.PRIVATE_KEY="<Secret>"
```

### Enable Prometheus + Grafana Stack
By default the stack includes a chart dependency that includes a prometheus + grafana + node-exporter stack, also adds 3 provisioned dashboards
- **Hedera Block Node Dashboard:** to monitor the Hedera Block Node metrics, this are the server application specific metrics.
- **Node Exporter Full:** to monitor the node-exporter metrics, system metrics at the K8 cluster/node level.
- **Kubernetes View Pods:** to monitor the kubernetes pods metrics, system metrics at the container level.

If you prefer to use your own prometheus+grafana stack, you can disable the stack by setting the following values:
```yaml
kube-prometheus-stack:
enabled: false
```
## Using
Follow the `NOTES` instructions after installing the chart to perform `port-forward` to the Hedera Block Node and be able to use it.

Expand Down
39 changes: 18 additions & 21 deletions charts/hedera-block-node/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "hedera-block-node.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "hedera-block-node.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "hedera-block-node.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "hedera-block-node.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
1. **Get the application URL** by running the following commands:

```bash
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{.Release.Name}}-hedera-block-node 8080:{{ .Values.service.port }}
echo "Visit http://127.0.0.1:8080 to use your application"
```

{{- if .Values.kubepromstack.enabled }}


2. **Access Grafana** by mapping the service port:

```bash
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{.Release.Name}}-grafana 3000:80
echo "Grafana is accessible at http://localhost:3000"
```

**Note**: This command forwards your local port `3000` to Grafana's port `80`. Ensure that port `3000` is free on your local machine or choose another available port if necessary.
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ if .Values.kubepromstack.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -8,3 +9,5 @@ data:
block-node-dashboard.json: {{ .Files.Get "dashboards/block-node-server.json" | quote }}
node-exporter-dashboard.json: {{ .Files.Get "dashboards/node-exporter-full.json" | quote }}
kubernetes-views-pods.json : {{ .Files.Get "dashboards/kubernetes-views-pods.json" | quote }}

{{- end }}
3 changes: 3 additions & 0 deletions charts/hedera-block-node/templates/grafana-datasource.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ if .Values.kubepromstack.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -16,3 +17,5 @@ data:
editable: true
jsonData:
timeInterval: "15s"
{{- end }}
3 changes: 3 additions & 0 deletions charts/hedera-block-node/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ if .Values.kubepromstack.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand All @@ -16,3 +17,5 @@ spec:
endpoints:
- port: metrics
interval: 15s

{{- end }}
3 changes: 2 additions & 1 deletion charts/hedera-block-node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ blockNode:
metrics:
port: 9999

kube-prometheus-stack:
kubepromstack:
enabled: true
prometheusOperator:
namespaces:
releaseNamespace: true
Expand Down

0 comments on commit 40330ab

Please sign in to comment.