mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-14 05:45:06 +03:00
CI: use VirtualMachineInstance for VMs
VMI in Kubevirt are the abstraction below VirtualMachine. - We don't really need the extra abstraction of VirtualMachine objects - Convert the waiting for VMs ip address to use kubernetes.core.k8s_info and no shell pipeline
This commit is contained in:
@@ -20,19 +20,19 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
loop: "{{ vms_files }}"
|
loop: "{{ vms_files }}"
|
||||||
|
|
||||||
- name: Wait for vms to have ipaddress assigned
|
- name: Wait for vms to have IP addresses
|
||||||
shell: "set -o pipefail && kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'"
|
kubernetes.core.k8s_info:
|
||||||
args:
|
api_version: kubevirt.io/v1
|
||||||
executable: /bin/bash
|
kind: VirtualMachineInstance
|
||||||
changed_when: false
|
label_selectors:
|
||||||
register: vm_ips
|
- "ci_job_id={{ ci_job_id }}"
|
||||||
loop: "{{ range(1, vm_count | int + 1, 1) | list }}"
|
namespace: "{{ pod_namespace }}"
|
||||||
loop_control:
|
register: vmis
|
||||||
index_var: vm_id
|
until: vmis.resources
|
||||||
retries: 20
|
| map(attribute='status.interfaces.0')
|
||||||
delay: 15
|
| rejectattr('ipAddress', 'defined') == []
|
||||||
until:
|
retries: 30
|
||||||
- vm_ips.stdout | ansible.utils.ipaddr
|
delay: 10
|
||||||
|
|
||||||
- name: "Create inventory for CI test in file /tmp/{{ test_name }}/inventory"
|
- name: "Create inventory for CI test in file /tmp/{{ test_name }}/inventory"
|
||||||
template:
|
template:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
apiVersion: kubevirt.io/v1
|
apiVersion: kubevirt.io/v1
|
||||||
kind: VirtualMachine
|
kind: VirtualMachineInstance
|
||||||
metadata:
|
metadata:
|
||||||
generateName: test-vm-
|
generateName: test-vm-
|
||||||
namespace: {{ pod_namespace }}
|
namespace: {{ pod_namespace }}
|
||||||
@@ -8,6 +8,8 @@ metadata:
|
|||||||
kubespray.com/ci.template-path: "tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2"
|
kubespray.com/ci.template-path: "tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2"
|
||||||
labels:
|
labels:
|
||||||
kubevirt.io/os: {{ cloud_image }}
|
kubevirt.io/os: {{ cloud_image }}
|
||||||
|
kubevirt.io/size: small
|
||||||
|
kubevirt.io/domain: "{{ test_name }}"
|
||||||
ci_job_id: "{{ ci_job_id }}"
|
ci_job_id: "{{ ci_job_id }}"
|
||||||
ci_job_name: "{{ ci_job_name }}"
|
ci_job_name: "{{ ci_job_name }}"
|
||||||
# leverage the Kubernetes GC for resources cleanup
|
# leverage the Kubernetes GC for resources cleanup
|
||||||
@@ -17,46 +19,39 @@ metadata:
|
|||||||
name: "{{ pod_name }}"
|
name: "{{ pod_name }}"
|
||||||
uid: "{{ pod_uid }}"
|
uid: "{{ pod_uid }}"
|
||||||
spec:
|
spec:
|
||||||
running: true
|
domain:
|
||||||
template:
|
devices:
|
||||||
metadata:
|
blockMultiQueue: true
|
||||||
labels:
|
disks:
|
||||||
kubevirt.io/size: small
|
- disk:
|
||||||
kubevirt.io/domain: "{{ test_name }}"
|
bus: virtio
|
||||||
spec:
|
name: containervolume
|
||||||
domain:
|
cache: writethrough
|
||||||
devices:
|
- disk:
|
||||||
blockMultiQueue: true
|
bus: virtio
|
||||||
disks:
|
name: cloudinitvolume
|
||||||
- disk:
|
interfaces:
|
||||||
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:
|
|
||||||
- name: default
|
- name: default
|
||||||
pod: {}
|
bridge: {}
|
||||||
terminationGracePeriodSeconds: 0
|
cpu:
|
||||||
volumes:
|
cores: {{ vm_cpu_cores }}
|
||||||
- name: containervolume
|
sockets: {{ vm_cpu_sockets }}
|
||||||
containerDisk:
|
threads: {{ vm_cpu_threads }}
|
||||||
image: quay.io/kubespray/vm-{{ cloud_image }}
|
resources:
|
||||||
- name: cloudinitvolume
|
requests:
|
||||||
cloudInitNoCloud:
|
memory: "{{ vm_memory * memory_allocation_ratio }}Mi"
|
||||||
userDataBase64: {{ cloud_init[cloud_image] }}
|
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] }}
|
||||||
|
|||||||
Reference in New Issue
Block a user