kubevirt-tekton-tasks-kubernetes.yaml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. ---
  2. apiVersion: tekton.dev/v1beta1
  3. kind: ClusterTask
  4. metadata:
  5. annotations:
  6. task.kubevirt.io/associatedServiceAccount: cleanup-vm-task
  7. vmNamespace.params.task.kubevirt.io/type: namespace
  8. secretName.params.task.kubevirt.io/type: execute-in-vm-secret
  9. script.params.task.kubevirt.io/type: script
  10. delete.params.task.kubevirt.io/type: boolean
  11. stop.params.task.kubevirt.io/type: boolean
  12. timeout.params.task.kubevirt.io/type: duration
  13. labels:
  14. task.kubevirt.io/type: cleanup-vm
  15. task.kubevirt.io/category: execute-in-vm
  16. name: cleanup-vm
  17. spec:
  18. params:
  19. - description: Name of a VM to execute the action in.
  20. name: vmName
  21. type: string
  22. - description: Namespace of a VM to execute the action in. (defaults to active namespace)
  23. name: vmNamespace
  24. type: string
  25. default: ""
  26. - description: Stops the VM after executing the commands when set to true.
  27. name: stop
  28. type: string
  29. default: "true"
  30. - description: Deletes the VM after executing the commands when set to true.
  31. name: delete
  32. type: string
  33. default: "false"
  34. - description: Timeout for the command/script (includes potential VM start). The VM will be stopped or deleted accordingly once the timout expires. Should be in a 3h2m1s format.
  35. name: timeout
  36. type: string
  37. default: "30m"
  38. - description: Secret to use when connecting to a VM.
  39. name: secretName
  40. type: string
  41. default: "__empty__"
  42. - description: Command to execute in a VM.
  43. name: command
  44. type: array
  45. default: []
  46. - description: Arguments of a command.
  47. name: args
  48. type: array
  49. default: []
  50. - description: Script to execute in a VM.
  51. name: script
  52. type: string
  53. default: ""
  54. steps:
  55. - name: execute-in-vm
  56. image: "quay.io/kubevirt/tekton-task-execute-in-vm:v0.13.2"
  57. command:
  58. - entrypoint
  59. args:
  60. - '--stop'
  61. - $(params.stop)
  62. - '--delete'
  63. - $(params.delete)
  64. - '--timeout'
  65. - $(params.timeout)
  66. - '--'
  67. - $(params.command)
  68. - $(params.args)
  69. env:
  70. - name: VM_NAME
  71. value: $(params.vmName)
  72. - name: VM_NAMESPACE
  73. value: $(params.vmNamespace)
  74. - name: EXECUTE_SCRIPT
  75. value: $(params.script)
  76. - name: CONNECTION_SECRET_NAME
  77. value: $(params.secretName)
  78. volumeMounts:
  79. - mountPath: /data/connectionsecret/
  80. name: connectionsecret
  81. readOnly: true
  82. volumes:
  83. - name: connectionsecret
  84. secret:
  85. secretName: $(params.secretName)
  86. optional: true
  87. ---
  88. apiVersion: rbac.authorization.k8s.io/v1
  89. kind: ClusterRole
  90. metadata:
  91. name: cleanup-vm-task
  92. rules:
  93. - verbs:
  94. - get
  95. - list
  96. - watch
  97. - delete
  98. apiGroups:
  99. - kubevirt.io
  100. resources:
  101. - virtualmachines
  102. - virtualmachineinstances
  103. - verbs:
  104. - update
  105. apiGroups:
  106. - subresources.kubevirt.io
  107. resources:
  108. - virtualmachines/start
  109. - virtualmachines/stop
  110. - virtualmachines/restart
  111. ---
  112. apiVersion: v1
  113. kind: ServiceAccount
  114. metadata:
  115. name: cleanup-vm-task
  116. ---
  117. apiVersion: rbac.authorization.k8s.io/v1
  118. kind: RoleBinding
  119. metadata:
  120. name: cleanup-vm-task
  121. roleRef:
  122. kind: ClusterRole
  123. name: cleanup-vm-task
  124. apiGroup: rbac.authorization.k8s.io
  125. subjects:
  126. - kind: ServiceAccount
  127. name: cleanup-vm-task
  128. ---
  129. apiVersion: tekton.dev/v1beta1
  130. kind: ClusterTask
  131. metadata:
  132. annotations:
  133. task.kubevirt.io/associatedServiceAccount: create-vm-from-manifest-task
  134. manifest.params.task.kubevirt.io/type: resource-yaml
  135. manifest.params.task.kubevirt.io/kind: VirtualMachine
  136. manifest.params.task.kubevirt.io/apiVersion: kubevirt.io/v1
  137. namespace.params.task.kubevirt.io/type: namespace
  138. dataVolumes.params.task.kubevirt.io/kind: DataVolume
  139. dataVolumes.params.task.kubevirt.io/apiVersion: cdi.kubevirt.io/v1beta1
  140. ownDataVolumes.params.task.kubevirt.io/kind: DataVolume
  141. ownDataVolumes.params.task.kubevirt.io/apiVersion: cdi.kubevirt.io/v1beta1
  142. persistentVolumeClaims.params.task.kubevirt.io/kind: PersistentVolumeClaim
  143. persistentVolumeClaims.params.task.kubevirt.io/apiVersion: v1
  144. ownPersistentVolumeClaims.params.task.kubevirt.io/kind: PersistentVolumeClaim
  145. ownPersistentVolumeClaims.params.task.kubevirt.io/apiVersion: v1
  146. startVM.params.task.kubevirt.io/type: boolean
  147. labels:
  148. task.kubevirt.io/type: create-vm-from-manifest
  149. task.kubevirt.io/category: create-vm
  150. name: create-vm-from-manifest
  151. spec:
  152. params:
  153. - name: manifest
  154. description: YAML manifest of a VirtualMachine resource to be created.
  155. type: string
  156. - name: namespace
  157. description: Namespace where to create the VM. (defaults to manifest namespace or active namespace)
  158. default: ""
  159. type: string
  160. - name: startVM
  161. 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.
  162. default: ""
  163. type: string
  164. - name: runStrategy
  165. description: Set runStrategy to VM. If runStrategy is set, vm.spec.running attribute is set to nil.
  166. default: ""
  167. type: string
  168. - name: dataVolumes
  169. description: Add DVs to VM Volumes. Replaces a particular volume if in VOLUME_NAME:DV_NAME format. Eg. ["rootdisk:my-dv", "my-dv2"]
  170. default: []
  171. type: array
  172. - name: ownDataVolumes
  173. 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"]
  174. default: []
  175. type: array
  176. - name: persistentVolumeClaims
  177. description: Add PVCs to VM Volumes. Replaces a particular volume if in VOLUME_NAME:PVC_NAME format. Eg. ["rootdisk:my-pvc", "my-pvc2"]
  178. default: []
  179. type: array
  180. - name: ownPersistentVolumeClaims
  181. 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"]
  182. default: []
  183. type: array
  184. results:
  185. - name: name
  186. description: The name of a VM that was created.
  187. - name: namespace
  188. description: The namespace of a VM that was created.
  189. steps:
  190. - name: createvm
  191. image: "quay.io/kubevirt/tekton-task-create-vm:v0.13.2"
  192. command:
  193. - create-vm
  194. args:
  195. - "--output=yaml"
  196. - '--dvs'
  197. - $(params.dataVolumes)
  198. - '--own-dvs'
  199. - $(params.ownDataVolumes)
  200. - '--pvcs'
  201. - $(params.persistentVolumeClaims)
  202. - '--own-pvcs'
  203. - $(params.ownPersistentVolumeClaims)
  204. env:
  205. - name: VM_MANIFEST
  206. value: $(params.manifest)
  207. - name: VM_NAMESPACE
  208. value: $(params.namespace)
  209. - name: START_VM
  210. value: $(params.startVM)
  211. - name: RUN_STRATEGY
  212. value: $(params.runStrategy)
  213. ---
  214. apiVersion: rbac.authorization.k8s.io/v1
  215. kind: ClusterRole
  216. metadata:
  217. name: create-vm-from-manifest-task
  218. rules:
  219. - verbs:
  220. - get
  221. - list
  222. - watch
  223. - create
  224. - update
  225. apiGroups:
  226. - kubevirt.io
  227. resources:
  228. - virtualmachines
  229. - virtualmachineinstances
  230. - verbs:
  231. - 'update'
  232. apiGroups:
  233. - subresources.kubevirt.io
  234. resources:
  235. - virtualmachines/start
  236. - verbs:
  237. - '*'
  238. apiGroups:
  239. - kubevirt.io
  240. resources:
  241. - virtualmachines/finalizers
  242. - verbs:
  243. - '*'
  244. apiGroups:
  245. - ''
  246. resources:
  247. - persistentvolumeclaims
  248. - verbs:
  249. - '*'
  250. apiGroups:
  251. - cdi.kubevirt.io
  252. resources:
  253. - datavolumes
  254. ---
  255. apiVersion: v1
  256. kind: ServiceAccount
  257. metadata:
  258. name: create-vm-from-manifest-task
  259. ---
  260. apiVersion: rbac.authorization.k8s.io/v1
  261. kind: RoleBinding
  262. metadata:
  263. name: create-vm-from-manifest-task
  264. roleRef:
  265. kind: ClusterRole
  266. name: create-vm-from-manifest-task
  267. apiGroup: rbac.authorization.k8s.io
  268. subjects:
  269. - kind: ServiceAccount
  270. name: create-vm-from-manifest-task
  271. ---
  272. apiVersion: tekton.dev/v1beta1
  273. kind: ClusterTask
  274. metadata:
  275. annotations:
  276. pvc.params.task.kubevirt.io/kind: PersistentVolumeClaim
  277. pvc.params.task.kubevirt.io/apiVersion: v1
  278. customizeCommands.params.task.kubevirt.io/type: script
  279. verbose.params.task.kubevirt.io/type: boolean
  280. labels:
  281. task.kubevirt.io/type: disk-virt-customize
  282. task.kubevirt.io/category: disk-virt-customize
  283. name: disk-virt-customize
  284. spec:
  285. params:
  286. - name: pvc
  287. description: PersistentVolumeClaim to run the the virt-customize script in. PVC should be in the same namespace as taskrun/pipelinerun.
  288. type: string
  289. - name: customizeCommands
  290. description: virt-customize commands in "--commands-from-file" format.
  291. type: string
  292. default: ""
  293. - name: verbose
  294. description: Enable verbose mode and tracing of libguestfs API calls.
  295. type: string
  296. default: 'false'
  297. - name: additionalOptions
  298. description: Additional options to pass to virt-customize.
  299. type: string
  300. default: ""
  301. steps:
  302. - name: run-virt-customize
  303. image: "quay.io/kubevirt/tekton-task-disk-virt-customize:v0.13.2"
  304. command:
  305. - entrypoint
  306. args:
  307. - '--verbose'
  308. - $(params.verbose)
  309. env:
  310. - name: CUSTOMIZE_COMMANDS
  311. value: $(params.customizeCommands)
  312. - name: ADDITIONAL_VIRT_CUSTOMIZE_OPTIONS
  313. value: $(params.additionalOptions)
  314. - name: LIBGUESTFS_BACKEND
  315. value: direct
  316. resources:
  317. limits:
  318. devices.kubevirt.io/kvm: '1'
  319. devices.kubevirt.io/tun: '1'
  320. devices.kubevirt.io/vhost-net: '1'
  321. requests:
  322. devices.kubevirt.io/kvm: '1'
  323. devices.kubevirt.io/tun: '1'
  324. devices.kubevirt.io/vhost-net: '1'
  325. volumeMounts:
  326. - mountPath: /mnt/appliance/
  327. name: guestfsappliance
  328. - mountPath: /mnt/targetpvc/
  329. name: targetpvc
  330. volumes:
  331. - name: guestfsappliance
  332. emptyDir: {}
  333. - name: targetpvc
  334. persistentVolumeClaim:
  335. claimName: $(params.pvc)
  336. workspaces:
  337. - name: data01
  338. description: |
  339. An optional workspace that may contain files or secrets to be
  340. used during the virt-customize run.
  341. optional: true
  342. mountPath: /data01
  343. - name: data02
  344. description: |
  345. An optional workspace that may contain files or secrets to be
  346. used during the virt-customize run.
  347. optional: true
  348. mountPath: /data02
  349. - name: data03
  350. description: |
  351. An optional workspace that may contain files or secrets to be
  352. used during the virt-customize run.
  353. optional: true
  354. mountPath: /data03
  355. - name: data04
  356. description: |
  357. An optional workspace that may contain files or secrets to be
  358. used during the virt-customize run.
  359. optional: true
  360. mountPath: /data04
  361. - name: data05
  362. description: |
  363. An optional workspace that may contain files or secrets to be
  364. used during the virt-customize run.
  365. optional: true
  366. mountPath: /data05
  367. - name: data06
  368. description: |
  369. An optional workspace that may contain files or secrets to be
  370. used during the virt-customize run.
  371. optional: true
  372. mountPath: /data06
  373. - name: data07
  374. description: |
  375. An optional workspace that may contain files or secrets to be
  376. used during the virt-customize run.
  377. optional: true
  378. mountPath: /data07
  379. - name: data08
  380. description: |
  381. An optional workspace that may contain files or secrets to be
  382. used during the virt-customize run.
  383. optional: true
  384. mountPath: /data08
  385. - name: data09
  386. description: |
  387. An optional workspace that may contain files or secrets to be
  388. used during the virt-customize run.
  389. optional: true
  390. mountPath: /data09
  391. - name: data10
  392. description: |
  393. An optional workspace that may contain files or secrets to be
  394. used during the virt-customize run.
  395. optional: true
  396. mountPath: /data10
  397. ---
  398. apiVersion: tekton.dev/v1beta1
  399. kind: ClusterTask
  400. metadata:
  401. annotations:
  402. pvc.params.task.kubevirt.io/kind: PersistentVolumeClaim
  403. pvc.params.task.kubevirt.io/apiVersion: v1
  404. sysprepCommands.params.task.kubevirt.io/type: script
  405. verbose.params.task.kubevirt.io/type: boolean
  406. labels:
  407. task.kubevirt.io/type: disk-virt-sysprep
  408. task.kubevirt.io/category: disk-virt-sysprep
  409. name: disk-virt-sysprep
  410. spec:
  411. params:
  412. - name: pvc
  413. description: PersistentVolumeClaim to run the the virt-sysprep script in. PVC should be in the same namespace as taskrun/pipelinerun.
  414. type: string
  415. - name: sysprepCommands
  416. description: virt-sysprep commands in "--commands-from-file" format.
  417. type: string
  418. default: ""
  419. - name: verbose
  420. description: Enable verbose mode and tracing of libguestfs API calls.
  421. type: string
  422. default: 'false'
  423. - name: additionalOptions
  424. description: Additional options to pass to virt-sysprep.
  425. type: string
  426. default: ""
  427. steps:
  428. - name: run-virt-sysprep
  429. image: "quay.io/kubevirt/tekton-task-disk-virt-sysprep:v0.13.2"
  430. command:
  431. - entrypoint
  432. args:
  433. - '--verbose'
  434. - $(params.verbose)
  435. env:
  436. - name: SYSPREP_COMMANDS
  437. value: $(params.sysprepCommands)
  438. - name: ADDITIONAL_VIRT_SYSPREP_OPTIONS
  439. value: $(params.additionalOptions)
  440. - name: LIBGUESTFS_BACKEND
  441. value: direct
  442. resources:
  443. limits:
  444. devices.kubevirt.io/kvm: '1'
  445. devices.kubevirt.io/tun: '1'
  446. devices.kubevirt.io/vhost-net: '1'
  447. requests:
  448. devices.kubevirt.io/kvm: '1'
  449. devices.kubevirt.io/tun: '1'
  450. devices.kubevirt.io/vhost-net: '1'
  451. volumeMounts:
  452. - mountPath: /mnt/appliance/
  453. name: guestfsappliance
  454. - mountPath: /mnt/targetpvc/
  455. name: targetpvc
  456. volumes:
  457. - name: guestfsappliance
  458. emptyDir: {}
  459. - name: targetpvc
  460. persistentVolumeClaim:
  461. claimName: $(params.pvc)
  462. workspaces:
  463. - name: data01
  464. description: |
  465. An optional workspace that may contain files or secrets to be
  466. used during the virt-customize run.
  467. optional: true
  468. mountPath: /data01
  469. - name: data02
  470. description: |
  471. An optional workspace that may contain files or secrets to be
  472. used during the virt-customize run.
  473. optional: true
  474. mountPath: /data02
  475. - name: data03
  476. description: |
  477. An optional workspace that may contain files or secrets to be
  478. used during the virt-customize run.
  479. optional: true
  480. mountPath: /data03
  481. - name: data04
  482. description: |
  483. An optional workspace that may contain files or secrets to be
  484. used during the virt-customize run.
  485. optional: true
  486. mountPath: /data04
  487. - name: data05
  488. description: |
  489. An optional workspace that may contain files or secrets to be
  490. used during the virt-customize run.
  491. optional: true
  492. mountPath: /data05
  493. - name: data06
  494. description: |
  495. An optional workspace that may contain files or secrets to be
  496. used during the virt-customize run.
  497. optional: true
  498. mountPath: /data06
  499. - name: data07
  500. description: |
  501. An optional workspace that may contain files or secrets to be
  502. used during the virt-customize run.
  503. optional: true
  504. mountPath: /data07
  505. - name: data08
  506. description: |
  507. An optional workspace that may contain files or secrets to be
  508. used during the virt-customize run.
  509. optional: true
  510. mountPath: /data08
  511. - name: data09
  512. description: |
  513. An optional workspace that may contain files or secrets to be
  514. used during the virt-customize run.
  515. optional: true
  516. mountPath: /data09
  517. - name: data10
  518. description: |
  519. An optional workspace that may contain files or secrets to be
  520. used during the virt-customize run.
  521. optional: true
  522. mountPath: /data10
  523. ---
  524. apiVersion: tekton.dev/v1beta1
  525. kind: ClusterTask
  526. metadata:
  527. annotations:
  528. task.kubevirt.io/associatedServiceAccount: execute-in-vm-task
  529. vmNamespace.params.task.kubevirt.io/type: namespace
  530. secretName.params.task.kubevirt.io/type: execute-in-vm-secret
  531. script.params.task.kubevirt.io/type: script
  532. labels:
  533. task.kubevirt.io/type: execute-in-vm
  534. task.kubevirt.io/category: execute-in-vm
  535. name: execute-in-vm
  536. spec:
  537. params:
  538. - description: Name of a VM to execute the action in.
  539. name: vmName
  540. type: string
  541. - description: Namespace of a VM to execute the action in. (defaults to active namespace)
  542. name: vmNamespace
  543. type: string
  544. default: ""
  545. - description: Secret to use when connecting to a VM.
  546. name: secretName
  547. type: string
  548. default: "__empty__"
  549. - description: Command to execute in a VM.
  550. name: command
  551. type: array
  552. default: []
  553. - description: Arguments of a command.
  554. name: args
  555. type: array
  556. default: []
  557. - description: Script to execute in a VM.
  558. name: script
  559. type: string
  560. default: ""
  561. steps:
  562. - name: execute-in-vm
  563. image: "quay.io/kubevirt/tekton-task-execute-in-vm:v0.13.2"
  564. command:
  565. - entrypoint
  566. args:
  567. - '--'
  568. - $(params.command)
  569. - $(params.args)
  570. env:
  571. - name: VM_NAME
  572. value: $(params.vmName)
  573. - name: VM_NAMESPACE
  574. value: $(params.vmNamespace)
  575. - name: EXECUTE_SCRIPT
  576. value: $(params.script)
  577. - name: CONNECTION_SECRET_NAME
  578. value: $(params.secretName)
  579. volumeMounts:
  580. - mountPath: /data/connectionsecret/
  581. name: connectionsecret
  582. readOnly: true
  583. volumes:
  584. - name: connectionsecret
  585. secret:
  586. secretName: $(params.secretName)
  587. optional: true
  588. ---
  589. apiVersion: rbac.authorization.k8s.io/v1
  590. kind: ClusterRole
  591. metadata:
  592. name: execute-in-vm-task
  593. rules:
  594. - verbs:
  595. - get
  596. - list
  597. - watch
  598. apiGroups:
  599. - kubevirt.io
  600. resources:
  601. - virtualmachines
  602. - virtualmachineinstances
  603. - verbs:
  604. - update
  605. apiGroups:
  606. - subresources.kubevirt.io
  607. resources:
  608. - virtualmachines/start
  609. - virtualmachines/stop
  610. - virtualmachines/restart
  611. ---
  612. apiVersion: v1
  613. kind: ServiceAccount
  614. metadata:
  615. name: execute-in-vm-task
  616. ---
  617. apiVersion: rbac.authorization.k8s.io/v1
  618. kind: RoleBinding
  619. metadata:
  620. name: execute-in-vm-task
  621. roleRef:
  622. kind: ClusterRole
  623. name: execute-in-vm-task
  624. apiGroup: rbac.authorization.k8s.io
  625. subjects:
  626. - kind: ServiceAccount
  627. name: execute-in-vm-task
  628. ---
  629. apiVersion: tekton.dev/v1beta1
  630. kind: ClusterTask
  631. metadata:
  632. annotations:
  633. task.kubevirt.io/associatedServiceAccount: generate-ssh-keys-task
  634. publicKeySecretName.params.task.kubevirt.io/kind: Secret
  635. publicKeySecretName.params.task.kubevirt.io/apiVersion: v1
  636. publicKeySecretNamespace.params.task.kubevirt.io/type: namespace
  637. privateKeySecretName.params.task.kubevirt.io/kind: Secret
  638. privateKeySecretName.params.task.kubevirt.io/apiVersion: v1
  639. privateKeySecretNamespace.params.task.kubevirt.io/type: namespace
  640. privateKeyConnectionOptions.params.task.kubevirt.io/type: private-key-options-array
  641. labels:
  642. task.kubevirt.io/type: generate-ssh-keys
  643. task.kubevirt.io/category: generate-ssh-keys
  644. name: generate-ssh-keys
  645. spec:
  646. params:
  647. - name: publicKeySecretName
  648. description: Name of a new or existing secret to append the generated public key to. The name will be generated and new secret created if not specified.
  649. default: ""
  650. type: string
  651. - name: publicKeySecretNamespace
  652. description: Namespace of publicKeySecretName. (defaults to active namespace)
  653. default: ""
  654. type: string
  655. - name: privateKeySecretName
  656. description: Name of a new secret to add the generated private key to. The name will be generated if not specified. The secret uses format of execute-in-vm task.
  657. default: ""
  658. type: string
  659. - name: privateKeySecretNamespace
  660. description: Namespace of privateKeySecretName. (defaults to active namespace)
  661. default: ""
  662. type: string
  663. - name: privateKeyConnectionOptions
  664. description: Additional options to use in SSH client. Please see execute-in-vm task SSH section for more details. Eg ["host-public-key:ssh-rsa AAAAB...", "additional-ssh-options:-p 8022"].
  665. default: []
  666. type: array
  667. - name: additionalSSHKeygenOptions
  668. description: Additional options to pass to the ssh-keygen command.
  669. default: ""
  670. type: string
  671. results:
  672. - name: publicKeySecretName
  673. description: The name of a public key secret.
  674. - name: publicKeySecretNamespace
  675. description: The namespace of a public key secret.
  676. - name: privateKeySecretName
  677. description: The name of a private key secret.
  678. - name: privateKeySecretNamespace
  679. description: The namespace of a private key secret.
  680. steps:
  681. - name: generate-ssh-keys
  682. image: "quay.io/kubevirt/tekton-task-generate-ssh-keys:v0.13.2"
  683. command:
  684. - entrypoint
  685. - '--'
  686. - $(params.privateKeyConnectionOptions)
  687. env:
  688. - name: PUBLIC_KEY_SECRET_NAME
  689. value: $(params.publicKeySecretName)
  690. - name: PUBLIC_KEY_SECRET_NAMESPACE
  691. value: $(params.publicKeySecretNamespace)
  692. - name: PRIVATE_KEY_SECRET_NAME
  693. value: $(params.privateKeySecretName)
  694. - name: PRIVATE_KEY_SECRET_NAMESPACE
  695. value: $(params.privateKeySecretNamespace)
  696. - name: ADDITIONAL_SSH_KEYGEN_OPTIONS
  697. value: $(params.additionalSSHKeygenOptions)
  698. ---
  699. apiVersion: rbac.authorization.k8s.io/v1
  700. kind: ClusterRole
  701. metadata:
  702. name: generate-ssh-keys-task
  703. rules:
  704. - verbs:
  705. - '*'
  706. apiGroups:
  707. - ''
  708. resources:
  709. - secrets
  710. ---
  711. apiVersion: v1
  712. kind: ServiceAccount
  713. metadata:
  714. name: generate-ssh-keys-task
  715. ---
  716. apiVersion: rbac.authorization.k8s.io/v1
  717. kind: RoleBinding
  718. metadata:
  719. name: generate-ssh-keys-task
  720. roleRef:
  721. kind: ClusterRole
  722. name: generate-ssh-keys-task
  723. apiGroup: rbac.authorization.k8s.io
  724. subjects:
  725. - kind: ServiceAccount
  726. name: generate-ssh-keys-task
  727. ---
  728. apiVersion: tekton.dev/v1beta1
  729. kind: ClusterTask
  730. metadata:
  731. annotations:
  732. task.kubevirt.io/associatedServiceAccount: modify-data-object-task
  733. manifest.params.task.kubevirt.io/type: resource-yaml
  734. manifest.params.task.kubevirt.io/apiVersion: cdi.kubevirt.io/v1beta1
  735. waitForSuccess.params.task.kubevirt.io/type: boolean
  736. labels:
  737. task.kubevirt.io/type: modify-data-object
  738. task.kubevirt.io/category: modify-data-object
  739. name: modify-data-object
  740. spec:
  741. description: >-
  742. This task modifies a data object (DataVolume or DataSource). It can optionally wait until CDI imports finish.
  743. params:
  744. - name: manifest
  745. description: YAML manifest of a data object to be created.
  746. type: string
  747. default: ''
  748. - name: namespace
  749. description: Namespace where to create the data object. (defaults to manifest namespace or active namespace)
  750. default: ""
  751. type: string
  752. - name: waitForSuccess
  753. description: Set to "true" or "false" if container should wait for Ready condition of the data object.
  754. default: 'false'
  755. type: string
  756. - name: allowReplace
  757. description: Allow replacing an already existing data object (same combination name/namespace). Allowed values true/false
  758. type: string
  759. default: "false"
  760. - name: deleteObject
  761. description: Set to `true` or `false` if task should delete the specified DataVolume, DataSource or PersistentVolumeClaim. If set to 'true' the ds/dv/pvc will be deleted and all other parameters are ignored.
  762. default: 'false'
  763. type: string
  764. - name: deleteObjectKind
  765. description: Kind of the data object to delete. This parameter is used only for Delete operation.
  766. default: ""
  767. type: string
  768. - name: deleteObjectName
  769. description: Name of the data object to delete. This parameter is used only for Delete operation.
  770. default: ""
  771. type: string
  772. results:
  773. - name: name
  774. description: The name of the data object that was created.
  775. - name: namespace
  776. description: The namespace of the data object that was created.
  777. steps:
  778. - name: modify-data-object
  779. image: "quay.io/kubevirt/tekton-task-modify-data-object:v0.13.2"
  780. command:
  781. - modify-data-object
  782. args:
  783. - "--output=yaml"
  784. env:
  785. - name: DATA_OBJECT_MANIFEST
  786. value: $(params.manifest)
  787. - name: DATA_OBJECT_NAMESPACE
  788. value: $(params.namespace)
  789. - name: WAIT_FOR_SUCCESS
  790. value: $(params.waitForSuccess)
  791. - name: ALLOW_REPLACE
  792. value: $(params.allowReplace)
  793. - name: DELETE_OBJECT
  794. value: $(params.deleteObject)
  795. - name: DELETE_OBJECT_KIND
  796. value: $(params.deleteObjectKind)
  797. - name: DELETE_OBJECT_NAME
  798. value: $(params.deleteObjectName)
  799. ---
  800. apiVersion: rbac.authorization.k8s.io/v1
  801. kind: ClusterRole
  802. metadata:
  803. name: modify-data-object-task
  804. rules:
  805. - verbs:
  806. - get
  807. - create
  808. - delete
  809. apiGroups:
  810. - cdi.kubevirt.io
  811. resources:
  812. - datavolumes
  813. - datasources
  814. - verbs:
  815. - create
  816. apiGroups:
  817. - ""
  818. resources:
  819. - pods
  820. - verbs:
  821. - get
  822. - delete
  823. apiGroups:
  824. - ""
  825. resources:
  826. - persistentvolumeclaims
  827. ---
  828. apiVersion: v1
  829. kind: ServiceAccount
  830. metadata:
  831. name: modify-data-object-task
  832. ---
  833. apiVersion: rbac.authorization.k8s.io/v1
  834. kind: RoleBinding
  835. metadata:
  836. name: modify-data-object-task
  837. roleRef:
  838. kind: ClusterRole
  839. name: modify-data-object-task
  840. apiGroup: rbac.authorization.k8s.io
  841. subjects:
  842. - kind: ServiceAccount
  843. name: modify-data-object-task
  844. ---
  845. apiVersion: tekton.dev/v1beta1
  846. kind: ClusterTask
  847. metadata:
  848. annotations:
  849. task.kubevirt.io/associatedServiceAccount: modify-windows-iso-file-task
  850. labels:
  851. task.kubevirt.io/type: modify-windows-iso-file
  852. task.kubevirt.io/category: modify-windows-iso-file
  853. name: modify-windows-iso-file
  854. spec:
  855. params:
  856. - name: pvcName
  857. description: PersistentVolumeClaim which contains windows iso.
  858. type: string
  859. default: ""
  860. steps:
  861. - name: modify-iso-file
  862. securityContext:
  863. allowPrivilegeEscalation: false
  864. capabilities:
  865. drop:
  866. - "ALL"
  867. image: "quay.io/kubevirt/tekton-task-disk-virt-customize:v0.13.2"
  868. script: |
  869. #!/bin/bash
  870. set -x
  871. export LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance
  872. export ISO_FILES_PATH="/tmp/extracted-iso-files"
  873. export EFI_BOOT="${ISO_FILES_PATH}/efi/microsoft/boot"
  874. export TARGET_IMG_FILE_PATH="tmp/target-pvc/disk.img"
  875. guestfish -a ${TARGET_IMG_FILE_PATH} -m /dev/sda tar-out / - | tar xvf - -C ${ISO_FILES_PATH} -m --no-overwrite-dir --owner=$(id -u) --group=$(id -g) --no-same-permissions
  876. chmod u+w "${ISO_FILES_PATH}/efi" "${ISO_FILES_PATH}/efi/microsoft" "${ISO_FILES_PATH}/efi/microsoft/boot"
  877. chmod u+w "${EFI_BOOT}/efisys.bin" "${EFI_BOOT}/cdboot.efi" "${EFI_BOOT}/efisys_noprompt.bin" "${EFI_BOOT}/cdboot_noprompt.efi"
  878. rm "${EFI_BOOT}/efisys.bin" "${EFI_BOOT}/cdboot.efi"
  879. mv "${EFI_BOOT}/efisys_noprompt.bin" "${EFI_BOOT}/efisys.bin"
  880. mv "${EFI_BOOT}/cdboot_noprompt.efi" "${EFI_BOOT}/cdboot.efi"
  881. env:
  882. - name: "LIBGUESTFS_BACKEND"
  883. value: "direct"
  884. - name: "HOME"
  885. value: "/usr/local/lib/guestfs/appliance"
  886. resources:
  887. limits:
  888. devices.kubevirt.io/kvm: '1'
  889. requests:
  890. devices.kubevirt.io/kvm: '1'
  891. volumeMounts:
  892. - mountPath: /tmp/target-pvc/
  893. name: target-pvc
  894. - mountPath: /tmp/extracted-iso-files/
  895. name: extracted-iso-files
  896. - name: create-iso-file
  897. securityContext:
  898. allowPrivilegeEscalation: false
  899. capabilities:
  900. drop:
  901. - "ALL"
  902. image: "quay.io/kubevirt/tekton-task-modify-data-object:v0.13.2"
  903. script: |
  904. #!/bin/bash
  905. set -ex
  906. export ISO_FILES_PATH="/tmp/extracted-iso-files"
  907. export ISO_FILE_PATH="/tmp/iso-file/disk.iso"
  908. xorriso -as mkisofs -no-emul-boot \
  909. -e "efi/microsoft/boot/efisys.bin" \
  910. -boot-load-size 1 \
  911. -iso-level 4 \
  912. -J -l -D -N \
  913. -joliet-long \
  914. -relaxed-filenames \
  915. -V "WINDOWS" \
  916. -o ${ISO_FILE_PATH} ${ISO_FILES_PATH}
  917. volumeMounts:
  918. - mountPath: /tmp/extracted-iso-files/
  919. name: extracted-iso-files
  920. - mountPath: /tmp/iso-file/
  921. name: iso-file
  922. - name: convert-iso-file
  923. securityContext:
  924. allowPrivilegeEscalation: false
  925. capabilities:
  926. drop:
  927. - "ALL"
  928. image: "quay.io/kubevirt/tekton-task-disk-virt-customize:v0.13.2"
  929. script: |
  930. #!/bin/bash
  931. set -x
  932. export ISO_FILE_PATH="/tmp/iso-file/disk.iso"
  933. export TARGET_IMG_FILE_PATH="/tmp/target-pvc/disk.img"
  934. rm ${TARGET_IMG_FILE_PATH}
  935. qemu-img convert -t writeback -p -O raw ${ISO_FILE_PATH} ${TARGET_IMG_FILE_PATH}
  936. volumeMounts:
  937. - mountPath: /tmp/target-pvc/
  938. name: target-pvc
  939. - mountPath: /tmp/iso-file/
  940. name: iso-file
  941. volumes:
  942. - name: target-pvc
  943. persistentVolumeClaim:
  944. claimName: "$(params.pvcName)"
  945. - name: extracted-iso-files
  946. emptyDir:
  947. sizeLimit: 7Gi
  948. - name: iso-file
  949. emptyDir:
  950. sizeLimit: 7Gi
  951. ---
  952. apiVersion: tekton.dev/v1beta1
  953. kind: ClusterTask
  954. metadata:
  955. annotations:
  956. task.kubevirt.io/associatedServiceAccount: wait-for-vmi-status-task
  957. vmiNamespace.params.task.kubevirt.io/type: namespace
  958. labels:
  959. task.kubevirt.io/type: wait-for-vmi-status
  960. task.kubevirt.io/category: wait-for-vmi-status
  961. name: wait-for-vmi-status
  962. spec:
  963. params:
  964. - name: vmiName
  965. description: Name of a VirtualMachineInstance to wait for.
  966. type: string
  967. - name: vmiNamespace
  968. description: Namespace of a VirtualMachineInstance to wait for. (defaults to manifest namespace or active namespace)
  969. default: ""
  970. type: string
  971. - name: successCondition
  972. default: ""
  973. description: A label selector expression to decide if the VirtualMachineInstance (VMI) is in a success state. Eg. "status.phase == Succeeded". It is evaluated on each VMI update and will result in this task succeeding if true.
  974. - name: failureCondition
  975. default: ""
  976. description: A label selector expression to decide if the VirtualMachineInstance (VMI) is in a failed state. Eg. "status.phase in (Failed, Unknown)". It is evaluated on each VMI update and will result in this task failing if true.
  977. steps:
  978. - name: wait-for-vmi-status
  979. image: "quay.io/kubevirt/tekton-task-wait-for-vmi-status:v0.13.2"
  980. command:
  981. - entrypoint
  982. env:
  983. - name: VMI_NAME
  984. value: $(params.vmiName)
  985. - name: VMI_NAMESPACE
  986. value: $(params.vmiNamespace)
  987. - name: SUCCESS_CONDITION
  988. value: $(params.successCondition)
  989. - name: FAILURE_CONDITION
  990. value: $(params.failureCondition)
  991. ---
  992. apiVersion: rbac.authorization.k8s.io/v1
  993. kind: ClusterRole
  994. metadata:
  995. name: wait-for-vmi-status-task
  996. rules:
  997. - verbs:
  998. - get
  999. - list
  1000. - watch
  1001. apiGroups:
  1002. - kubevirt.io
  1003. resources:
  1004. - virtualmachineinstances
  1005. ---
  1006. apiVersion: v1
  1007. kind: ServiceAccount
  1008. metadata:
  1009. name: wait-for-vmi-status-task
  1010. ---
  1011. apiVersion: rbac.authorization.k8s.io/v1
  1012. kind: RoleBinding
  1013. metadata:
  1014. name: wait-for-vmi-status-task
  1015. roleRef:
  1016. kind: ClusterRole
  1017. name: wait-for-vmi-status-task
  1018. apiGroup: rbac.authorization.k8s.io
  1019. subjects:
  1020. - kind: ServiceAccount
  1021. name: wait-for-vmi-status-task