Expose CPU and Memory limits as variables
This is useful for applications that calculate internal values based on available memory. And it is especially useful in containers because majority of applications can not determine available memory correctly (they do not work with cgroups). Change-Id: Iadd0529d166ef1dad1697215bbc181104a7b926e
This commit is contained in:
parent
a67f526fcb
commit
5f20f7e6db
|
@ -120,7 +120,24 @@ def serialize_env_variables(container):
|
|||
"fieldPath": "metadata.name"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "CPU_LIMIT",
|
||||
"valueFrom": {
|
||||
"resourceFieldRef": {
|
||||
"resource": "limits.cpu"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "MEMORY_LIMIT",
|
||||
"valueFrom": {
|
||||
"resourceFieldRef": {
|
||||
"resource": "limits.memory"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
if container.get('env'):
|
||||
env.extend(container['env'])
|
||||
|
|
|
@ -88,6 +88,22 @@ class TestDeploy(base.TestCase):
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'CPU_LIMIT',
|
||||
'valueFrom': {
|
||||
'resourceFieldRef': {
|
||||
'resource': 'limits.cpu'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'MEMORY_LIMIT',
|
||||
'valueFrom': {
|
||||
'resourceFieldRef': {
|
||||
'resource': 'limits.memory'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "env_foo",
|
||||
"valueFrom": {
|
||||
|
|
Loading…
Reference in New Issue