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

docs: add some complete samples for node_labels and dynamic vars render by inventory group #11806

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/ansible/vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ node_labels:
label2_name: label2_value
```

Example of `node_labels` definition in `inventory.ini` format:

```toml
Comment on lines +261 to +263
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't be toml and ini ^.

Also, IMO that kind of vars is much more readable in yaml.

[sample_inventory_group:vars]
node_labels={"label1_name":"label1_value", "label2_name":"label2_value"}
```

* *node_taints* - Taints applied to nodes via `kubectl taint node`.
For example, taints can be set in the inventory as variables or more widely in group_vars.
*node_taints* has to be defined as a list of strings in format `key=value:effect`, e.g.:
Expand Down
5 changes: 3 additions & 2 deletions inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@ persistent_volumes_enabled: false
## Important: if you use Ubuntu then you should set in all.yml 'docker_storage_options: -s overlay2'
## Array with nvida_gpu_nodes, leave empty or comment if you don't want to install drivers.
## Labels and taints won't be set to nodes if they are not in the array.
# nvidia_gpu_nodes:
# - kube-gpu-001
## Dynamic render gpu node list via ansible inventory group.
# nvidia_gpu_nodes: "{{ groups['nvidia_gpu_nodes'] | list }}"

Comment on lines -318 to +320
Copy link
Contributor

Choose a reason for hiding this comment

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

You can drop this, the nvidia_gpu_nodes which only reflect the groups is a bad idea and will be deleted eventually.

# nvidia_driver_version: "384.111"
## flavor can be tesla or gtx
# nvidia_gpu_flavor: gtx
Expand Down
12 changes: 12 additions & 0 deletions roles/container-engine/containerd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ containerd_systemd_dir: "/etc/systemd/system/containerd.service.d"
containerd_oom_score: 0

containerd_default_runtime: "runc"
# Also you can dynamic set container runtime by ansible inventory group
# containerd_default_runtime: "{{ 'nvidia' if inventory_hostname in groups['nvidia_gpu_nodes'] else 'runc' }}"

Comment on lines +11 to +13
Copy link
Contributor

Choose a reason for hiding this comment

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

This is wrong advice, this is the kind of settings which should go in a group_vars/nvidia_gpu_nodes.yml in your inventory instead.

containerd_snapshotter: "overlayfs"

containerd_runc_runtime:
Expand All @@ -27,6 +30,15 @@ containerd_additional_runtimes: []
# engine: ""
# root: ""

# Example for Nvidia as additional runtime:
# containerd_additional_runtimes:
Copy link
Contributor

Choose a reason for hiding this comment

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

scrap this line and indent the rest as the example above for Kata

# - name: nvidia
# type: "io.containerd.runc.v2"
# engine: ""
# root: ""
# options:
# BinaryName: "/usr/bin/nvidia-container-runtime"

containerd_base_runtime_spec_rlimit_nofile: 65535

containerd_default_base_runtime_spec_patch:
Expand Down