-
Notifications
You must be signed in to change notification settings - Fork 34
/
create-vm.yaml
125 lines (125 loc) · 5.58 KB
/
create-vm.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
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
annotations:
task.kubevirt.io/associatedServiceAccount: {{ sa_name }}
{% if task_name == "create-vm-from-manifest" %}
manifest.params.task.kubevirt.io/type: {{ task_param_types.resource_yaml }}
manifest.params.task.kubevirt.io/kind: {{ task_param_types.vm_kind}}
manifest.params.task.kubevirt.io/apiVersion: {{ task_param_types.vm_version }}
namespace.params.task.kubevirt.io/type: {{ task_param_types.namespace }}
{% elif task_name == "create-vm-from-template" %}
tekton.dev/deprecated: "true"
templateName.params.task.kubevirt.io/type: {{ task_param_types.vm_template_name }}
templateName.params.task.kubevirt.io/kind: {{ task_param_types.template_kind }}
templateName.params.task.kubevirt.io/apiVersion: {{ task_param_types.template_version }}
templateNamespace.params.task.kubevirt.io/type: {{ task_param_types.namespace }}
templateParams.params.task.kubevirt.io/type: {{ task_param_types.template_params_array }}
vmNamespace.params.task.kubevirt.io/type: {{ task_param_types.namespace }}
{% endif %}
dataVolumes.params.task.kubevirt.io/kind: {{ task_param_types.datavolume_kind }}
dataVolumes.params.task.kubevirt.io/apiVersion: {{ task_param_types.cdi_beta_api_version }}
ownDataVolumes.params.task.kubevirt.io/kind: {{ task_param_types.datavolume_kind }}
ownDataVolumes.params.task.kubevirt.io/apiVersion: {{ task_param_types.cdi_beta_api_version }}
persistentVolumeClaims.params.task.kubevirt.io/kind: {{ task_param_types.pvc_kind }}
persistentVolumeClaims.params.task.kubevirt.io/apiVersion: {{ task_param_types.v1_version }}
ownPersistentVolumeClaims.params.task.kubevirt.io/kind: {{ task_param_types.pvc_kind }}
ownPersistentVolumeClaims.params.task.kubevirt.io/apiVersion: {{ task_param_types.v1_version }}
startVM.params.task.kubevirt.io/type: {{ task_param_types.boolean }}
labels:
task.kubevirt.io/type: {{ task_name }}
task.kubevirt.io/category: {{ task_category }}
name: {{ task_name }}
spec:
params:
{% if task_name == "create-vm-from-manifest" %}
- name: manifest
description: YAML manifest of a VirtualMachine resource to be created.
type: string
- name: namespace
description: Namespace where to create the VM. (defaults to manifest namespace or active namespace)
default: ""
type: string
{% elif task_name == "create-vm-from-template" %}
- name: templateName
description: Name of an OKD template to create VM from.
type: string
- name: templateNamespace
description: Namespace of an OKD template to create VM from. (defaults to active namespace)
default: ""
type: string
- name: templateParams
description: Template params to pass when processing the template manifest. Each param should have KEY:VAL format. Eg ["NAME:my-vm", "DESC:blue"]
default: []
type: array
- name: vmNamespace
description: Namespace where to create the VM. (defaults to active namespace)
default: ""
type: string
{% endif %}
- name: startVM
description: Set to true or false to start / not start vm after creation. In case of runStrategy is set to Always, startVM flag is ignored.
default: ""
type: string
- name: runStrategy
description: Set runStrategy to VM. If runStrategy is set, vm.spec.running attribute is set to nil.
default: ""
type: string
- name: dataVolumes
description: Add DVs to VM Volumes. Replaces a particular volume if in VOLUME_NAME:DV_NAME format. Eg. ["rootdisk:my-dv", "my-dv2"]
default: []
type: array
- name: ownDataVolumes
description: Add DVs to VM Volumes and add VM to DV ownerReferences. These DataVolumes will be deleted once the created VM gets deleted. Replaces a particular volume if in VOLUME_NAME:DV_NAME format. Eg. ["rootdisk:my-dv", "my-dv2"]
default: []
type: array
- name: persistentVolumeClaims
description: Add PVCs to VM Volumes. Replaces a particular volume if in VOLUME_NAME:PVC_NAME format. Eg. ["rootdisk:my-pvc", "my-pvc2"]
default: []
type: array
- name: ownPersistentVolumeClaims
description: Add PVCs to VM Volumes and add VM to PVC ownerReferences. These PVCs will be deleted once the created VM gets deleted. Replaces a particular volume if in VOLUME_NAME:PVC_NAME format. Eg. ["rootdisk:my-pvc", "my-pvc2"]
default: []
type: array
results:
- name: name
description: The name of a VM that was created.
- name: namespace
description: The namespace of a VM that was created.
steps:
- name: createvm
image: "{{ main_image }}:{{ version }}"
command:
- create-vm
args:
- "--output=yaml"
- '--dvs'
- $(params.dataVolumes)
- '--own-dvs'
- $(params.ownDataVolumes)
- '--pvcs'
- $(params.persistentVolumeClaims)
- '--own-pvcs'
- $(params.ownPersistentVolumeClaims)
{% if task_name == "create-vm-from-template" %}
- '--template-params'
- $(params.templateParams)
env:
- name: TEMPLATE_NAME
value: $(params.templateName)
- name: TEMPLATE_NAMESPACE
value: $(params.templateNamespace)
- name: VM_NAMESPACE
value: $(params.vmNamespace)
{% elif task_name == "create-vm-from-manifest" %}
env:
- name: VM_MANIFEST
value: $(params.manifest)
- name: VM_NAMESPACE
value: $(params.namespace)
{% endif %}
- name: START_VM
value: $(params.startVM)
- name: RUN_STRATEGY
value: $(params.runStrategy)