Skip to content

Commit

Permalink
Rework kubevirt role a bit. Add support for nested KVM virtualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfgang Kulhanek authored and Wolfgang Kulhanek committed Nov 21, 2024
1 parent 8af53b1 commit 6abbc79
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ ocp4_workload_kubevirt_workload_tolerations: []
# which elminiates VolumeSnapshots without associated PVCs
ocp4_workload_kubevirt_boot_sources_shapshot: true

# For AWS it is possible to use KubeVirt without a metal node
# For that the subscription for the operator needs to have special config
# whih will be added if the following variable is set to true
ocp4_workload_kubevirt_enabled_nested_kvm: false

# --------------------------------
# Operator Catalog Snapshot Settings
# --------------------------------
Expand Down
23 changes: 7 additions & 16 deletions ansible/roles_ocp_workloads/ocp4_workload_kubevirt/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
---
- name: Running Pre Workload Tasks
when: ACTION == "create" or ACTION == "provision"
# Do not modify this file
- name: Running Workload tasks
when: ACTION == "provision"
ansible.builtin.include_tasks:
file: ./pre_workload.yml
file: workload.yml

- name: Running Workload Tasks
when: ACTION == "create" or ACTION == "provision"
- name: Running Workload removal tasks
when: ACTION == "destroy"
ansible.builtin.include_tasks:
file: ./workload.yml

- name: Running Post Workload Tasks
when: ACTION == "create" or ACTION == "provision"
ansible.builtin.include_tasks:
file: ./post_workload.yml

- name: Running Workload removal Tasks
when: ACTION == "destroy" or ACTION == "remove"
ansible.builtin.include_tasks:
file: ./remove_workload.yml
file: remove_workload.yml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
---
# Implement your Workload deployment tasks here
- name: Setting up workload for user
ansible.builtin.debug:
msg: "Setting up workload for user ocp_username = {{ ocp_username }}"
- name: Set subscription extra config for nested kvm
when: ocp4_workload_kubevirt_enabled_nested_kvm | bool
ansible.builtin.set_fact:
_ocp4_workload_kubevirt_extra_config:
env:
- name: KVM_EMULATION
value: "true"

- name: Install OpenShift Virtualization Operator
ansible.builtin.include_role:
Expand All @@ -22,6 +26,7 @@
install_operator_catalogsource_namespace: openshift-cnv
install_operator_catalogsource_image: "{{ ocp4_workload_kubevirt_catalog_snapshot_image | default('') }}"
install_operator_catalogsource_image_tag: "{{ ocp4_workload_kubevirt_catalog_snapshot_image_tag | default('') }}"
install_operator_subscription_config: "{{ _ocp4_workload_kubevirt_extra_config }}"

- name: Create the HyperConverged instance
kubernetes.core.k8s:
Expand All @@ -34,18 +39,13 @@
kind: HyperConverged
name: kubevirt-hyperconverged
namespace: openshift-cnv
register: r_hyperconverged
retries: 120
delay: 10
until:
- r_hyperconverged.resources is defined
- r_hyperconverged.resources | length > 0
- r_hyperconverged.resources[0].status is defined
- r_hyperconverged.resources[0].status.conditions | length > 0
- r_hyperconverged.resources[0].status.conditions | json_query( hyperconverged_query ) | bool
vars:
hyperconverged_query: >-
[?type=='Available'].status[] | [0]
wait: true
wait_sleep: 10
wait_timeout: 1200
wait_condition:
reason: "ReconcileCompleted"
type: "Available"
status: "True"

# For deployments on CNV with external Ceph use PVCs for boot image snapshots
# HyperConverged must have been created with .spec.featureGates.enableCommonBootImageImport: false
Expand Down Expand Up @@ -167,9 +167,3 @@
ansible.builtin.file:
state: absent
path: /tmp/virtctl.tar.gz

# Leave this as the last task in the playbook.
- name: Workload tasks complete
when: not silent|bool
ansible.builtin.debug:
msg: "Workload Tasks completed successfully."
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Internal Variables
_ocp4_workload_kubevirt_default_storage_class: ""
_ocp4_workload_kubevirt_extra_config: ""

0 comments on commit 6abbc79

Please sign in to comment.