-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ns212
committed
Jan 25, 2021
1 parent
11dd8dd
commit 3d3b20f
Showing
18 changed files
with
675 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
description: Polkadot Node chart. | ||
name: w3f-polkadot | ||
version: v0.34.1 | ||
apiVersion: v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{{/* Generates bootnodes string */}} | ||
{{- define "polkadot-deployer.bootnodes" -}} | ||
{{- range .Values.bootNodes }}--bootnodes={{ . }} {{ end -}} | ||
{{- end }} | ||
|
||
{{/* Returns custom-chainspec configmap name */}} | ||
{{- define "polkadot-deployer.custom-chainspec-configmap" -}} | ||
polkadot-custom-chainspec | ||
{{- end }} | ||
|
||
{{/* Returns the certificate name */}} | ||
{{- define "polkadot-deployer.certificateName" -}} | ||
{{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* Returns the TLS secret name */}} | ||
{{- define "polkadot-deployer.tlsSecretName" -}} | ||
{{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* Returns the session key secret name */}} | ||
{{- define "polkadot-deployer.sessionKey" -}} | ||
{{ .Release.Name }}-session-key | ||
{{- end }} | ||
|
||
{{/* Returns the node key secret name */}} | ||
{{- define "polkadot-deployer.nodeKey" -}} | ||
{{ .Release.Name }}-node-key | ||
{{- end }} | ||
|
||
{{/* Returns the PSP name */}} | ||
{{- define "polkadot-deployer.podSecurityPolicyName" -}} | ||
{{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* Returns the external websockets service name */}} | ||
{{- define "polkadot-deployer.websocketService" -}} | ||
{{ .Release.Name }}-external-websockets | ||
{{- end }} | ||
|
||
{{/* Returns the telemetry parameter content */}} | ||
{{- define "polkadot-deployer.telemetry" -}} | ||
{{- if .Values.telemetry }}--telemetry-url={{ .Values.telemetry }} {{ end -}} | ||
{{- end }} | ||
|
||
{{/* Returns the p2p service name */}} | ||
{{- define "polkadot-deployer.p2pService" -}} | ||
{{ .Release.Name }}-p2p | ||
{{- end }} | ||
|
||
{{/* Returns the http RPC service name */}} | ||
{{- define "polkadot-deployer.rpcService" -}} | ||
{{ .Release.Name }}-rpc | ||
{{- end }} | ||
|
||
{{/* Returns the bootnode service name */}} | ||
{{- define "polkadot-deployer.bootnodeService" -}} | ||
{{ .Release.Name }}-bootnode | ||
{{- end }} | ||
|
||
{{/* Returns the chainspec to use */}} | ||
{{- define "polkadot-deployer.chainspecName" -}} | ||
{{- if .Values.chainspec.preset -}} | ||
{{ .Values.chainspec.name }} | ||
{{- else -}} | ||
{{ .Values.chainspec.basePath }}/{{ .Values.chainspec.name }} | ||
{{- end -}} | ||
{{- end }} | ||
|
||
{{/* Returns the statefulset name */}} | ||
{{- define "polkadot-deployer.statefulsetName" -}} | ||
{{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* Returns the default name to use with session injection related resources */}} | ||
{{- define "polkadot-deployer.sessionInjectionName" -}} | ||
{{ .Release.Name }}-session-injection | ||
{{- end }} | ||
|
||
{{/* Returns the default name to use with pod restarter related resources */}} | ||
{{- define "polkadot-deployer.podRestarterName" -}} | ||
{{ .Release.Name }}-pod-restarter | ||
{{- end }} | ||
|
||
{{/* Json for private docker registry */}} | ||
{{- define "imagePullSecret" }} | ||
{{- with .Values.imagePullSecret.imageCredentials }} | ||
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{{ if .Values.createConfigMap -}} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "polkadot-deployer.custom-chainspec-configmap" . }} | ||
data: | ||
custom_chainspec.json: |- | ||
{{- $totalItems := len .Values.chainspec.addresses.stash }} | ||
{{- $lastIndex := sub $totalItems 1 }} | ||
{ | ||
"name": {{ .Values.networkName | quote }}, | ||
"id": {{ .Values.networkName | quote }}, | ||
"bootNodes": [ | ||
{{- $lastBootIndex := sub (len .Values.bootNodes) 1}} | ||
{{- range $index, $value := .Values.bootNodes }} | ||
{{ $value | quote }}{{- if ne $index $lastBootIndex }},{{- end }} | ||
{{- end }} | ||
], | ||
"protocolId": "dot", | ||
"properties": { | ||
"tokenDecimals": 15 | ||
}, | ||
"genesis": { | ||
"runtime": { | ||
"palletBalances": { | ||
"balances": [ | ||
{{- range $index, $value := .Values.chainspec.addresses.stash }} | ||
[ | ||
{{ $value | quote }}, | ||
1048576000000000000 | ||
]{{- if ne $index $lastIndex }},{{- end }} | ||
{{- end }} | ||
] | ||
}, | ||
"palletSession": { | ||
"keys": [ | ||
{{- $grandpaSessionKeys := .Values.chainspec.addresses.session_grandpa }} | ||
{{- $babeSessionKeys := .Values.chainspec.addresses.session_babe }} | ||
{{- $imonlineSessionKeys := .Values.chainspec.addresses.session_imonline }} | ||
{{- $parachainSessionKeys := .Values.chainspec.addresses.session_parachain }} | ||
{{- $audiSessionKeys := .Values.chainspec.addresses.session_audi }} | ||
{{- range $index, $value := .Values.chainspec.addresses.stash }} | ||
[ | ||
{{ $value | quote }}, | ||
{{ $value | quote }}, | ||
{ | ||
"grandpa": {{ index $grandpaSessionKeys $index | quote }}, | ||
"babe": {{ index $babeSessionKeys $index | quote }}, | ||
"parachain_validator": {{ index $parachainSessionKeys $index | quote }}, | ||
"im_online": {{ index $imonlineSessionKeys $index | quote }}, | ||
"authority_discovery": {{ index $audiSessionKeys $index | quote }} | ||
} | ||
]{{- if ne $index $lastIndex }},{{- end }} | ||
{{- end }} | ||
] | ||
}, | ||
"palletStaking": { | ||
"validatorCount": {{ $totalItems }}, | ||
"invulnerables": [ | ||
{{- range $index, $value := .Values.chainspec.addresses.stash }} | ||
{{ $value | quote }}{{- if ne $index $lastIndex }},{{- end }} | ||
{{- end }} | ||
], | ||
"stakers": [ | ||
{{- $controllers := .Values.chainspec.addresses.controller }} | ||
{{- range $index, $value := .Values.chainspec.addresses.stash }} | ||
[ | ||
{{ $value | quote }}, | ||
{{ index $controllers $index | quote }}, | ||
5000, | ||
"Validator" | ||
]{{- if ne $index $lastIndex }},{{- end }} | ||
{{- end }} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ if .Values.nodeRestart.enabled }} | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ include "polkadot-deployer.podRestarterName" . }} | ||
spec: | ||
schedule: {{ .Values.nodeRestart.schedule }} | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
serviceAccountName: {{ include "polkadot-deployer.podRestarterName" . }} | ||
containers: | ||
- name: {{ include "polkadot-deployer.podRestarterName" . }} | ||
image: {{ .Values.initImage.repo }}:{{ .Values.initImage.tag }} | ||
args: | ||
- /app/restart_pods.sh | ||
- {{ include "polkadot-deployer.statefulsetName" . }} | ||
restartPolicy: Never | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ if and .Values.validator .Values.sessionInjection.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "polkadot-deployer.sessionInjectionName" . }} | ||
spec: | ||
template: | ||
spec: | ||
serviceAccountName: {{ include "polkadot-deployer.sessionInjectionName" . }} | ||
containers: | ||
- name: {{ include "polkadot-deployer.sessionInjectionName" . }} | ||
image: {{ .Values.initImage.repo }}:{{ .Values.initImage.tag }} | ||
command: | ||
- /app/inject_session_keys.sh | ||
- {{ include "polkadot-deployer.rpcService" . }}:{{ .Values.rpcPort }} | ||
- {{ include "polkadot-deployer.statefulsetName" . }} | ||
volumeMounts: | ||
- name: session-keys | ||
mountPath: /keys | ||
restartPolicy: Never | ||
volumes: | ||
- name: session-keys | ||
secret: | ||
secretName: {{ include "polkadot-deployer.sessionKey" . }} | ||
defaultMode: 256 | ||
items: | ||
- key: grandpa-session-key | ||
path: grandpa-session | ||
- key: babe-session-key | ||
path: babe-session | ||
- key: imonline-session-key | ||
path: imonline-session | ||
- key: parachain-session-key | ||
path: parachain-session | ||
- key: audi-session-key | ||
path: audi-session | ||
backoffLimit: 120 | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "polkadot-deployer.podRestarterName" . }} | ||
rules: | ||
- apiGroups: ["apps"] | ||
verbs: | ||
- "get" | ||
resources: | ||
- "statefulsets" | ||
- apiGroups: ["apps"] | ||
verbs: | ||
- "get" | ||
- "patch" | ||
resources: | ||
- "statefulsets/scale" |
13 changes: 13 additions & 0 deletions
13
charts/w3f-polkadot/templates/rolebinding-pod-restarter.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "polkadot-deployer.podRestarterName" . }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ include "polkadot-deployer.podRestarterName" . }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "polkadot-deployer.sessionInjectionName" . }} | ||
- kind: ServiceAccount | ||
name: {{ include "polkadot-deployer.podRestarterName" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{ if .Values.imagePullSecret }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ .Values.imagePullSecret.secretName | default "dockerregistrysecret" }} | ||
type: kubernetes.io/dockerconfigjson | ||
data: | ||
.dockerconfigjson: {{ template "imagePullSecret" . }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{ if .Values.nodeKey }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "polkadot-deployer.nodeKey" . }} | ||
type: Opaque | ||
data: | ||
node-key: {{ .Values.nodeKey | b64enc }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{ if and .Values.validator .Values.sessionInjection.enabled }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "polkadot-deployer.sessionKey" . }} | ||
type: Opaque | ||
data: | ||
grandpa-session-key: {{ .Values.keys.session_grandpa | b64enc }} | ||
babe-session-key: {{ .Values.keys.session_babe | b64enc }} | ||
imonline-session-key: {{ .Values.keys.session_imonline | b64enc }} | ||
parachain-session-key: {{ .Values.keys.session_parachain | b64enc }} | ||
audi-session-key: {{ .Values.keys.session_audi | b64enc }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{ if .Values.createBootnodeService -}} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "polkadot-deployer.bootnodeService" . }} | ||
labels: | ||
node: {{ .Release.Name }} | ||
spec: | ||
ports: | ||
- port: {{ .Values.p2pPort }} | ||
name: p2p | ||
selector: | ||
node: {{ .Release.Name }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "polkadot-deployer.p2pService" . }} | ||
labels: | ||
node: {{ .Release.Name }} | ||
spec: | ||
externalTrafficPolicy: Local | ||
ports: | ||
- port: {{ .Values.p2pPort }} | ||
name: p2p | ||
nodePort: {{ .Values.p2pPort }} | ||
selector: | ||
node: {{ .Release.Name }} | ||
type: NodePort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "polkadot-deployer.rpcService" . }} | ||
labels: | ||
node: {{ .Release.Name }} | ||
spec: | ||
ports: | ||
- port: {{ .Values.rpcPort }} | ||
name: http-rpc | ||
- port: {{ .Values.metricsPort }} | ||
name: metrics | ||
selector: | ||
node: {{ .Release.Name }} |
6 changes: 6 additions & 0 deletions
6
charts/w3f-polkadot/templates/serviceaccount-pod-restarter.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ if .Values.nodeRestart.enabled }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "polkadot-deployer.podRestarterName" . }} | ||
{{ end }} |
4 changes: 4 additions & 0 deletions
4
charts/w3f-polkadot/templates/serviceaccount-session-injection.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "polkadot-deployer.sessionInjectionName" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ if .Values.monitoring }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
name: {{ .Release.Name }} | ||
labels: | ||
{{ toYaml .Values.serviceMonitorLabels | indent 4 }} | ||
release: prometheus-operator | ||
spec: | ||
selector: | ||
matchLabels: | ||
node: {{ .Release.Name }} | ||
endpoints: | ||
- port: metrics | ||
{{ end }} |
Oops, something went wrong.