Skip to content

Commit

Permalink
CI: use VirtualMachineInstance for VMs
Browse files Browse the repository at this point in the history
VMI in Kubevirt are the abstraction below VirtualMachine.

- We don't really need the extra abstraction of VirtualMachine objects
- Fix the provisioning playbook not waiting correctly on the VMs until
  they have an IP address to use for the dynamic inventory
  • Loading branch information
VannTen committed Oct 7, 2024
1 parent 678b791 commit 19a4aab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ exclude_paths:
- tests/files/custom_cni/cilium.yaml
- venv
- .github
mock_modules:
- kubevirt.core.kubevirt_vmi_info
6 changes: 1 addition & 5 deletions tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
loop: "{{ scenarios[mode | d('default')] }}"

- name: Wait for vms to have ipaddress assigned
kubernetes.core.k8s_info:
api_version: kubevirt.io/v1
kind: VirtualMachine
kubevirt.core.kubevirt_vmi_info:
label_selectors:
- "ci_job_id={{ ci_job_id }}"
namespace: "{{ pod_namespace }}"
wait: true
wait_condition:
type: Ready
wait_timeout: 300

- name: "Create inventory for CI tests"
Expand Down
91 changes: 43 additions & 48 deletions tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
---
apiVersion: kubevirt.io/v1
kind: VirtualMachine
kind: VirtualMachineInstance
metadata:
generateName: test-vm-
namespace: {{ pod_namespace }}
annotations:
kubespray.com/ci.template-path: "tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2"
labels:
kubevirt.io/os: {{ cloud_image }}
kubevirt.io/size: small
kubevirt.io/domain: "{{ test_name }}"
ci_job_id: "{{ ci_job_id }}"
ci_job_name: "{{ ci_job_name }}"
{% for group in kubespray_groups -%}
Expand All @@ -20,51 +22,44 @@ metadata:
name: "{{ pod_name }}"
uid: "{{ pod_uid }}"
spec:
running: true
template:
metadata:
labels:
kubevirt.io/size: small
kubevirt.io/domain: "{{ test_name }}"
spec:
readinessProbe:
initialDelaySeconds: 5
periodsSeconds: 10
tcpSocket:
port: 22
domain:
devices:
blockMultiQueue: true
disks:
- disk:
bus: virtio
name: containervolume
cache: writethrough
- disk:
bus: virtio
name: cloudinitvolume
interfaces:
- name: default
bridge: {}
cpu:
cores: {{ vm_cpu_cores }}
sockets: {{ vm_cpu_sockets }}
threads: {{ vm_cpu_threads }}
resources:
requests:
memory: "{{ vm_memory * memory_allocation_ratio }}Mi"
cpu: {{ vm_cpu_cores * cpu_allocation_ratio }}
limits:
memory: "{{ vm_memory }}Mi"
cpu: {{ vm_cpu_cores }}
networks:
readinessProbe:
initialDelaySeconds: 5
periodSeconds: 10
tcpSocket:
port: 22
domain:
devices:
blockMultiQueue: true
disks:
- disk:
bus: virtio
name: containervolume
cache: writethrough
- disk:
bus: virtio
name: cloudinitvolume
interfaces:
- name: default
pod: {}
terminationGracePeriodSeconds: 0
volumes:
- name: containervolume
containerDisk:
image: quay.io/kubespray/vm-{{ cloud_image }}
- name: cloudinitvolume
cloudInitNoCloud:
userDataBase64: {{ cloud_init[cloud_image] }}
bridge: {}
cpu:
cores: {{ vm_cpu_cores }}
sockets: {{ vm_cpu_sockets }}
threads: {{ vm_cpu_threads }}
resources:
requests:
memory: "{{ vm_memory * memory_allocation_ratio }}Mi"
cpu: {{ vm_cpu_cores * cpu_allocation_ratio }}
limits:
memory: "{{ vm_memory }}Mi"
cpu: {{ vm_cpu_cores }}
networks:
- name: default
pod: {}
terminationGracePeriodSeconds: 0
volumes:
- name: containervolume
containerDisk:
image: quay.io/kubespray/vm-{{ cloud_image }}
- name: cloudinitvolume
cloudInitNoCloud:
userDataBase64: {{ cloud_init[cloud_image] }}

0 comments on commit 19a4aab

Please sign in to comment.