Skip to content

Commit

Permalink
Merge pull request #77 from francescotimperi/feature-231
Browse files Browse the repository at this point in the history
  • Loading branch information
francescotimperi authored Jul 9, 2023
2 parents fe7646e + 3ace354 commit 472638a
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 9 deletions.
71 changes: 70 additions & 1 deletion deploy/nuvolaris-permissions/whisk-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,34 @@ spec:
type: integer
required:
- blackbox-fraction
- timeout-factor
- timeout-factor
couchdb:
description: configure couchdb limits
type: object
properties:
resources:
description: resource limits specification for the controller container
type: object
properties:
cpu-req:
description: container cpu requested resources. Defaulted to 2
type: string
cpu-lim:
description: max container cpu allowed resources. Defaulted to 4
type: string
mem-req:
description: container memory requested. Defaulted to 1G
type: string
mem-lim:
description: container container max memory allowed. Defaulted to 2G
type: string
required:
- cpu-req
- cpu-lim
- mem-req
- mem-lim
required:
- resources
controller:
description: configure the OW controller
type: object
Expand All @@ -474,6 +501,27 @@ spec:
- WARN
- ERROR
- TRACE
resources:
description: resource limits specification for the controller container
type: object
properties:
cpu-req:
description: container cpu requested resources. Defaulted to 2
type: string
cpu-lim:
description: max container cpu allowed resources. Defaulted to 4
type: string
mem-req:
description: container memory requested. Defaulted to 1G
type: string
mem-lim:
description: container container max memory allowed. Defaulted to 2G
type: string
required:
- cpu-req
- cpu-lim
- mem-req
- mem-lim
required:
- javaOpts
invoker:
Expand Down Expand Up @@ -501,6 +549,27 @@ spec:
type: string
required:
- userMemory
resources:
description: resource limits specification for the controller container
type: object
properties:
cpu-req:
description: container cpu requested resources. Defaulted to 2
type: string
cpu-lim:
description: max container cpu allowed resources. Defaulted to 4
type: string
mem-req:
description: container memory requested. Defaulted to 1G
type: string
mem-lim:
description: container container max memory allowed. Defaulted to 2G
type: string
required:
- cpu-req
- cpu-lim
- mem-req
- mem-lim
required:
- javaOpts
- containerPool
Expand Down
6 changes: 5 additions & 1 deletion nuvolaris/couchdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def create(owner=None):
"name": "couchdb",
"size": cfg.get("couchdb.volume-size", "COUCHDB_VOLUME_SIZE", 10),
"dir": "/opt/couchdb/data",
"storageClass": cfg.get("nuvolaris.storageClass")
"storageClass": cfg.get("nuvolaris.storageClass"),
"container_cpu_req": cfg.get('configs.couchdb.resources.cpu-req') or "1",
"container_cpu_lim": cfg.get('configs.couchdb.resources.cpu-lim') or "2",
"container_mem_req": cfg.get('configs.couchdb.resources.mem-req') or "1G",
"container_mem_lim": cfg.get('configs.couchdb.resources.mem-lim') or "2G"
}

kus.processTemplate("couchdb","couchdb-set-tpl.yaml",data,"couchdb-set_generated.yaml")
Expand Down
12 changes: 7 additions & 5 deletions nuvolaris/templates/couchdb-set-tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ spec:
drop:
- ALL
imagePullPolicy: "Always"
resources:
requests:
memory: "1G"
limits:
memory: "4G"
{% else %}
imagePullPolicy: "IfNotPresent"
{% endif %}
resources:
requests:
memory: "{{container_mem_req}}"
cpu : "{{container_cpu_req}}"
limits:
memory: "{{container_mem_lim}}"
cpu : "{{container_cpu_lim}}"
ports:
- name: couchdb
containerPort: 5984
Expand Down
9 changes: 8 additions & 1 deletion nuvolaris/templates/standalone-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
- name: controller
imagePullPolicy: "IfNotPresent"
image: "ghcr.io/nuvolaris/openwhisk-controller:0.3.0-morpheus.22122609"
command: ["/bin/bash", "-c", "/init.sh `hostname | awk -F '-' '{print $NF}'`"]
command: ["/bin/bash", "-c", "/init.sh `hostname | awk -F '-' '{print $NF}'`"]
ports:
- name: controller
containerPort: 8080
Expand Down Expand Up @@ -73,6 +73,13 @@ spec:
capabilities:
drop:
- ALL
resources:
requests:
memory: "{{container_mem_req}}"
cpu : "{{container_cpu_req}}"
limits:
memory: "{{container_mem_lim}}"
cpu : "{{container_cpu_lim}}"
env:

- name: "PORT"
Expand Down
2 changes: 1 addition & 1 deletion nuvolaris/user_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def whisk_user_create(spec, name, **kwargs):
minio.create_ow_storage(state, ucfg, user_metadata, owner)

if(cfg.get('components.minio') and ucfg.get('object-storage.route.enabled') and cfg.get('components.static')):
res = static.create_ow_static_endpoint(ucfg,owner)
res = static.create_ow_static_endpoint(ucfg,user_metadata, owner)
logging.info(f"OpenWhisk static endpoint for {ucfg.get('namespace')} added = {res}")
state['static']= res

Expand Down
4 changes: 4 additions & 0 deletions nuvolaris/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def get_standalone_config_data():
"concurrency_limit_std": cfg.get("configs.limits.concurrency.limit-std") or 1,
"concurrency_limit_max": cfg.get("configs.limits.concurrency.limit-max") or 1,
"controller_java_opts": cfg.get('configs.controller.javaOpts') or "-Xmx2048M",
"container_cpu_req": cfg.get('configs.controller.resources.cpu-req') or "1",
"container_cpu_lim": cfg.get('configs.controller.resources.cpu-lim') or "2",
"container_mem_req": cfg.get('configs.controller.resources.mem-req') or "1G",
"container_mem_lim": cfg.get('configs.controller.resources.mem-lim') or "2G"
}
return data

Expand Down
11 changes: 11 additions & 0 deletions tests/kind/whisk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ spec:
fires-perMinute: 999
controller:
javaOpts: "-Xmx2048M"
resources:
cpu-req: 1
cpu-lim: 2
mem-req: "1G"
mem-lim: "2G"
couchdb:
resources:
cpu-req: 1
cpu-lim: 2
mem-req: "512M"
mem-lim: "1G"
redis:
volume-size: 10
default:
Expand Down

0 comments on commit 472638a

Please sign in to comment.