Skip to content

Commit

Permalink
add new polkadot-stps chart (#244)
Browse files Browse the repository at this point in the history
* add new polkadot-stps chart

* automatically set the correct senders flags on stps-sender pods

* fix stps port name

* set different selector labels for stps-tps and stps-sender

* lower scrapeTiemout as it cannot be higher than scrape interval

* add tps args for kind to pass validation test

* allow disabling tps deployment
  • Loading branch information
PierreBesson authored Jun 5, 2023
1 parent 464ae09 commit e442795
Show file tree
Hide file tree
Showing 11 changed files with 394 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Parity's [Kubernetes Helm](https://helm.sh/) charts collection.
- [Polkadot Basic Notification](charts/polkadot-basic-notification/README.md): deploy a chain notification bot
- [Polkadot Introspector](charts/polkadot-introspector/README.md): deploy a chain monitoring and introspection service
- [Staking miner](charts/staking-miner/README.md): deploy the staking-miner for submitting solutions to NPoS elections
- [Polkadot STPS](charts/polkadot-stps/README.md): deploy the Polkadot Standard Transactions Per Second (sTPS) performance benchmarking service
- [Substrate faucet](charts/substrate-faucet/README.md): deploy Substrate Faucet service
- [Substrate telemetry](charts/substrate-telemetry/README.md): deploy the Substrate Telemetry service
- [Testnet Manager](charts/testnet-manager/README.md): deploy a management tool for operating testnets
23 changes: 23 additions & 0 deletions charts/polkadot-stps/.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/
9 changes: 9 additions & 0 deletions charts/polkadot-stps/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: polkadot-stps
description: A Helm chart to deploy polkadot-stps
type: application
version: 0.1.0
appVersion: "1.0.0"
maintainers:
- name: Parity
url: https://github.com/paritytech/helm-charts
10 changes: 10 additions & 0 deletions charts/polkadot-stps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Polkadot stps helm chart

The helm chart installs [Polkadot STPS](https://github.com/paritytech/polkadot-stps).

## Installing the chart

```console
helm repo add parity https://paritytech.github.io/helm-charts/
helm install polkadot-stps parity/polkadot-stps
```
5 changes: 5 additions & 0 deletions charts/polkadot-stps/ci/kind-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
serviceMonitor:
enabled: false

tps:
enabled: false
78 changes: 78 additions & 0 deletions charts/polkadot-stps/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "polkadot-stps.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-stps.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-stps.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "polkadot-stps.labels" -}}
helm.sh/chart: {{ include "polkadot-stps.chart" . }}
{{ include "polkadot-stps.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-stps.selectorLabels" -}}
app.kubernetes.io/name: {{ include "polkadot-stps.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/*
TPS Selector labels
*/}}
{{- define "polkadot-stps-tps.selectorLabels" -}}
{{ include "polkadot-stps.selectorLabels" . }}
stps/app: tps
{{- end }}

{{/*
Sender Selector labels
*/}}
{{- define "polkadot-stps-sender.selectorLabels" -}}
{{ include "polkadot-stps.selectorLabels" . }}
stps/app: sender
{{- end }}

{{/*
Define a regex matcher to check if the role is supported
*/}}
{{- define "stps.rolesSupported" -}}
{{- "^(block-time|parachain-tracer)$" }}
{{- end }}
60 changes: 60 additions & 0 deletions charts/polkadot-stps/templates/sender-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{- if .Values.sender.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "polkadot-stps.fullname" . }}-sender
labels:
{{- include "polkadot-stps.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.sender.replicas }}
podManagementPolicy: Parallel
serviceName: {{ include "polkadot-stps.fullname" . }}
selector:
matchLabels:
{{- include "polkadot-stps-sender.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "polkadot-stps-sender.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: stps-sender
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.sender.image.repository }}:{{ .Values.sender.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.sender.image.pullPolicy }}
command: ["/bin/sh"]
args:
- -c
- |
exec /usr/local/bin/sender \
--total-senders={{ .Values.sender.replicas }} \
--sender-index=${HOSTNAME##*-} \
{{- range $key, $val := .Values.sender.args }}
--{{ $key }}={{ $val }} \
{{- end }}
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 }}
{{- end }}
34 changes: 34 additions & 0 deletions charts/polkadot-stps/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if .Values.sender.enabled }}
{{- if .Values.serviceMonitor.enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "polkadot-stps.fullname" . }}
labels:
{{- include "polkadot-stps.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-stps-tps.selectorLabels" . | nindent 8 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
{{- end }}
74 changes: 74 additions & 0 deletions charts/polkadot-stps/templates/tps-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{{- if .Values.tps.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "polkadot-stps.fullname" . }}-tps
labels:
{{- include "polkadot-stps.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
{{- include "polkadot-stps-tps.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "polkadot-stps-tps.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: stps-tps
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.tps.image.repository }}:{{ .Values.tps.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.tps.image.pullPolicy }}
args:
{{- range $key, $val := .Values.tps.args }}
- --{{ $key }}={{ $val }}
{{- end }}
{{- if .Values.tps.scrapeFromGenesis.enabled }}
- --genesis
{{- end }}
{{- if .Values.tps.paraBlockFinality.enabled }}
- --para-finality
{{- end }}
{{- if .Values.tps.prometheus.enabled }}
- --prometheus
- --prometheus-port={{ .Values.tps.prometheus.port }}
ports:
- name: prometheus
containerPort: {{ .Values.tps.prometheus.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /metrics
port: prometheus
readinessProbe:
httpGet:
path: /metrics
port: prometheus
{{- end }}
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 }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/polkadot-stps/templates/tps-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.sender.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "polkadot-stps.fullname" . }}-tps
labels:
{{- include "polkadot-stps-tps.selectorLabels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- name: {{ .Values.service.portName }}
port: {{ .Values.service.port }}
targetPort: {{ .Values.tps.prometheus.port }}
protocol: TCP
selector:
{{- include "polkadot-stps-tps.selectorLabels" . | nindent 4 }}
{{- end }}
Loading

0 comments on commit e442795

Please sign in to comment.