Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reources management for nodes #508

Merged
merged 3 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions charts/tezos/templates/_containers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved
*/ -}}

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

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


Expand Down Expand Up @@ -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") -}}
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved
{{- include "tezos.generic_container" (dict "root" $
"type" "sidecar"
"image" "utils"
"resources" $sidecarResources
) | nindent 0 }}
{{- end }}
{{- end }}
Expand All @@ -249,6 +260,7 @@
"type" "octez-node"
"image" "octez"
"with_config" 0
"resources" $.node_vals.resources
) | nindent 0 }}
{{- end }}

Expand Down
8 changes: 8 additions & 0 deletions charts/tezos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ 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.
# 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
Expand Down Expand Up @@ -187,6 +190,11 @@ should_generate_unsafe_deterministic_data: false
# runs:
# - octez_node
# - baker
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved
# resources:
# requests:
# memory: 16192Mi
# limits:
# memory: 16192Mi
# instances:
# - bake_using_account: baker0
# is_bootstrap_node: true
Expand Down
7 changes: 6 additions & 1 deletion test/charts/mainnet.expect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 26 additions & 3 deletions test/charts/mainnet2.expect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ data:
}
}
],
"resources": {
"limits": {
"memory": "16192Mi"
},
"requests": {
"memory": "16192Mi"
}
},
"runs": [
"octez_node",
"logger",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions test/charts/mainnet2.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
21 changes: 18 additions & 3 deletions test/charts/private-chain.expect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down