Skip to content

Commit

Permalink
Make tezos node and rpc service labels and selector configurable (#313)
Browse files Browse the repository at this point in the history
* Make tezos node and rpc service labels and selector configurable

* Up the default node storage in values.yaml to 100Gi
  • Loading branch information
harryttd authored Nov 5, 2021
1 parent a4c5188 commit 4d1da02
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 30 deletions.
53 changes: 27 additions & 26 deletions charts/tezos/templates/nodes.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
{{- range $key, $val := .Values.nodes }}
{{- if $val }}
{{- $_ := set $ "node_class" $key }}
{{- $_ := set $ "node_vals" $val }}
{{- $_ := set $ "node_class" $key }}
{{- $_ := set $ "node_vals" $val }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ $key }}
name: {{ $.node_class }}
namespace: {{ $.Release.Namespace }}
spec:
podManagementPolicy: Parallel
replicas: {{ $val.instances | len }}
serviceName: {{ $key }}
replicas: {{ $.node_vals.instances | len }}
serviceName: {{ $.node_class }}
selector:
matchLabels:
app: {{ $key }}
node_class: {{ $.node_class }}
template:
metadata:
labels:
app: {{ $key }}
appType: tezos-node
node_class: {{ $.node_class }}
{{- $.node_vals.labels | default dict | toYaml | nindent 8 }}
spec:
containers:
{{- include "tezos.container.node" $ | indent 8 }}
{{- include "tezos.container.tezedge" $ | indent 8 }}
{{- include "tezos.container.bakers" $ | indent 8 }}
{{- include "tezos.container.endorsers" $ | indent 8 }}
{{- include "tezos.container.logger" $ | indent 8 }}
{{- include "tezos.container.metrics" $ | indent 8 }}
{{- include "tezos.container.zerotier" $ | indent 8 }}
{{- include "tezos.container.sidecar" $ | indent 8 }}
{{- include "tezos.container.node" $ | indent 8 }}
{{- include "tezos.container.tezedge" $ | indent 8 }}
{{- include "tezos.container.bakers" $ | indent 8 }}
{{- include "tezos.container.endorsers" $ | indent 8 }}
{{- include "tezos.container.logger" $ | indent 8 }}
{{- include "tezos.container.metrics" $ | indent 8 }}
{{- include "tezos.container.zerotier" $ | indent 8 }}
{{- include "tezos.container.sidecar" $ | indent 8 }}
initContainers:
{{- include "tezos.init_container.config_init" $ | indent 8 }}
{{- include "tezos.init_container.zerotier" $ | indent 8 }}
{{- include "tezos.init_container.config_generator" $ | indent 8 }}
{{- include "tezos.init_container.wait_for_dns" $ | indent 8 }}
{{- include "tezos.init_container.snapshot_downloader" $ | indent 8 }}
{{- include "tezos.init_container.snapshot_importer" $ | indent 8 }}
{{- include "tezos.init_container.tarball_downloader" $ | indent 8 }}
{{- include "tezos.init_container.config_init" $ | indent 8 }}
{{- include "tezos.init_container.zerotier" $ | indent 8 }}
{{- include "tezos.init_container.config_generator" $ | indent 8 }}
{{- include "tezos.init_container.wait_for_dns" $ | indent 8 }}
{{- include "tezos.init_container.snapshot_downloader" $ | indent 8 }}
{{- include "tezos.init_container.snapshot_importer" $ | indent 8 }}
{{- include "tezos.init_container.tarball_downloader" $ | indent 8 }}
securityContext:
fsGroup: 100
{{- include "tezos.nodeSelectorConfig" $ | indent 6 }}
Expand All @@ -46,7 +47,7 @@ spec:
name: dev-net-tun
- emptyDir: {}
name: config-volume
{{- if $val.local_storage | default false }}
{{- if $.node_vals.local_storage | default false }}
- emptyDir: {}
name: var-volume
{{- else }}
Expand All @@ -57,12 +58,12 @@ spec:
spec:
accessModes:
- ReadWriteOnce
{{- if $val.storageClassName }}
storageClassName: {{ $val.storageClassName }}
{{- if $.node_vals.storageClassName }}
storageClassName: {{ $.node_vals.storageClassName }}
{{- end }}
resources:
requests:
storage: {{ default "15Gi" $val.storage_size }}
storage: {{ default "15Gi" $.node_vals.storage_size }}
{{- end }}
---
{{- end }}
Expand Down
4 changes: 3 additions & 1 deletion charts/tezos/templates/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ spec:
ports:
- port: 8732
name: rpc
{{- with .Values.services.tezos_node_rpc.selector | default (dict "appType" "tezos-node") }}
selector:
appType: tezos-node
{{- toYaml . | nindent 4 }}
{{- end }}
type: NodePort
---
{{- range $key, $val := .Values.nodes }}
Expand Down
29 changes: 26 additions & 3 deletions charts/tezos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,20 @@ accounts: {}
## config.json. Run `tezos-node config --help` for more info.
## - "node_selector": Specify a kubernetes node selector in 'key: value' format
## for your tezos nodes.
## - "labels": https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
##
##
## defaults are filled in for most values.
## Defaults are filled in for most of the above values.
##
## E.g.:
## Example config:
##
# nodes:
# tezos-baking-node:
# labels:
# # Example labels you might use to specify certain attributes of your nodes.
# baking_node: "true" # This node types instances are baking nodes
# peer_node: "true" # Forward P2P traffic to this node types instances
# rpc_node: "true" # Forward RPC traffic to this node types instances
# node_selector:
# nodeSelectorKey: nodeSelectorValue
# storage_size: 15Gi
Expand All @@ -118,6 +124,10 @@ accounts: {}
# shell:
# history_mode: rolling
# tezos-node:
# labels:
# # Example labels you might use to specify certain attributes of your nodes.
# peer_node: "true"
# rpc_node: "true"
# images: # (optional field)
# tezedge: tezedge/tezedge:v...
# runs: ["tezedge_node"]
Expand All @@ -127,7 +137,10 @@ accounts: {}

nodes:
tezos-node:
storage_size: 15Gi
labels:
rpc_node: "true"
peer_node: "true"
storage_size: 100Gi
runs:
- octez_node
instances:
Expand All @@ -136,6 +149,16 @@ nodes:
shell:
history_mode: rolling

## Configuration for K8s Service resources. Configuring the labels selector of a
## service will result in the service forwarding traffic only to pods that have
## matching labels.
services:
## Configure the labels selector of the Tezos node RPC service. Traffic will
## be forwarded to all nodes if no labels are specified.
tezos_node_rpc:
selector:
rpc_node: "true"

# Define and use external remote signers.
# Bakers automatically use signers when configured.
signers: {}
Expand Down

0 comments on commit 4d1da02

Please sign in to comment.