From d5ae36b26fda97198022827e6240bd64758ab235 Mon Sep 17 00:00:00 2001 From: Chao Zhang Date: Fri, 28 Oct 2022 13:26:36 +0200 Subject: [PATCH 1/3] Add reources management for nodes --- charts/tezos/templates/_containers.tpl | 18 +++++++++++++--- charts/tezos/values.yaml | 8 +++++++ test/charts/mainnet.expect.yaml | 7 ++++++- test/charts/mainnet2.expect.yaml | 29 +++++++++++++++++++++++--- test/charts/mainnet2.in.yaml | 5 +++++ test/charts/private-chain.expect.yaml | 21 ++++++++++++++++--- 6 files changed, 78 insertions(+), 10 deletions(-) diff --git a/charts/tezos/templates/_containers.tpl b/charts/tezos/templates/_containers.tpl index bda72f5a2..60eeca78e 100644 --- a/charts/tezos/templates/_containers.tpl +++ b/charts/tezos/templates/_containers.tpl @@ -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,9 +246,11 @@ {{- 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 }} @@ -249,6 +260,7 @@ "type" "octez-node" "image" "octez" "with_config" 0 + "resources" $.node_vals.resources ) | nindent 0 }} {{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 884b7ea98..5c02d2fde 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -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 diff --git a/test/charts/mainnet.expect.yaml b/test/charts/mainnet.expect.yaml index 4a354b348..d36c25768 100644 --- a/test/charts/mainnet.expect.yaml +++ b/test/charts/mainnet.expect.yaml @@ -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" diff --git a/test/charts/mainnet2.expect.yaml b/test/charts/mainnet2.expect.yaml index be4a18332..ad1069047 100644 --- a/test/charts/mainnet2.expect.yaml +++ b/test/charts/mainnet2.expect.yaml @@ -90,6 +90,14 @@ data: } } ], + "resources": { + "limits": { + "memory": "16192Mi" + }, + "requests": { + "memory": "16192Mi" + } + }, "runs": [ "octez_node", "logger", @@ -293,7 +301,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" @@ -586,7 +599,12 @@ spec: readinessProbe: httpGet: path: /is_synced - port: 31732 + port: 31732 + resources: + limits: + memory: 16192Mi + requests: + memory: 16192Mi - name: logger image: "ghcr.io/oxheadalpha/tezos-k8s-utils:master" imagePullPolicy: IfNotPresent @@ -646,7 +664,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" diff --git a/test/charts/mainnet2.in.yaml b/test/charts/mainnet2.in.yaml index 9d521bff4..c73b77392 100644 --- a/test/charts/mainnet2.in.yaml +++ b/test/charts/mainnet2.in.yaml @@ -16,6 +16,11 @@ nodes: images: octez: tezos/tezos:v15-release runs: [ octez_node, logger, metrics ] + resources: + requests: + memory: 16192Mi + limits: + memory: 16192Mi instances: - config: shell: {history_mode: rolling} diff --git a/test/charts/private-chain.expect.yaml b/test/charts/private-chain.expect.yaml index 3d1f253c1..3479868c0 100644 --- a/test/charts/private-chain.expect.yaml +++ b/test/charts/private-chain.expect.yaml @@ -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" From ddc12a7ab5579a6ede793390920759df1ad51deb Mon Sep 17 00:00:00 2001 From: Chao Zhang Date: Fri, 23 Dec 2022 00:02:10 +0100 Subject: [PATCH 2/3] Update charts/tezos/values.yaml Co-authored-by: Aryeh Harris --- charts/tezos/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 5c02d2fde..ae3f95d36 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -188,7 +188,7 @@ should_generate_unsafe_deterministic_data: false # runs: # - octez_node # - baker -# # You can optionally set resources and limits for your octez node/baker +# # You can optionally set resources and limits for your octez node # # See: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ # resources: # requests: From 2889ad84258eb8ae23be783dcbb7fdc6a46d730e Mon Sep 17 00:00:00 2001 From: Chao Zhang Date: Fri, 23 Dec 2022 10:14:11 +0100 Subject: [PATCH 3/3] Move resource comment to proper section --- charts/tezos/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index ae3f95d36..d2cfaa92a 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -114,6 +114,8 @@ should_generate_unsafe_deterministic_data: false # using just "baker". # - "storage_size": the size of the PV # - "resources": resources specifications for the node. +# Optionally set resources and limits for octez node +# See: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ # - "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 @@ -188,8 +190,6 @@ should_generate_unsafe_deterministic_data: false # runs: # - octez_node # - baker -# # You can optionally set resources and limits for your octez node -# # See: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ # resources: # requests: # memory: 16192Mi