From 41f6efc636e732a42898648408631496eabe09fb Mon Sep 17 00:00:00 2001 From: David Blane Date: Sat, 5 Mar 2022 20:53:58 +0000 Subject: [PATCH 01/13] WIP pruning --- charts/node/templates/_helpers.tpl | 6 ++++++ charts/node/templates/statefulset.yaml | 7 +++++++ charts/node/values.yaml | 1 + 3 files changed, 14 insertions(+) diff --git a/charts/node/templates/_helpers.tpl b/charts/node/templates/_helpers.tpl index 5a80a0b5..b5d2c7d8 100644 --- a/charts/node/templates/_helpers.tpl +++ b/charts/node/templates/_helpers.tpl @@ -43,6 +43,12 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} chain: {{ .Values.node.chain }} role: {{ .Values.node.role }} +{{- if .Values.node.pruning }} +pruning: {{ .Values.node.pruning }} +{{- if or (eq .Values.node.role "authority") (eq .Values.node.role "validator") }} +unsafe-pruning: true +{{- end }} +{{- end }} {{- with .Values.extraLabels }} {{ toYaml . }} {{- end }} diff --git a/charts/node/templates/statefulset.yaml b/charts/node/templates/statefulset.yaml index e02743a9..d4f24ee1 100644 --- a/charts/node/templates/statefulset.yaml +++ b/charts/node/templates/statefulset.yaml @@ -264,6 +264,13 @@ spec: --chain={{ if .Values.node.customChainspecUrl }}{{ .Values.node.customChainspecPath }}{{ else }}${CHAIN}{{ end }} \ {{- if or (eq .Values.node.role "authority") (eq .Values.node.role "validator") }} --validator \ + {{- if .Values.node.pruning }} + --unsafe-pruning \ + --pruning {{ .Values.node.pruning }} \ + {{- end }} + {{- end }} + {{- if and (eq .Values.node.role "full") .Values.node.pruning }} + --pruning {{ .Values.node.pruning }} \ {{- end }} {{- if eq .Values.node.role "collator" }} --collator \ diff --git a/charts/node/values.yaml b/charts/node/values.yaml index c66ca356..bf30620c 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -98,6 +98,7 @@ node: # seed: "//Alice//babe" persistGeneratedNodeKey: false #customNodeKey: "" + # pruning: 1000 resources: {} serviceMonitor: enabled: false From ebea0a14136b45ef0356ebcf9628d4bc5eaa0a8c Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Mon, 7 Mar 2022 17:51:11 +0800 Subject: [PATCH 02/13] Include extra labels for service monitor --- charts/node/Chart.yaml | 2 +- charts/node/templates/serviceMonitor.yaml | 7 ++++--- charts/node/values.yaml | 7 +++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/charts/node/Chart.yaml b/charts/node/Chart.yaml index 08543c62..d1ed0ed7 100644 --- a/charts/node/Chart.yaml +++ b/charts/node/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: node description: A Helm chart to deploy Substrate/Polkadot nodes type: application -version: 1.2.0 +version: 1.2.1 appVersion: "0.0.1" diff --git a/charts/node/templates/serviceMonitor.yaml b/charts/node/templates/serviceMonitor.yaml index 3265d743..3cfebdf9 100644 --- a/charts/node/templates/serviceMonitor.yaml +++ b/charts/node/templates/serviceMonitor.yaml @@ -28,7 +28,8 @@ spec: namespaceSelector: matchNames: - {{ $.Release.Namespace }} + {{- with $.Values.node.serviceMonitor.targetLabels }} targetLabels: - - chain - - instance -{{- end }} + {{ toYaml .| nindent 4 }} + {{- end}} +{{- end }} \ No newline at end of file diff --git a/charts/node/values.yaml b/charts/node/values.yaml index c66ca356..ce86ee5f 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -102,8 +102,11 @@ node: serviceMonitor: enabled: false #namespace: monitoring - #interval: 10s - # scrapeTimeout: 10s + interval: 1m + scrapeTimeout: 30s + targetLabels: + - chain + - instance perNodeServices: createClusterIPService: true createP2pNodePortService: false From 609b618fa6ffcd3aaf7eb776d34743d53c29e649 Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Mon, 7 Mar 2022 20:51:46 +0800 Subject: [PATCH 03/13] Replaced instance by node --- charts/node/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/node/values.yaml b/charts/node/values.yaml index ce86ee5f..b33c2935 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -106,7 +106,7 @@ node: scrapeTimeout: 30s targetLabels: - chain - - instance + - node perNodeServices: createClusterIPService: true createP2pNodePortService: false @@ -164,4 +164,4 @@ affinity: {} storageClass: "default" -extraContainers: [] \ No newline at end of file +extraContainers: [] From de9e0a3e528831a56b99b7983d0efaa5ae42c22f Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Tue, 8 Mar 2022 11:25:53 +0800 Subject: [PATCH 04/13] Added honorlabels in servicemonitor --- charts/node/README.md | 1 + charts/node/templates/serviceMonitor.yaml | 1 + charts/node/values.yaml | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/node/README.md b/charts/node/README.md index 142daeda..a78184fd 100644 --- a/charts/node/README.md +++ b/charts/node/README.md @@ -73,6 +73,7 @@ helm install kusama-node parity/node --set node.chainDataSnapshotUrl=https://ksm | `node.serviceMonitor.namespace` | Prometheus namespace | `nil` | | `node.serviceMonitor.internal` | Prometheus scrape interval | `nil` | | `node.serviceMonitor.scrapeTimeout` | Prometheus scrape timeout | `nil` | +| `node.serviceMonitor.targetLabels` | transfers labels on the Kubernetes Pod onto service monitor | `[nodes]` | | `node.tracing.enabled` | If true, creates a jaeger agent sidecar | `false` | | `node.subtrateApiSiecar.enabled` | If true, creates a substrate api sidecar | `false` | | `node.perNodeServices.createClusterIPService` | If true creates a clusterIP API service | `true` | diff --git a/charts/node/templates/serviceMonitor.yaml b/charts/node/templates/serviceMonitor.yaml index 3cfebdf9..309a4788 100644 --- a/charts/node/templates/serviceMonitor.yaml +++ b/charts/node/templates/serviceMonitor.yaml @@ -24,6 +24,7 @@ spec: {{- end }} {{- if $.Values.node.serviceMonitor.scrapeTimeout }} scrapeTimeout: {{ $.Values.node.serviceMonitor.scrapeTimeout }} + honorLabels: true {{- end }} namespaceSelector: matchNames: diff --git a/charts/node/values.yaml b/charts/node/values.yaml index b33c2935..73c36156 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -105,7 +105,6 @@ node: interval: 1m scrapeTimeout: 30s targetLabels: - - chain - node perNodeServices: createClusterIPService: true From 7f7a76da6e462c86d5af0d16391021cec521e553 Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Wed, 9 Mar 2022 14:58:57 +0800 Subject: [PATCH 05/13] Chart for polkadot-introspector --- README.md | 1 + charts/polkadot-introspector/.helmignore | 23 ++++++ charts/polkadot-introspector/Chart.yaml | 6 ++ charts/polkadot-introspector/README.md | 39 ++++++++++ .../polkadot-introspector/templates/NOTES.txt | 26 +++++++ .../templates/_helpers.tpl | 65 +++++++++++++++++ .../templates/deployment.yaml | 69 ++++++++++++++++++ .../templates/ingress.yaml | 61 ++++++++++++++++ .../templates/service.yaml | 15 ++++ .../templates/serviceaccount.yaml | 12 ++++ .../templates/servicemonitor.yaml | 33 +++++++++ charts/polkadot-introspector/values.yaml | 72 +++++++++++++++++++ 12 files changed, 422 insertions(+) create mode 100644 charts/polkadot-introspector/.helmignore create mode 100644 charts/polkadot-introspector/Chart.yaml create mode 100644 charts/polkadot-introspector/README.md create mode 100644 charts/polkadot-introspector/templates/NOTES.txt create mode 100644 charts/polkadot-introspector/templates/_helpers.tpl create mode 100644 charts/polkadot-introspector/templates/deployment.yaml create mode 100644 charts/polkadot-introspector/templates/ingress.yaml create mode 100644 charts/polkadot-introspector/templates/service.yaml create mode 100644 charts/polkadot-introspector/templates/serviceaccount.yaml create mode 100644 charts/polkadot-introspector/templates/servicemonitor.yaml create mode 100644 charts/polkadot-introspector/values.yaml diff --git a/README.md b/README.md index a238935e..4b68e8d1 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ Parity's [Kubernetes Helm](https://helm.sh/) charts collection. - [Node](charts/node/README.md): deploy Substrate/Polkadot nodes - [Substrate telemetry](charts/substrate-telemetry/README.md): deploy Substrate Telemetry for the nodes +- [Introspector](charts/introspector/README.md): deploy introspector for the nodes diff --git a/charts/polkadot-introspector/.helmignore b/charts/polkadot-introspector/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/polkadot-introspector/.helmignore @@ -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/ diff --git a/charts/polkadot-introspector/Chart.yaml b/charts/polkadot-introspector/Chart.yaml new file mode 100644 index 00000000..c96a4cff --- /dev/null +++ b/charts/polkadot-introspector/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: polkadot-introspector +description: A Helm chart to deploy polkadot-introspector +type: application +version: 0.1.0 +appVersion: "0.1.0" diff --git a/charts/polkadot-introspector/README.md b/charts/polkadot-introspector/README.md new file mode 100644 index 00000000..f26a3845 --- /dev/null +++ b/charts/polkadot-introspector/README.md @@ -0,0 +1,39 @@ +# Polkadot introspector helm chart + +The helm chart installs Polkadot introspector. The repo is located in https://github.com/paritytech/polkadot-introspector. + +## Installing the chart + +```console +helm repo add parity https://paritytech.github.io/helm-charts/ +helm install polkadot-introspector parity/polkadot-introspector +``` + +## Parameters + +### Common parameters + +| Parameter | Description | Default | +|---------------------|----------------------------------------------------------------------------|--------------------------------| +| `nameOverride` | String to partially override node.fullname | `nil` | +| `fullnameOverride` | String to fully override node.fullname | `nil` | +| `imagePullSecrets` | Labels to add to all deployed objects | `[]` | +| `podAnnotations` | Annotations to add to pods | `{}` | +| `nodeSelector` | Node labels for pod assignment | `{}` | +| `tolerations` | Tolerations for pod assignment | `[]` | +| `affinity` | Affinity for pod assignment | `{}` | +| `extraLabels` | Tolerations for pod assignment | `[]` | +| `replicas` | Number of replicas | `1` | +| `extraLabels ` | Extra labels to add in all resources | `{}` | +| `serviceMonitor.enabled` | If true, creates a Prometheus Operator ServiceMonitor | `false` | +| `serviceMonitor.internal` | Prometheus scrape interval | `1m` | +| `serviceMonitor.scrapeTimeout` | Prometheus scrape timeout | `30s` | +| `serviceMonitor.targetLabels` | Transfers labels on Kubernetes onto the metrics | `[]` | + +### Introspector parameters + +| Parameter | Description | Default | +|-------------------------------|----------------------------------------------------------|--------------------------------------------------------------------| +| `introspector.role` | Main subcommand to use by introspector | `block-time-monitor` | +| `introspector.rpcNodes` | List of RPC nodes to connect when in block-time-monitor | `wss://rpc.polkadot.io:443,wss://kusama-rpc.polkadot.io:443` | +| `introspector.prometheusPort` | Prometheus Port to expose the metrics | `9615` | \ No newline at end of file diff --git a/charts/polkadot-introspector/templates/NOTES.txt b/charts/polkadot-introspector/templates/NOTES.txt new file mode 100644 index 00000000..01f47356 --- /dev/null +++ b/charts/polkadot-introspector/templates/NOTES.txt @@ -0,0 +1,26 @@ +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 "polkadot-introspector.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 "polkadot-introspector.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "polkadot-introspector.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 "polkadot-introspector.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}") +{{- if contains "block-time-monitor" .Values.introspector.role }} + +2. To view the block production time via different RPC nodes + echo "Visit http://127.0.0.1:{{ .Values.introspector.prometheusPort }}/metrics to view the metrics" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME {{ .Values.introspector.prometheusPort }}:{{ .Values.introspector.prometheusPort }} +{{- end }} +{{- end }} diff --git a/charts/polkadot-introspector/templates/_helpers.tpl b/charts/polkadot-introspector/templates/_helpers.tpl new file mode 100644 index 00000000..583bee96 --- /dev/null +++ b/charts/polkadot-introspector/templates/_helpers.tpl @@ -0,0 +1,65 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "polkadot-introspector.name" -}} +{{- default .Chart.Name .Values.nameOverride | 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 "polkadot-introspector.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 }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "polkadot-introspector.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "polkadot-introspector.labels" -}} +helm.sh/chart: {{ include "polkadot-introspector.chart" . }} +{{ include "polkadot-introspector.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- with .Values.extraLabels }} +{{ toYaml . }} +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "polkadot-introspector.selectorLabels" -}} +app.kubernetes.io/name: {{ include "polkadot-introspector.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "polkadot-introspector.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "polkadot-introspector.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/polkadot-introspector/templates/deployment.yaml b/charts/polkadot-introspector/templates/deployment.yaml new file mode 100644 index 00000000..874144e1 --- /dev/null +++ b/charts/polkadot-introspector/templates/deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "polkadot-introspector.fullname" . }} + labels: + {{- include "polkadot-introspector.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + {{- include "polkadot-introspector.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "polkadot-introspector.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "polkadot-introspector.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["/bin/sh"] + args: + - -c + - | + exec polkadot-introspector \ + {{- if eq .Values.introspector.role "block-time-monitor"}} + block-time-monitor \ + --ws {{ .Values.introspector.rpcNodes }} \ + prometheus --port {{ .Values.introspector.prometheusPort }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.introspector.prometheusPort }} + protocol: TCP + livenessProbe: + httpGet: + path: /metrics + port: http + readinessProbe: + httpGet: + path: /metrics + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/polkadot-introspector/templates/ingress.yaml b/charts/polkadot-introspector/templates/ingress.yaml new file mode 100644 index 00000000..a085728a --- /dev/null +++ b/charts/polkadot-introspector/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "polkadot-introspector.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "polkadot-introspector.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/polkadot-introspector/templates/service.yaml b/charts/polkadot-introspector/templates/service.yaml new file mode 100644 index 00000000..8ae6963a --- /dev/null +++ b/charts/polkadot-introspector/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "polkadot-introspector.fullname" . }} + labels: + {{- include "polkadot-introspector.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - name: prometheus + port: {{ .Values.service.port }} + targetPort: {{ .Values.introspector.prometheusPort }} + protocol: TCP + selector: + {{- include "polkadot-introspector.selectorLabels" . | nindent 4 }} \ No newline at end of file diff --git a/charts/polkadot-introspector/templates/serviceaccount.yaml b/charts/polkadot-introspector/templates/serviceaccount.yaml new file mode 100644 index 00000000..61c541b1 --- /dev/null +++ b/charts/polkadot-introspector/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "polkadot-introspector.serviceAccountName" . }} + labels: + {{- include "polkadot-introspector.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/polkadot-introspector/templates/servicemonitor.yaml b/charts/polkadot-introspector/templates/servicemonitor.yaml new file mode 100644 index 00000000..ad88c56c --- /dev/null +++ b/charts/polkadot-introspector/templates/servicemonitor.yaml @@ -0,0 +1,33 @@ +{{- if .Values.serviceMonitor.enabled }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "polkadot-introspector.fullname" . }} + labels: + {{- include "polkadot-introspector.labels" . | nindent 4 }} +spec: + endpoints: + - port: {{ .Values.service.portName }} + {{- with .Values.serviceMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + honorLabels: true + path: /metrics + scheme: http + {{- with .Values.serviceMonitor.targetLabels }} + targetLabels: + {{ toYaml .| nindent 6 }} + {{- end}} + jobLabel: "{{ .Release.Name }}" + selector: + matchLabels: + {{- include "polkadot-introspector.selectorLabels" . | nindent 8 }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + +{{- end}} \ No newline at end of file diff --git a/charts/polkadot-introspector/values.yaml b/charts/polkadot-introspector/values.yaml new file mode 100644 index 00000000..45364dbb --- /dev/null +++ b/charts/polkadot-introspector/values.yaml @@ -0,0 +1,72 @@ +nameOverride: "" +fullnameOverride: "" + +image: + repository: lazam/introspector #To be replaced once public image is available + pullPolicy: Always + tag: latest + +imagePullSecrets: [] + +replicas: 1 + +introspector: + role: block-time-monitor + rpcNodes: "wss://rpc.polkadot.io:443,wss://kusama-rpc.polkadot.io:443" + prometheusPort: 9615 + +serviceAccount: + create: true +# annotations: {} +# name: "" + +extraLabels: [] + +podAnnotations: {} + +podSecurityContext: + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 9615 + +serviceMonitor: + enabled: false + interval: 1m + scrapeTimeout: 30s + targetLabels: [] + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 7f49cd5250abd3f284363ad12f6e71f322cc6b99 Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Wed, 9 Mar 2022 18:51:21 +0800 Subject: [PATCH 06/13] Convert RPC nodes to yaml --- charts/polkadot-introspector/templates/deployment.yaml | 2 +- charts/polkadot-introspector/values.yaml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/charts/polkadot-introspector/templates/deployment.yaml b/charts/polkadot-introspector/templates/deployment.yaml index 874144e1..c0f84ab3 100644 --- a/charts/polkadot-introspector/templates/deployment.yaml +++ b/charts/polkadot-introspector/templates/deployment.yaml @@ -38,7 +38,7 @@ spec: exec polkadot-introspector \ {{- if eq .Values.introspector.role "block-time-monitor"}} block-time-monitor \ - --ws {{ .Values.introspector.rpcNodes }} \ + --ws {{ join "," .Values.introspector.rpcNodes }} \ prometheus --port {{ .Values.introspector.prometheusPort }} {{- end }} ports: diff --git a/charts/polkadot-introspector/values.yaml b/charts/polkadot-introspector/values.yaml index 45364dbb..8a744214 100644 --- a/charts/polkadot-introspector/values.yaml +++ b/charts/polkadot-introspector/values.yaml @@ -12,7 +12,9 @@ replicas: 1 introspector: role: block-time-monitor - rpcNodes: "wss://rpc.polkadot.io:443,wss://kusama-rpc.polkadot.io:443" + rpcNodes: + - wss://rpc.polkadot.io:443 + - wss://kusama-rpc.polkadot.io:443 prometheusPort: 9615 serviceAccount: From e803d13a95d89ebb57e1ca125ad0536e3a5defef Mon Sep 17 00:00:00 2001 From: Arsham Teymouri <75425316+ArshamTeymouri@users.noreply.github.com> Date: Wed, 9 Mar 2022 13:30:42 +0100 Subject: [PATCH 07/13] add livenessProbe and readinessProbe support for common helm chart (#59) --- charts/common/Chart.yaml | 2 +- charts/common/README.md | 3 ++- charts/common/templates/deployment.yaml | 12 ++++++------ charts/common/values.yaml | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index bf268673..4783ab13 100644 --- a/charts/common/Chart.yaml +++ b/charts/common/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.1.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/common/README.md b/charts/common/README.md index 87e5f595..4229476d 100644 --- a/charts/common/README.md +++ b/charts/common/README.md @@ -2,4 +2,5 @@ add templates for: - configmaps -- liveness and readiness probes +- serviceMonitor +- prometheusRules diff --git a/charts/common/templates/deployment.yaml b/charts/common/templates/deployment.yaml index 1e14bc61..e213dd83 100644 --- a/charts/common/templates/deployment.yaml +++ b/charts/common/templates/deployment.yaml @@ -38,14 +38,14 @@ spec: - name: http containerPort: {{ .Values.service.containerPort }} protocol: TCP + {{- with .Values.livenessProbe }} livenessProbe: - httpGet: - path: /ping - port: http + {{- toYaml . | trim | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} readinessProbe: - httpGet: - path: /ping - port: http + {{- toYaml . | trim | nindent 12 }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} env: diff --git a/charts/common/values.yaml b/charts/common/values.yaml index e9a20e41..da52a757 100644 --- a/charts/common/values.yaml +++ b/charts/common/values.yaml @@ -102,6 +102,26 @@ tolerations: [] affinity: {} +## Controller Container liveness/readiness probe configuration +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: {} + # failureThreshold: 3 + # successThreshold: 1 + # initialDelaySeconds: 0 + # timeoutSeconds: 1 + # tcpSocket: + # port: 80 + # periodSeconds: 10 + +readinessProbe: {} + # failureThreshold: 3 + # successThreshold: 1 + # initialDelaySeconds: 0 + # timeoutSeconds: 1 + # tcpSocket: + # port: 80 + # periodSeconds: 10 + persistence: enabled: false accessModes: From 8ceefe7550597b17c70428332166eaadce8ae822 Mon Sep 17 00:00:00 2001 From: David Blane Date: Wed, 9 Mar 2022 14:34:25 +0000 Subject: [PATCH 08/13] Fixed pruning options --- charts/node/README.md | 1 + charts/node/templates/_helpers.tpl | 10 ++++++---- charts/node/templates/statefulset.yaml | 12 ++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/charts/node/README.md b/charts/node/README.md index a78184fd..9fa76c59 100644 --- a/charts/node/README.md +++ b/charts/node/README.md @@ -68,6 +68,7 @@ helm install kusama-node parity/node --set node.chainDataSnapshotUrl=https://ksm | `node.collator.relayChainFlags` | Relay-chain node flags other than `--name` (set from the helm release name), `--base-path` and `--chain` | `nil` | | `node.resources.limits` | The resources limits (cpu/memory) for nodes | `{}` | | `node.podManagementPolicy` | The pod management policy to apply to the StatefulSet, set it to `Parallel` to launch or terminate all Pods in parallel, and not to wait for pods to become Running and Ready or completely terminated prior to launching or terminating another pod | `{}` | +| `node.pruning` | The amount of blocks to retain. Set to a number or `0` for `--pruning=archive`. | `nil` | | `node.resources.requests` | The resources requests (cpu/memory) for nodes | `{}` | | `node.serviceMonitor.enabled` | If true, creates a Prometheus Operator ServiceMonitor | `false` | | `node.serviceMonitor.namespace` | Prometheus namespace | `nil` | diff --git a/charts/node/templates/_helpers.tpl b/charts/node/templates/_helpers.tpl index b5d2c7d8..5c48c861 100644 --- a/charts/node/templates/_helpers.tpl +++ b/charts/node/templates/_helpers.tpl @@ -43,11 +43,13 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} chain: {{ .Values.node.chain }} role: {{ .Values.node.role }} -{{- if .Values.node.pruning }} -pruning: {{ .Values.node.pruning }} -{{- if or (eq .Values.node.role "authority") (eq .Values.node.role "validator") }} -unsafe-pruning: true +{{- if or .Values.node.pruning (eq ( .Values.node.pruning | int64 ) 0 ) }} +{{- if ge ( .Values.node.pruning | int64 ) 1 }} +pruning: {{ ( .Values.node.pruning | int64 ) }} +{{- else if eq ( .Values.node.pruning | int64 ) 0 }} +pruning: archive {{- end }} +unsafe-pruning: true {{- end }} {{- with .Values.extraLabels }} {{ toYaml . }} diff --git a/charts/node/templates/statefulset.yaml b/charts/node/templates/statefulset.yaml index d4f24ee1..4888c371 100644 --- a/charts/node/templates/statefulset.yaml +++ b/charts/node/templates/statefulset.yaml @@ -264,13 +264,13 @@ spec: --chain={{ if .Values.node.customChainspecUrl }}{{ .Values.node.customChainspecPath }}{{ else }}${CHAIN}{{ end }} \ {{- if or (eq .Values.node.role "authority") (eq .Values.node.role "validator") }} --validator \ - {{- if .Values.node.pruning }} - --unsafe-pruning \ - --pruning {{ .Values.node.pruning }} \ - {{- end }} {{- end }} - {{- if and (eq .Values.node.role "full") .Values.node.pruning }} - --pruning {{ .Values.node.pruning }} \ + {{- if ge ( .Values.node.pruning | int64 ) 1 }} + --unsafe-pruning \ + --pruning={{ .Values.node.pruning }} \ + {{- else if eq ( .Values.node.pruning | int64 ) 0 }} + --unsafe-pruning \ + --pruning=archive \ {{- end }} {{- if eq .Values.node.role "collator" }} --collator \ From 337c959413cacd2c9b4b70dd55f336a0ee00bae9 Mon Sep 17 00:00:00 2001 From: David Blane Date: Wed, 9 Mar 2022 14:35:44 +0000 Subject: [PATCH 09/13] Bumped version --- charts/node/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/node/Chart.yaml b/charts/node/Chart.yaml index d1ed0ed7..53c8bf5a 100644 --- a/charts/node/Chart.yaml +++ b/charts/node/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: node description: A Helm chart to deploy Substrate/Polkadot nodes type: application -version: 1.2.1 +version: 1.3.0 appVersion: "0.0.1" From 9cae7ae4741ac9cfe99a89c45729b20aaa2023ad Mon Sep 17 00:00:00 2001 From: David Blane Date: Wed, 9 Mar 2022 16:04:13 +0000 Subject: [PATCH 10/13] Fixed logic for kindIs invalid --- charts/node/README.md | 2 +- charts/node/templates/_helpers.tpl | 8 ++++---- charts/node/templates/statefulset.yaml | 4 ++-- charts/node/values.yaml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/node/README.md b/charts/node/README.md index 9fa76c59..f7a4e62a 100644 --- a/charts/node/README.md +++ b/charts/node/README.md @@ -68,7 +68,7 @@ helm install kusama-node parity/node --set node.chainDataSnapshotUrl=https://ksm | `node.collator.relayChainFlags` | Relay-chain node flags other than `--name` (set from the helm release name), `--base-path` and `--chain` | `nil` | | `node.resources.limits` | The resources limits (cpu/memory) for nodes | `{}` | | `node.podManagementPolicy` | The pod management policy to apply to the StatefulSet, set it to `Parallel` to launch or terminate all Pods in parallel, and not to wait for pods to become Running and Ready or completely terminated prior to launching or terminating another pod | `{}` | -| `node.pruning` | The amount of blocks to retain. Set to a number or `0` for `--pruning=archive`. | `nil` | +| `node.pruning` | The amount of blocks to retain. Set to a number or 0 for `--pruning=archive` . | `nil` | | `node.resources.requests` | The resources requests (cpu/memory) for nodes | `{}` | | `node.serviceMonitor.enabled` | If true, creates a Prometheus Operator ServiceMonitor | `false` | | `node.serviceMonitor.namespace` | Prometheus namespace | `nil` | diff --git a/charts/node/templates/_helpers.tpl b/charts/node/templates/_helpers.tpl index 5c48c861..765e890c 100644 --- a/charts/node/templates/_helpers.tpl +++ b/charts/node/templates/_helpers.tpl @@ -43,10 +43,10 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} chain: {{ .Values.node.chain }} role: {{ .Values.node.role }} -{{- if or .Values.node.pruning (eq ( .Values.node.pruning | int64 ) 0 ) }} -{{- if ge ( .Values.node.pruning | int64 ) 1 }} -pruning: {{ ( .Values.node.pruning | int64 ) }} -{{- else if eq ( .Values.node.pruning | int64 ) 0 }} +{{- if or .Values.node.pruning ( not ( kindIs "invalid" .Values.node.pruning ) ) }} +{{- if ge ( int .Values.node.pruning ) 1 }} +pruning: {{ ( int .Values.node.pruning ) }} +{{- else if and ( not ( kindIs "invalid" .Values.node.pruning ) ) ( eq 0 ( int .Values.node.pruning ) ) }} pruning: archive {{- end }} unsafe-pruning: true diff --git a/charts/node/templates/statefulset.yaml b/charts/node/templates/statefulset.yaml index 4888c371..9514d0e2 100644 --- a/charts/node/templates/statefulset.yaml +++ b/charts/node/templates/statefulset.yaml @@ -265,10 +265,10 @@ spec: {{- if or (eq .Values.node.role "authority") (eq .Values.node.role "validator") }} --validator \ {{- end }} - {{- if ge ( .Values.node.pruning | int64 ) 1 }} + {{- if ge ( int .Values.node.pruning ) 1 }} --unsafe-pruning \ --pruning={{ .Values.node.pruning }} \ - {{- else if eq ( .Values.node.pruning | int64 ) 0 }} + {{- else if and ( not ( kindIs "invalid" .Values.node.pruning ) ) ( eq 0 ( int .Values.node.pruning ) ) }} --unsafe-pruning \ --pruning=archive \ {{- end }} diff --git a/charts/node/values.yaml b/charts/node/values.yaml index cfd1acb0..25c05bbb 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -98,7 +98,7 @@ node: # seed: "//Alice//babe" persistGeneratedNodeKey: false #customNodeKey: "" - # pruning: 1000 + pruning: 1000 resources: {} serviceMonitor: enabled: false From 1602462ee2e5bec4224ca8e2890560949e3cbdb1 Mon Sep 17 00:00:00 2001 From: David Blane Date: Wed, 9 Mar 2022 16:05:11 +0000 Subject: [PATCH 11/13] Updated Readme --- charts/node/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/node/README.md b/charts/node/README.md index f7a4e62a..f9d39b28 100644 --- a/charts/node/README.md +++ b/charts/node/README.md @@ -68,7 +68,7 @@ helm install kusama-node parity/node --set node.chainDataSnapshotUrl=https://ksm | `node.collator.relayChainFlags` | Relay-chain node flags other than `--name` (set from the helm release name), `--base-path` and `--chain` | `nil` | | `node.resources.limits` | The resources limits (cpu/memory) for nodes | `{}` | | `node.podManagementPolicy` | The pod management policy to apply to the StatefulSet, set it to `Parallel` to launch or terminate all Pods in parallel, and not to wait for pods to become Running and Ready or completely terminated prior to launching or terminating another pod | `{}` | -| `node.pruning` | The amount of blocks to retain. Set to a number or 0 for `--pruning=archive` . | `nil` | +| `node.pruning` | The amount of blocks to retain. Set to a number or set to 0 for `--pruning=archive` . | `nil` | | `node.resources.requests` | The resources requests (cpu/memory) for nodes | `{}` | | `node.serviceMonitor.enabled` | If true, creates a Prometheus Operator ServiceMonitor | `false` | | `node.serviceMonitor.namespace` | Prometheus namespace | `nil` | From 67fd86954fdcaa91a1b1cb75e5635f68e928dcef Mon Sep 17 00:00:00 2001 From: David Blane Date: Wed, 9 Mar 2022 16:06:24 +0000 Subject: [PATCH 12/13] Default pruning value --- charts/node/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/node/values.yaml b/charts/node/values.yaml index 25c05bbb..cfd1acb0 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -98,7 +98,7 @@ node: # seed: "//Alice//babe" persistGeneratedNodeKey: false #customNodeKey: "" - pruning: 1000 + # pruning: 1000 resources: {} serviceMonitor: enabled: false From 5b70890441917cc59965ce8fa337029d448dea0f Mon Sep 17 00:00:00 2001 From: David Blane Date: Thu, 10 Mar 2022 09:10:24 +0000 Subject: [PATCH 13/13] Updated unsafe-pruning args and labels --- charts/node/templates/_helpers.tpl | 3 ++- charts/node/templates/statefulset.yaml | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/node/templates/_helpers.tpl b/charts/node/templates/_helpers.tpl index 765e890c..862320f6 100644 --- a/charts/node/templates/_helpers.tpl +++ b/charts/node/templates/_helpers.tpl @@ -46,10 +46,11 @@ role: {{ .Values.node.role }} {{- if or .Values.node.pruning ( not ( kindIs "invalid" .Values.node.pruning ) ) }} {{- if ge ( int .Values.node.pruning ) 1 }} pruning: {{ ( int .Values.node.pruning ) }} +unsafe-pruning: true {{- else if and ( not ( kindIs "invalid" .Values.node.pruning ) ) ( eq 0 ( int .Values.node.pruning ) ) }} pruning: archive +unsafe-pruning: false {{- end }} -unsafe-pruning: true {{- end }} {{- with .Values.extraLabels }} {{ toYaml . }} diff --git a/charts/node/templates/statefulset.yaml b/charts/node/templates/statefulset.yaml index 9514d0e2..c6db5999 100644 --- a/charts/node/templates/statefulset.yaml +++ b/charts/node/templates/statefulset.yaml @@ -269,7 +269,6 @@ spec: --unsafe-pruning \ --pruning={{ .Values.node.pruning }} \ {{- else if and ( not ( kindIs "invalid" .Values.node.pruning ) ) ( eq 0 ( int .Values.node.pruning ) ) }} - --unsafe-pruning \ --pruning=archive \ {{- end }} {{- if eq .Values.node.role "collator" }}