Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reources management for nodes
Browse files Browse the repository at this point in the history
puppetninja committed Dec 22, 2022
1 parent cec5cd8 commit d291af7
Showing 5 changed files with 66 additions and 14 deletions.
30 changes: 22 additions & 8 deletions charts/tezos/templates/_containers.tpl
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@
* with_config bring in the configMap defaults true only on utils.
* with_secret bring in the secrets map including the identities.
* localvars set env vars MY_* Defaults to true only on utils.
* resources set container resources management, i.e. request
* and limit, default value is an empty dict.
*/ -}}

{{- define "tezos.generic_container" }}
@@ -75,6 +77,9 @@
{{- $_ := set . "args" (list .type) }}
{{- end }}
{{- end }}
{{- if not (hasKey . "resources") }}
{{- $_ := set . "resources" dict }}
{{- end }}

{{- /*
* And, now, we generate the YAML:
@@ -164,6 +169,10 @@
port: 31732
{{- end }}
{{- end }}
{{- if .resources }}
resources:
{{ toYaml .resources | indent 4 }}
{{- end }}
{{- end }}


@@ -237,19 +246,24 @@

{{- define "tezos.container.sidecar" }}
{{- if or (not (hasKey $.node_vals "readiness_probe")) $.node_vals.readiness_probe }}
{{- include "tezos.generic_container" (dict "root" $
"type" "sidecar"
"image" "utils"
{{- $sidecarResources := dict "requests" (dict "memory" "80Mi") "limits" (dict "memory" "100Mi") -}}
{{- include "tezos.generic_container" (dict "root" $
"type" "sidecar"
"image" "utils"
"resources" $sidecarResources
) | nindent 0 }}
{{- end }}
{{- end }}

{{- define "tezos.container.node" }}
{{- include "tezos.generic_container" (dict "root" $
"type" "octez-node"
"image" "octez"
"with_config" 0
) | nindent 0 }}
{{- include "tezos.generic_container" (dict "root" $
"name" (print "baker-"
(lower .command))
"type" "baker"
"image" "octez"
"with_config" 0
"resources" $.node_vals.resources
) | nindent 0 }}
{{- end }}

{{- define "tezos.container.bakers" }}
8 changes: 8 additions & 0 deletions charts/tezos/values.yaml
Original file line number Diff line number Diff line change
@@ -113,6 +113,7 @@ should_generate_unsafe_deterministic_data: false
# bakers and accusers, so "baker-011-pthangz2" is configured
# using just "baker".
# - "storage_size": the size of the PV
# - "resources": resources specifications for the node.
# - "images": Optional specification of images to use for the tezos node and
# baker. Options are "octez" with a tezos/tezos image.
# If no images are provided, the containers will default to the images
@@ -187,6 +188,13 @@ should_generate_unsafe_deterministic_data: false
# runs:
# - octez_node
# - baker
# # You can optionally set resources and limits for your octez node/baker
# # See: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
# resources:
# requests:
# memory: 16192Mi
# limits:
# memory: 16192Mi
# instances:
# - bake_using_account: baker0
# is_bootstrap_node: true
7 changes: 6 additions & 1 deletion test/charts/mainnet.expect.yaml
Original file line number Diff line number Diff line change
@@ -198,7 +198,12 @@ spec:
- mountPath: /etc/tezos
name: config-volume
- mountPath: /var/tezos
name: var-volume
name: var-volume
resources:
limits:
memory: 100Mi
requests:
memory: 80Mi
initContainers:
- name: config-init
image: "tezos/tezos:v15-release"
14 changes: 12 additions & 2 deletions test/charts/mainnet2.expect.yaml
Original file line number Diff line number Diff line change
@@ -293,7 +293,12 @@ spec:
- mountPath: /etc/tezos
name: config-volume
- mountPath: /var/tezos
name: var-volume
name: var-volume
resources:
limits:
memory: 100Mi
requests:
memory: 80Mi
initContainers:
- name: config-init
image: "tezos/tezos:v15-release"
@@ -646,7 +651,12 @@ spec:
- mountPath: /etc/tezos
name: config-volume
- mountPath: /var/tezos
name: var-volume
name: var-volume
resources:
limits:
memory: 100Mi
requests:
memory: 80Mi
initContainers:
- name: config-init
image: "tezos/tezos:v15-release"
21 changes: 18 additions & 3 deletions test/charts/private-chain.expect.yaml
Original file line number Diff line number Diff line change
@@ -375,7 +375,12 @@ spec:
- mountPath: /etc/tezos
name: config-volume
- mountPath: /var/tezos
name: var-volume
name: var-volume
resources:
limits:
memory: 100Mi
requests:
memory: 80Mi
initContainers:
- name: config-generator
image: "ghcr.io/oxheadalpha/tezos-k8s-utils:master"
@@ -665,7 +670,12 @@ spec:
- mountPath: /etc/tezos
name: config-volume
- mountPath: /var/tezos
name: var-volume
name: var-volume
resources:
limits:
memory: 100Mi
requests:
memory: 80Mi
initContainers:
- name: config-generator
image: "ghcr.io/oxheadalpha/tezos-k8s-utils:master"
@@ -926,7 +936,12 @@ spec:
- mountPath: /etc/tezos
name: config-volume
- mountPath: /var/tezos
name: var-volume
name: var-volume
resources:
limits:
memory: 100Mi
requests:
memory: 80Mi
initContainers:
- name: config-generator
image: "ghcr.io/oxheadalpha/tezos-k8s-utils:master"

0 comments on commit d291af7

Please sign in to comment.