Skip to content

Commit 0bee988

Browse files
author
Alan Christie
committed
fix: Initial support for pos priority classes
1 parent a92db24 commit 0bee988

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

operator/handlers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
# The ingress class
3131
_DEFAULT_INGRESS_CLASS: str = "nginx"
3232

33+
# Apply Pod Priority class?
34+
# Any value results in setting the Pod's Priority Class
35+
_APPLY_POD_PRIORITY_CLASS: Optional[str] = os.environ.get("JO_APPLY_POD_PRIORITY_CLASS")
36+
# If set and JO_APPLY_POD_PRIORITY_CLASS is set
37+
# this value will be used if now alternative is available.
38+
_DEFAULT_POD_PRIORITY_CLASS: str = os.environ.get(
39+
"JO_DEFAULT_POD_PRIORITY_CLASS", "im-worker-medium"
40+
)
41+
42+
3343
# The cert-manager issuer,
3444
# expected if a INGRESS_TLS_SECRET is not defined.
3545
ingress_cert_issuer: Optional[str] = os.environ.get("INGRESS_CERT_ISSUER")
@@ -284,6 +294,12 @@ def create(spec: Dict[str, Any], name: str, namespace: str, **_: Any) -> Dict[st
284294
},
285295
}
286296

297+
# Insert a pod priority class?
298+
if _APPLY_POD_PRIORITY_CLASS:
299+
deployment_body["spec"]["template"]["spec"][
300+
"priorityClassName"
301+
] = _DEFAULT_POD_PRIORITY_CLASS
302+
287303
# Additional labels?
288304
# Provided by the DM as an array of strings of the form '<KEY>=<VALUE>'
289305
for label in material.get("labels", []):

roles/operator/defaults/main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ jo_dmapi_namespace: data-manager-api
3838
# Jupyter will be run on nodes that have labels keys and values defined here...
3939
jo_pod_node_selector_key: informaticsmatters.com/purpose-worker
4040
jo_pod_node_selector_value: 'yes'
41+
42+
# Apply Priority Class to Pods launched
43+
jo_apply_pod_priority_class: no

roles/operator/templates/deployment.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ spec:
3939
imagePullPolicy: IfNotPresent
4040
{% endif %}
4141
env:
42+
{% if jo_apply_pod_priority_class %}
43+
- name: JO_APPLY_POD_PRIORITY_CLASS
44+
value: 'true'
45+
{% endif %}
4246
- name: JO_POD_NODE_SELECTOR_KEY
4347
value: '{{ jo_pod_node_selector_key }}'
4448
- name: JO_POD_NODE_SELECTOR_VALUE

0 commit comments

Comments
 (0)