Skip to content

Commit 0759230

Browse files
committed
feat: Add RKE2 as alternative Kubernetes distribution for service cluster
Add support for deploying RKE2 (Rancher Kubernetes Engine 2) as an alternative to vanilla Kubernetes (kubeadm) for the service cluster. Users can choose the distribution via the new k8s_distro field in omnia_config.yml. Configuration changes: - Add k8s_distro field to service_k8s_cluster in omnia_config.yml (default: kubeadm) - Update omnia_config.json schema to validate k8s_distro enum (kubeadm/rke2) - Expand k8s_cni enum to include canal, cilium (RKE2-supported CNIs) Pipeline integration: - discovery.yml: Enable service_k8s tag when service_rke2 is in software_config.json - include_software_config.yml: Detect service_rke2 and set service_rke2_support fact - validate_software_config_json.yml: Handle service_rke2 arch and version detection - common_validation.py: Accept service_rke2 for cluster validation - image_package_collector.py: Dynamically select service_rke2.json for image builds - k8s_config/main.yml: Branch NFS setup based on k8s_distro - configure_cloud_init_group.yml: Select RKE2-specific templates when k8s_distro=rke2 New files: - 3 RKE2 cloud-init templates (first server, additional server, agent) - create_rke2_config_nfs.yml for RKE2-specific NFS directory setup - service_rke2.json package definitions for RHEL 10.0 x86_64 Key differences from kubeadm path: - RKE2 uses built-in containerd (no CRI-O) - RKE2 manages CNI lifecycle (calico/canal/cilium/flannel) - Token-based cluster join instead of kubeadm certificates - kube-vip deployed as RKE2 static pod manifest - RKE2 registries.yaml for Pulp mirror integration - Port 9345 for RKE2 supervisor API Existing kubeadm deployment is completely unaffected when k8s_distro=kubeadm (default). Signed-off-by: John Lockman <j.lockman@dell.com>
1 parent 483ce3a commit 0759230

17 files changed

Lines changed: 1778 additions & 13 deletions

File tree

common/library/module_utils/input_validation/schema/omnia_config.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@
106106
"deployment": {
107107
"type": "boolean"
108108
},
109+
"k8s_distro": {
110+
"enum": ["kubeadm", "rke2"],
111+
"default": "kubeadm",
112+
"description": "Kubernetes distribution to deploy. kubeadm for vanilla K8s, rke2 for RKE2."
113+
},
109114
"k8s_cni": {
110-
"enum": ["calico"],
115+
"enum": ["calico", "canal", "cilium", "flannel"],
111116
"description": "K8s CNI plugin to use for this cluster."
112117
},
113118
"pod_external_ip_range": {

common/library/module_utils/input_validation/validation_flows/common_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ def validate_k8s(data, admin_networks, softwares, ha_config, tag_names, errors,
931931
# service_k8s_cluster = data["service_k8s_cluster"]
932932
cluster_set = {}
933933

934-
if "service_k8s" in softwares and "service_k8s" in tag_names:
934+
if ("service_k8s" in softwares or "service_rke2" in softwares) and "service_k8s" in tag_names:
935935
cluster_set["service_k8s_cluster"] = data.get(
936936
"service_k8s_cluster", [])
937937

common/library/modules/image_package_collector.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,15 @@ def collect_packages_from_json(sw_data, fg_name=None,
109109
elif service_k8s_defined:
110110
fg_name = fg_name.replace("_aarch64", "").replace("_x86_64", "")
111111

112-
if "service_k8s" in sw_data and "cluster" in sw_data["service_k8s"]:
113-
for entry in sw_data["service_k8s"]["cluster"]:
112+
# Determine the top-level key (service_k8s or service_rke2)
113+
k8s_top_key = "service_rke2" if "service_rke2" in sw_data else "service_k8s"
114+
115+
if k8s_top_key in sw_data and "cluster" in sw_data[k8s_top_key]:
116+
for entry in sw_data[k8s_top_key]["cluster"]:
114117
if entry.get("type") == "rpm" and "package" in entry:
115118
packages.append(entry["package"])
116119

120+
117121
if fg_name in sw_data and "cluster" in sw_data[fg_name]:
118122
for entry in sw_data[fg_name]["cluster"]:
119123
if entry.get("type") == "rpm" and "package" in entry:
@@ -170,7 +174,7 @@ def process_functional_group(fg_name, arch, os_version, input_project_dir,
170174
sw_data, fg_name=fg_name, slurm_defined=True
171175
)
172176
)
173-
elif json_file == "service_k8s.json":
177+
elif json_file in ("service_k8s.json", "service_rke2.json"):
174178
packages.extend(
175179
collect_packages_from_json(
176180
sw_data, fg_name=fg_name, service_k8s_defined=True
@@ -230,12 +234,15 @@ def run_module():
230234
allowed_additional_subgroups = get_allowed_additional_subgroups(software_config) if additional_enabled else []
231235

232236
# pylint: disable=line-too-long
237+
# Determine which K8s package JSON to use based on software_config.json
238+
k8s_json = "service_rke2.json" if "service_rke2" in allowed_softwares else "service_k8s.json"
239+
233240
# Functional group → json files mapping
234241
software_map = {
235242
"default_x86_64": ["openldap.json"],
236-
"service_kube_node_x86_64": ["service_k8s.json"],
237-
"service_kube_control_plane_first_x86_64": ["service_k8s.json"],
238-
"service_kube_control_plane_x86_64": ["service_k8s.json"],
243+
"service_kube_node_x86_64": [k8s_json],
244+
"service_kube_control_plane_first_x86_64": [k8s_json],
245+
"service_kube_control_plane_x86_64": [k8s_json],
239246
"slurm_control_node_x86_64": ["slurm_custom.json", "openldap.json", "ldms.json"],
240247
"slurm_node_x86_64": ["slurm_custom.json", "openldap.json", "ldms.json"],
241248
"login_node_x86_64": ["slurm_custom.json", "openldap.json", "ldms.json"],

discovery/discovery.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
(
6868
['service_k8s']
6969
if ( 'service_k8s' in (
70+
lookup('file', hostvars['localhost']['input_project_dir'] ~ '/software_config.json')
71+
| from_json).softwares | map(attribute='name') | list
72+
or 'service_rke2' in (
7073
lookup('file', hostvars['localhost']['input_project_dir'] ~ '/software_config.json')
7174
| from_json).softwares | map(attribute='name') | list )
7275
else []

discovery/roles/configure_ochami/tasks/configure_cloud_init_group.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@
2525
changed_when: true
2626
failed_when: false
2727

28+
- name: Determine cloud-init template path based on k8s_distro # noqa: yaml[line-length]
29+
ansible.builtin.set_fact:
30+
ci_group_template_src: >-
31+
{%- if k8s_distro | default('kubeadm') == 'rke2' and
32+
'service_kube' in functional_group_name -%}
33+
cloud_init/rke2/ci-group-{{ functional_group_name }}.yaml.j2
34+
{%- else -%}
35+
cloud_init/ci-group-{{ functional_group_name }}.yaml.j2
36+
{%- endif -%}
37+
2838
- name: Load ci group template
2939
block:
3040
- name: Load ci group template - {{ functional_group_name }}
3141
ansible.builtin.template:
32-
src: "cloud_init/ci-group-{{ functional_group_name }}.yaml.j2"
42+
src: "{{ ci_group_template_src | trim }}"
3343
dest: "{{ cloud_init_dir }}/ci-group-{{ functional_group_name }}.yaml"
3444
mode: "{{ hostvars['localhost']['file_permissions_644'] }}"
3545
rescue:

0 commit comments

Comments
 (0)