Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soufianej taint k3s #291

Merged
merged 2 commits into from
Jun 29, 2024
Merged

Soufianej taint k3s #291

merged 2 commits into from
Jun 29, 2024

Conversation

JOUNAIDSoufiane
Copy link
Contributor

@JOUNAIDSoufiane JOUNAIDSoufiane commented Jun 14, 2024

Added k8s worker taint configuration options

The options to add to site-config are:

  • doni_enable_worker_taint: true/false, by default set to false (enables worker tainting through
    the k8s worker on doni devices)
  • zun_tolerate_worker_taint: true/false, by default set to false (enables taint enforcement by
    adding tolerations to worker pods)
  • k8s_worker_taint
    • key: taint key, by default set to "worker-node"
    • value: taint value, by default set to "true"
    • effect: taint effect, by default set to "NoSchedule"

Added taint tolerations to core deployments in k3s

k3s defaults.yaml gets the value of k3s_worker_taint from worker_taint
which is defined under kolla/defaults.yml which subsequently defines
defaults for the option and takes in site values from the
k8s_worker_taint option that can be specified through the site config.

Added worker node taint toleration to smarter devices manager
daemonsets.

Furthermore, templated the nvidia device plugin daemonset and added the
toleration there as well.

Taint deployment strategy on a running testbed:

  1. Redeploy k3s playbook to apply tolerations to and relaunch the core daemonsets running on the worker nodes
  2. Set zun_tolerate_worker_taint to True and redeploy Zun
  3. Finally, set doni_enable_worker_taint to True and redeploy

The above sequence ensures that no existing or simultaneous user pods get evicted and inflicts minimal downtime to core daemonsets.

@msherman64
Copy link
Contributor

Requires code from:

Zun: ChameleonCloud/zun#20
Doni: ChameleonCloud/doni#138

Order to apply is:

  1. pull and deploy new zun
  2. pull and deploy new doni
  3. deploy this PR

@msherman64
Copy link
Contributor

note: add worker_node_taint with a | default(something) to kolla/defaults.yml

Copy link
Contributor

@msherman64 msherman64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall LGTM, but with the following caveats:

  1. the noted refactoring of how the taint/toleration is specified, to avoid repeating logic throughout the jinja templates
  2. related to the integration with doni and zun: I would suggest adding two flags:

doni_enforce_worker_taints: false
zun_enforce_worker_taints: false

Then, separate from the deployed container versions, the operator can first toggle on the zun support, and then toggle on the doni support, to avoid unexpected breakage.

Finally, is there a migration procedure to ensure currently running/deployed containers are not un-scheduled when this is deployed?
Do we have docs on how to trigger doni to deploy the new annotation? How can an operator check if some otherwise "good" nodes aren't available because they are/aren't tainted correctly?

Comment on lines 72 to 76
tolerations:
- key: "{{ k3s_worker_taint.split('=')[0] }}"
operator: "Equal"
value: "{{ k3s_worker_taint.split('=')[1].split(':')[0] }}"
effect: "{{ k3s_worker_taint.split(':')[1] }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is difficult to maintain jinja templates containing logic.

I suggest putting lines into kolla/defaults.yml instead:

k3s_worker_taint_key:
k3s_worker_taint_value:
k3s_worker_taint_effect:

If necessary, you can also use those to template the string format, also in defaults.yml

# format like 'worker-node=true:NoSchedule'
k3s_worker_taint: "{{ k3s_worker_taint_key }}={{ k3s_worker_taint_value }}:{{ k3s_worker_taint_effect}}"

Comment on lines 70 to 74
tolerations:
- key: "{{ k3s_worker_taint.split('=')[0] }}"
operator: "Equal"
value: "{{ k3s_worker_taint.split('=')[1].split(':')[0] }}"
effect: "{{ k3s_worker_taint.split(':')[1] }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest refactor as per above comment

Comment on lines 45 to 48
- key: "{{ k3s_worker_taint.split('=')[0] }}"
operator: "Equal"
value: "{{ k3s_worker_taint.split('=')[1].split(':')[0] }}"
effect: "{{ k3s_worker_taint.split(':')[1] }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest refactor as per above comment

Copy link
Contributor

@msherman64 msherman64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments, mostly just naming/nits for consistency and to avoid confusing future me?

@@ -92,6 +92,7 @@ enable_cinder: no

# Doni
enable_doni: yes
doni_enforce_worker_taints: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remnant from a merge :(, I'll change it

@@ -345,6 +346,10 @@ enable_k3s: no
enable_zun: no
enable_zun_compute_k8s: "{{ enable_zun | bool and enable_k3s | bool }}"
blazar_enable_device_plugin_k8s: "{{ enable_k3s | bool }}"
# K8S worker tainting
zun_enforce_worker_taint: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be zun_tolerate_worker_taint? afaik it will not prevent scheduling even if no workers are tainted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

# K8S worker tainting
zun_enforce_worker_taint: false
doni_enable_worker_taint: false
worker_taint: "{{ k8s_worker_taint.key | default('worker-node') }}={{ k8s_worker_taint.value | default('true') }}:{{ k8s_worker_taint.effect | default('NoSchedule') }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a string or a dict? you reference worker_taint.key in doni.conf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a dict, looks like my merge was a little destructive

@JOUNAIDSoufiane JOUNAIDSoufiane force-pushed the soufianej-taint-k3s branch 3 times, most recently from 0c33ef9 to 93cfd5d Compare June 26, 2024 17:50
The options to add to site-config are:
- doni_enable_worker_taint: true/false, by default set to false (enables worker tainting through
  the k8s worker on doni devices)
- zun_tolerate_worker_taint: true/false, by default set to false (enables taint enforcement by
  adding tolerations to worker pods)
- k8s_worker_taint
  - key: taint key, by default set to "worker-node"
  - value: taint value, by default set to "true"
  - effect: taint effect, by default set to "NoSchedule"
k3s defaults.yaml gets the value of k3s_worker_taint from worker_taint
which is defined under kolla/defaults.yml which subsequently defines
defaults for the option and takes in site values from the
k8s_worker_taint option that can be specified through the site config.

Added worker node taint toleration to smarter devices manager
daemonsets.

Furthermore, templated the nvidia device plugin daemonset and added the
toleration there as well.
@JOUNAIDSoufiane JOUNAIDSoufiane merged commit 6aaf946 into stable/xena Jun 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants