Skip to content

Commit

Permalink
update resource directive to use directly cpu and memory, optionally …
Browse files Browse the repository at this point in the history
…support full resource object as well, update all examples and tests (#134)
  • Loading branch information
Anmol1696 authored Jun 29, 2023
1 parent 2538fe2 commit d6e8724
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 196 deletions.
24 changes: 21 additions & 3 deletions charts/devnet/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ Usage:
echo "Ready to start"
exit 0
resources:
{{ toYaml .context.Values.resources.wait | indent 4 }}
{{- include "getResourceObject" .context.Values.resources.wait | indent 4 }}
{{- end }}

{{/*
Returns resources for a validator
*/}}
{{- define "devnet.node.resources" }}
{{- if hasKey .node "resources" }}
{{ toYaml .node.resources }}
{{- include "getResourceObject" .node.resources }}
{{- else }}
{{ toYaml .context.Values.resources.node }}
{{- include "getResourceObject" .context.Values.resources.node }}
{{- end }}
{{- end }}

Expand Down Expand Up @@ -178,3 +178,21 @@ Returns a comma seperated list of urls for the Exposer address
{{- end -}}
{{ join "," $values }}
{{- end -}}

{{/*
Returns a resource object based on the input resource
Usage:
{{ include "getResourceObject" .Values.resources }}
*/}}
{{- define "getResourceObject" -}}
{{- if hasKey . "cpu" }}
limits:
cpu: {{ .cpu }}
memory: {{ .memory }}
requests:
cpu: {{ .cpu }}
memory: {{ .memory }}
{{- else }}
{{ toYaml . }}
{{- end }}
{{- end }}
6 changes: 2 additions & 4 deletions charts/devnet/templates/chain/genesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ spec:
- name: EXPOSER_PRIV_VAL_FILE
value: {{ $chain.home }}/config/priv_validator_key.json
command: [ "/app/exposer/exposer" ]
resources:
{{ toYaml $.Values.exposer.resources | nindent 12 }}
resources: {{- include "getResourceObject" $.Values.exposer.resources | trim | nindent 12 }}
volumeMounts:
- mountPath: {{ $chain.home }}
name: node
Expand Down Expand Up @@ -235,8 +234,7 @@ spec:
volumeMounts:
- mountPath: /configs
name: addresses
resources:
{{ toYaml $faucet.resources | nindent 12 }}
resources: {{- include "getResourceObject" $faucet.resources | trim | nindent 12 }}
readinessProbe:
httpGet:
path: /status
Expand Down
2 changes: 1 addition & 1 deletion charts/devnet/templates/chain/validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ spec:
- name: EXPOSER_PRIV_VAL_FILE
value: {{ $chain.home }}/config/priv_validator_key.json
command: [ "/app/exposer/exposer" ]
resources: {{- toYaml $.Values.exposer.resources | nindent 12 }}
resources: {{- include "getResourceObject" $.Values.exposer.resources | trim | nindent 12 }}
volumeMounts:
- mountPath: {{ $chain.home }}
name: node
Expand Down
2 changes: 1 addition & 1 deletion charts/devnet/templates/collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
value: /opt/collector
command: [ "collector" ]
resources:
{{ toYaml .Values.collector.resources | indent 12 }}
{{- include "getResourceObject" .Values.collector.resources | indent 12 }}
volumeMounts:
- mountPath: /opt/collector
name: collector
Expand Down
2 changes: 1 addition & 1 deletion charts/devnet/templates/explorer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
- |
yarn serve --host 0.0.0.0 --port 8080
resources:
{{ toYaml .Values.explorer.resources | indent 12 }}
{{- include "getResourceObject" .Values.explorer.resources | indent 12 }}
volumeMounts:
- mountPath: /home/explorer/chains/mainnet
name: explorer-configs
Expand Down
2 changes: 1 addition & 1 deletion charts/devnet/templates/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ spec:
- name: REGISTRY_CHAIN_CLIENT_EXPOSERS
value: "{{ include "devnet.chains.exposer.addrs" . }}"
resources:
{{ toYaml .Values.registry.resources | indent 12 }}
{{- include "getResourceObject" .Values.registry.resources | indent 12 }}
volumeMounts:
{{- range $chain := .Values.chains }}
- mountPath: /configs/{{ $chain.name }}
Expand Down
3 changes: 1 addition & 2 deletions charts/devnet/templates/relayers/hermes/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ spec:
name: keys
- mountPath: /scripts
name: scripts
resources:
{{ toYaml $.Values.resources.init | indent 12 }}
resources: {{- include "devnet.node.resources" ( dict "node" $relayer "context" $ ) | trim | nindent 12 }}
containers:
- name: relayer
image: {{ $relayer.image | default $defaultRelayer.image }}
Expand Down
3 changes: 1 addition & 2 deletions charts/devnet/templates/relayers/ts-relayer/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ spec:
name: keys
- mountPath: /scripts
name: scripts
resources:
{{ toYaml $.Values.resources.init | indent 12 }}
resources: {{- include "devnet.node.resources" ( dict "node" $relayer "context" $ ) | trim | nindent 12 }}
containers:
- name: relayer
image: {{ $relayer.image | default $defaultRelayer.image }}
Expand Down
48 changes: 12 additions & 36 deletions charts/devnet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,27 @@ resources:
node:
# Default values for resources for chain and validator nodes
# Preference would be given to the resources directive in chain/relayer
limits:
cpu: "0.5"
memory: "500M"
requests:
cpu: "0.5"
memory: "500M"
cpu: "0.5"
memory: "500M"
wait:
limits:
cpu: "0.1"
memory: "100M"
requests:
cpu: "0.1"
memory: "100M"
cpu: "0.1"
memory: "100M"

exposer:
image: ghcr.io/cosmology-tech/starship/exposer:20230617-eea58bd
ports:
rest: 8081
resources:
limits:
cpu: "0.2"
memory: "200M"
requests:
cpu: "0.2"
memory: "200M"
cpu: "0.2"
memory: "200M"

faucet:
image: ghcr.io/cosmology-tech/starship/cosmjs-faucet:v0.31.0
ports:
rest: 8000
resources:
limits:
cpu: "0.2"
memory: "200M"
requests:
cpu: "0.2"
memory: "200M"
cpu: "0.2"
memory: "200M"

# Chain timeouts
timeouts:
Expand Down Expand Up @@ -356,12 +340,8 @@ explorer:
# at runtime (with custom configs). Anything bellow 2Gi will crash the pods on startup
# todo: make this more efficient with faster startuptime
resources:
limits:
cpu: "1"
memory: "2Gi"
requests:
cpu: "1"
memory: "2Gi"
cpu: "1"
memory: "2Gi"

registry:
enabled: false
Expand All @@ -370,12 +350,8 @@ registry:
rest: 6060
grpc: 7070
resources:
limits:
cpu: "0.2"
memory: "200M"
requests:
cpu: "0.2"
memory: "200M"
cpu: "0.2"
memory: "200M"

collector:
enabled: false
16 changes: 4 additions & 12 deletions examples/cosmos-simapp-multi/configs/devnet-30.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ chains:
# only a single faucet is spun up with the genesis node, so resources wont multiply
# with the number of validators
resources:
limits:
cpu: "0.4"
memory: "500M"
requests:
cpu: "0.4"
memory: "500M"
cpu: "0.4"
memory: "500M"

registry:
enabled: true
Expand All @@ -32,9 +28,5 @@ explorer:

exposer:
resources:
limits:
cpu: "0.1"
memory: "100M"
requests:
cpu: "0.1"
memory: "100M"
cpu: "0.1"
memory: "100M"
8 changes: 2 additions & 6 deletions examples/cosmos-simapp-multi/configs/local-custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ chains:
faucet:
image: ghcr.io/cosmology-tech/starship/cosmjs-faucet:v0.31.0-alpha.2
resources:
limits:
cpu: "1"
memory: "2Gi"
requests:
cpu: "1"
memory: "2Gi"
cpu: "1"
memory: "2Gi"

registry:
enabled: true
Expand Down
8 changes: 2 additions & 6 deletions examples/cosmos-simapp-multi/configs/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ chains:
faucet:
image: ghcr.io/cosmology-tech/starship/cosmjs-faucet:v0.31.0-alpha.2
resources:
limits:
cpu: "1"
memory: "2Gi"
requests:
cpu: "1"
memory: "2Gi"
cpu: "1"
memory: "2Gi"

registry:
enabled: true
Expand Down
49 changes: 12 additions & 37 deletions examples/getting-started/configs/tiny-starship.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,17 @@ chains:
rest: 1313
rpc: 26653
resources:
limits:
cpu: "0.3"
memory: "300M"
requests:
cpu: "0.3"
memory: "300M"
cpu: "0.3"
memory: "300M"
- name: gaia-1
type: cosmos
numValidators: 1
ports:
rest: 1317
rpc: 26657
resources:
limits:
cpu: "0.3"
memory: "300M"
requests:
cpu: "0.3"
memory: "300M"
cpu: "0.3"
memory: "300M"

relayers:
- name: osmos-gaia
Expand All @@ -34,41 +26,24 @@ relayers:
- osmosis-1
- gaia-1
resources:
limits:
cpu: "0.1"
memory: "100M"
requests:
cpu: "0.1"
memory: "100M"
cpu: "0.1"
memory: "100M"

registry:
enabled: true
ports:
rest: 8081
resources:
limits:
cpu: "0.1"
memory: "100M"
requests:
cpu: "0.1"
memory: "100M"
cpu: "0.1"
memory: "100M"

# configure default resources
resources:
node:
resources:
limits:
cpu: "0.3"
memory: "300M"
requests:
cpu: "0.3"
memory: "300M"
cpu: "0.3"
memory: "300M"

exposer:
resources:
limits:
cpu: "0.1"
memory: "100M"
requests:
cpu: "0.1"
memory: "100M"
cpu: "0.1"
memory: "100M"
8 changes: 2 additions & 6 deletions examples/upgrade-test/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ chains:
rpc: 26657
rest: 1317
resources:
limits:
cpu: "1"
memory: "1Gi"
requests:
cpu: "1"
memory: "1Gi"
cpu: "1"
memory: "1Gi"

relayers:
- name: persistence-gaia
Expand Down
8 changes: 2 additions & 6 deletions tests/configs/build-chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ chains:
# Minimum resources required is 1 CPU and 1 GB Ram, if resources are not
# increased, pods will crash. Takes around 8 mins to spin up
resources:
limits:
cpu: "2"
memory: "2Gi"
requests:
cpu: "2"
memory: "2Gi"
cpu: "2"
memory: "2Gi"

relayers:
- name: persistence-cosmos
Expand Down
Loading

0 comments on commit d6e8724

Please sign in to comment.