|
19 | 19 |
|
20 | 20 | from coldfront_plugin_cloud import attributes, base, utils |
21 | 21 |
|
| 22 | +QUOTA_OPENSHIFT = { |
| 23 | +":requests.cpu": { "base": 2, "coefficient": 0 }, |
| 24 | +":requests.memory": { "base": 2, "coefficient": 0 }, |
| 25 | +":limits.cpu": { "base": 2, "coefficient": 0 }, |
| 26 | +":limits.memory": { "base": 2, "coefficient": 0 }, |
| 27 | +":requests.storage": { "base": 2, "coefficient": 0, "units": "Gi" }, |
| 28 | +":limits.storage": { "base": 2, "coefficient": 0, "units": "Gi" }, |
| 29 | +":requests.ephemeral-storage": { "base": 2, "coefficient": 8, "units": "Gi" }, |
| 30 | +":requests.nvidia.com/gpu": { "base": 0, "coefficient": 0 }, |
| 31 | +":limits.ephemeral-storage": { "base": 2, "coefficient": 8, "units": "Gi" }, |
| 32 | +":persistentvolumeclaims": { "base": 2, "coefficient": 0 }, |
| 33 | +":replicationcontrollers": { "base": 2, "coefficient": 0 }, |
| 34 | +":resourcequotas": { "base": 5, "coefficient": 0 }, |
| 35 | +":services": { "base": 4, "coefficient": 0 }, |
| 36 | +":services.loadbalancers": { "base": 2, "coefficient": 0 }, |
| 37 | +":services.nodeports": { "base": 2, "coefficient": 0 }, |
| 38 | +":secrets": { "base": 4, "coefficient": 0 }, |
| 39 | +":configmaps": { "base": 4, "coefficient": 0 }, |
| 40 | +":openshift.io/imagestreams": { "base": 2, "coefficient": 0 }, |
| 41 | +"BestEffort:pods": { "base": 2, "coefficient": 2 }, |
| 42 | +"NotBestEffort:pods": { "base": 2, "coefficient": 2 }, |
| 43 | +"NotBestEffort:requests.memory": { "base": 2, "coefficient": 4, "units": "Gi" }, |
| 44 | +"NotBestEffort:limits.memory": { "base": 2, "coefficient": 4, "units": "Gi" }, |
| 45 | +"NotBestEffort:requests.cpu": { "base": 2, "coefficient": 2 }, |
| 46 | +"NotBestEffort:limits.cpu": { "base": 2, "coefficient": 2 }, |
| 47 | +"Terminating:pods": { "base": 2, "coefficient": 2 }, |
| 48 | +"Terminating:requests.memory": { "base": 2, "coefficient": 4, "units": "Gi" }, |
| 49 | +"Terminating:limits.memory": { "base": 2, "coefficient": 4, "units": "Gi" }, |
| 50 | +"Terminating:requests.cpu": { "base": 2, "coefficient": 2 }, |
| 51 | +"Terminating:limits.cpu": { "base": 2, "coefficient": 2 }, |
| 52 | +"NotTerminating:pods": { "base": 2, "coefficient": 2 }, |
| 53 | +"NotTerminating:requests.memory": { "base": 2, "coefficient": 4, "units": "Gi" }, |
| 54 | +"NotTerminating:limits.memory": { "base": 2, "coefficient": 4, "units": "Gi" }, |
| 55 | +"NotTerminating:requests.cpu": { "base": 2, "coefficient": 2 }, |
| 56 | +"NotTerminating:limits.cpu": { "base": 2, "coefficient": 2 } |
| 57 | +} |
| 58 | + |
| 59 | +LIMITS_OPENSHIFT = [ |
| 60 | + { |
| 61 | + "type": "Container", |
| 62 | + "default": { |
| 63 | + "cpu": "2", |
| 64 | + "memory": "1024Mi", |
| 65 | + "nvidia.com/gpu": "0" |
| 66 | + }, |
| 67 | + "defaultRequest": { |
| 68 | + "cpu": "1", |
| 69 | + "memory": "512Mi", |
| 70 | + "nvidia.com/gpu": "0" |
| 71 | + } |
| 72 | + } |
| 73 | +] |
| 74 | + |
22 | 75 | QUOTA_KEY_MAPPING = { |
23 | 76 | attributes.QUOTA_LIMITS_CPU: lambda x: {":limits.cpu": f"{x * 1000}m"}, |
24 | 77 | attributes.QUOTA_LIMITS_MEMORY: lambda x: {":limits.memory": f"{x}Mi"}, |
@@ -76,10 +129,11 @@ def __init__( |
76 | 129 | logger = logging.getLogger() |
77 | 130 | else: |
78 | 131 | logger = logging.getLogger("django") |
| 132 | + |
79 | 133 | config = env_config() |
80 | 134 |
|
81 | 135 | self.client = moc_openshift.MocOpenShift4x( |
82 | | - DynamicClient(k8s_client), logger, config |
| 136 | + DynamicClient(k8s_client), logger, config, QUOTA_OPENSHIFT, LIMITS_OPENSHIFT |
83 | 137 | ) |
84 | 138 |
|
85 | 139 | @functools.cached_property |
|
0 commit comments