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

[host-ocp4-assisted-installer] Add the option to add extra disks to masters and/or workers #8867

Merged
merged 5 commits into from
Nov 25, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
---
- name: Set default volumes/disks variables
ansible.builtin.set_fact:
_instance_volumes:
- dataVolume:
name: "{{ vmname }}"
name: rootdisk
- dataVolume:
name: "{{ vmname }}-installation-cdrom"
name: installation-cdrom
- dataVolume:
name: "{{ vmname }}-etcd"
name: etcd
_instance_disks:
- bootOrder: 1
disk:
bus: virtio
name: rootdisk
- bootOrder: 3
disk:
bus: virtio
name: etcd
- bootOrder: 2
cdrom:
bus: sata
name: installation-cdrom

- name: Set the instances disks
ansible.builtin.set_fact:
_instance_disks: "{{ _instance_disks | from_yaml + [
{
'name': _disk.metadata.name,
'disk': {'bus': _instance.disk_type | default('virtio')}
}
] }}"
_instance_volumes: "{{ _instance_volumes | from_yaml + [
{
'name': _disk.metadata.name,
'dataVolume': {'name': _disk.metadata.name}
}
] }}"
loop: "{{ ai_masters_extra_disks | default([]) | list }}"
loop_control:
loop_var: _disk

- name: Create Master virtual machine
kubevirt.core.kubevirt_vm:
api_version: kubevirt.io/v1
Expand All @@ -7,7 +51,17 @@
validate_certs: false
name: "{{ vmname }}"
namespace: "{{ namespace }}"
data_volume_templates:
data_volume_templates: "{{ _datavolume + (ai_masters_extra_disks | default([]) | to_json | replace('INSTANCENAME', vmname) | from_json ) }}"
running: true
wait: false
annotations:
vm.kubevirt.io/os: rhel8
labels:
kubevirt.io/domain: "{{ vmname }}"
role: control-plane
spec: "{{ _spec | from_yaml }}"
vars:
_datavolume:
- metadata:
name: "{{ vmname }}-installation-cdrom"
spec:
Expand Down Expand Up @@ -43,16 +97,6 @@
storage: 30Gi
storageClassName: "{{ ai_local_storageclass }}"
volumeMode: Filesystem

running: true
wait: false
annotations:
vm.kubevirt.io/os: rhel8
labels:
kubevirt.io/domain: "{{ vmname }}"
role: control-plane
spec: "{{ _spec | from_yaml }}"
vars:
_spec: |
domain:
cpu:
Expand All @@ -61,19 +105,7 @@
threads: 1
model: host-passthrough
devices:
disks:
- bootOrder: 1
disk:
bus: virtio
name: rootdisk
- bootOrder: 3
disk:
bus: virtio
name: etcd
- bootOrder: 2
cdrom:
bus: sata
name: installation-cdrom
disks: {{ _instance_disks | replace('INSTANCENAME', vmname) }}
interfaces:
- masquerade: {}
model: virtio
Expand Down Expand Up @@ -105,16 +137,7 @@
networkName: "{{ network_name }}"
terminationGracePeriodSeconds: 180
evictionStrategy: None
volumes:
- dataVolume:
name: "{{ vmname }}"
name: rootdisk
- dataVolume:
name: "{{ vmname }}-installation-cdrom"
name: installation-cdrom
- dataVolume:
name: "{{ vmname }}-etcd"
name: etcd
volumes: {{ _instance_volumes | replace('INSTANCENAME', vmname) }}

- name: Wait till VM is running
kubernetes.core.k8s_info:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
---
- name: Set default volumes/disks variables
ansible.builtin.set_fact:
_instance_volumes:
- dataVolume:
name: "{{ vmname }}"
name: rootdisk
- dataVolume:
name: "{{ vmname }}-installation-cdrom"
name: installation-cdrom
_instance_disks:
- bootOrder: 1
disk:
bus: virtio
name: rootdisk
- bootOrder: 2
cdrom:
bus: sata
name: installation-cdrom

- name: Set the instances disks
ansible.builtin.set_fact:
_instance_disks: "{{ _instance_disks | from_yaml + [
{
'name': _disk.metadata.name,
'disk': {'bus': _instance.disk_type | default('virtio')}
}
] }}"
_instance_volumes: "{{ _instance_volumes | from_yaml + [
{
'name': _disk.metadata.name,
'dataVolume': {'name': _disk.metadata.name}
}
] }}"
loop: "{{ ai_workers_extra_disks | default([]) | list }}"
loop_control:
loop_var: _disk

- name: Create Worker virtual machine
kubevirt.core.kubevirt_vm:
api_version: kubevirt.io/v1
Expand All @@ -7,7 +44,17 @@
validate_certs: false
name: "{{ vmname }}"
namespace: "{{ namespace }}"
data_volume_templates:
data_volume_templates: "{{ _datavolume + (ai_workers_extra_disks | default([]) | to_json | replace('INSTANCENAME', vmname) | from_json ) }}"
running: true
wait: false
annotations:
vm.kubevirt.io/os: rhel8
labels:
kubevirt.io/domain: "{{ vmname }}"
role: worker
spec: "{{ _spec | from_yaml }}"
vars:
_datavolume:
- metadata:
name: "{{ vmname }}-installation-cdrom"
spec:
Expand All @@ -18,7 +65,7 @@
storage:
resources:
requests:
storage: 2Gi
storage: 1Gi
- metadata:
name: "{{ vmname }}"
spec:
Expand All @@ -30,15 +77,6 @@
requests:
storage: 100Gi
storageClassName: "{{ storageclass }}"
running: true
wait: false
annotations:
vm.kubevirt.io/os: rhel8
labels:
kubevirt.io/domain: "{{ vmname }}"
role: worker
spec: "{{ _spec | from_yaml }}"
vars:
_spec: |
domain:
cpu:
Expand All @@ -47,15 +85,7 @@
threads: 1
model: host-passthrough
devices:
disks:
- bootOrder: 1
disk:
bus: virtio
name: rootdisk
- bootOrder: 2
cdrom:
bus: sata
name: installation-cdrom
disks: {{ _instance_disks | replace('INSTANCENAME', vmname) }}
interfaces:
- masquerade: {}
model: virtio
Expand Down Expand Up @@ -85,13 +115,7 @@
multus:
networkName: "{{ network_name }}"
terminationGracePeriodSeconds: 180
volumes:
- dataVolume:
name: "{{ vmname }}"
name: rootdisk
- dataVolume:
name: "{{ vmname }}-installation-cdrom"
name: installation-cdrom
volumes: {{ _instance_volumes | replace('INSTANCENAME', vmname) }}

- name: Wait till VM is running
kubernetes.core.k8s_info:
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/host-ocp4-assisted-installer/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ ai_workers_macs: []
ai_masters_macs2: []
ai_workers_macs2: []

ai_masters_extra_disks: []
ai_workers_extra_disks: []

# This variable is used to configure the role and the installation disk
ai_configure_hosts: []
Loading