This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
e2e.yaml
140 lines (126 loc) · 3.46 KB
/
e2e.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
- name: End-to-End flow for creating a VM using CDI
hosts: localhost
connection: local
module_defaults:
group/k8s:
namespace: default
vars:
vm_name: test-e2e-vm
pvc_name: test-e2e-pvc
service_name: test-e2e-service
tasks:
- name: Check for known open issues
include_tasks: known_issues.yaml
vars:
current_playbook: e2e
- name: Create PVC with CDI annotations
kubevirt_pvc:
state: present
name: "{{ pvc_name }}"
access_modes:
- ReadWriteOnce
size: 100Mi
cdi_source:
http:
url: "https://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img"
wait: yes
- name: Create a VM with the CDI PVC that was created
kubevirt_vm:
state: present
name: "{{ vm_name }}"
labels:
special: cirros-e2e-key
memory: 64Mi
cpu_cores: 1
disks:
- name: rootdisk
volume:
persistentVolumeClaim:
claimName: "{{ pvc_name }}"
disk:
bus: virtio
- name: Change VM status to running
kubevirt_vm:
state: running
name: "{{ vm_name }}"
- name: Wait for VM to be ready
k8s_facts:
name: "{{ vm_name }}"
kind: VirtualMachine
api_version: kubevirt.io/v1alpha3
register: vm
until: "vm.resources[0].status['created'] == true and vm.resources[0].status['ready'] == true"
delay: 10
retries: 18
- name: Increase the resources of VM
kubevirt_vm:
state: present
name: '{{ vm_name }}'
namespace: default
memory: 128Mi
cpu_cores: 2
- name: Restart the VM
kubevirt_vm:
state: "{{ item }}"
name: "{{ vm_name }}"
with_items:
- "stopped"
- "running"
- name: Wait for VM to be ready
k8s_facts:
name: "{{ vm_name }}"
kind: VirtualMachine
api_version: kubevirt.io/v1alpha3
register: vm
until: "vm.resources[0].status['created'] == true and vm.resources[0].status['ready'] == true"
delay: 10
retries: 18
- name: Expose the VMI using service
k8s_service:
state: present
name: "{{ service_name }}"
type: NodePort
ports:
- name: http
nodePort: 30000
port: 27017
targetPort: 22
protocol: TCP
selector:
special: cirros-e2e-key
definition:
metadata:
labels:
kubevirt.io/vm: cirros-e2e-service
spec:
externalTrafficPolicy: Cluster
# - name: Gather facts for {{ vm_name }} VMI in default namespace
# k8s_facts:
# name: "{{ vm_name }}"
# kind: VirtualMachineInstance
# api_version: kubevirt.io/v1alpha3
# register: vmi
# - name: Wait for port to be oppened
# wait_for:
# host: "{{ vmi.resources[0].status.nodeName}}"
# port: 30000
# delay: 10
# register: result
# - name: Check ssh is executed for VM
# assert:
# that:
# - "result['state'] == 'started'"
# fail_msg: "ssh is not established "
- name: Clean-up for VM
kubevirt_vm:
name: "{{ vm_name }}"
state: absent
- name: Clean-up for PVC
kubevirt_pvc:
name: "{{ pvc_name }}"
state: absent
- name: Clean-up for Service
k8s_service:
name: "{{ service_name }}"
state: absent