diff --git a/automation/check-validations.py b/automation/check-validations.py index 8ac7d384..7cf5a639 100644 --- a/automation/check-validations.py +++ b/automation/check-validations.py @@ -21,7 +21,7 @@ def checkValidations(path): logging.info("Checking " + template["metadata"]["name"]) try: - json.loads(template["metadata"]["annotations"]["validations"]) + json.loads(template["objects"][0]["metadata"]["annotations"]["vm.kubevirt.io/validations"]) except Exception as e: logging.info("Validation is not json") raise e diff --git a/automation/unit-tests.sh b/automation/unit-tests.sh index f56a413d..528c0106 100755 --- a/automation/unit-tests.sh +++ b/automation/unit-tests.sh @@ -3,7 +3,7 @@ set -ex make generate #syntax check -templates=($(grep -L "template.kubevirt.io/deprecated: \"true\"" dist/templates/*)) +templates=( dist/templates/* ) namespace="kubevirt" oc apply -f - <- Template for CentOS 6 VM or newer. A PVC with the CentOS disk image must be available. tags: "hidden,kubevirt,virtualmachine,linux,centos" - -{% set diskbus = diskbus |default("sata") %} - -{% include "_linux.yaml" %} - + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/centos7.tpl.yaml b/templates/centos7.tpl.yaml index 03d307c5..8581d0d4 100644 --- a/templates/centos7.tpl.yaml +++ b/templates/centos7.tpl.yaml @@ -1,14 +1,150 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "CentOS 7.0+ VM" description: >- Template for CentOS 7 VM or newer. A PVC with the CentOS disk image must be available. tags: "hidden,kubevirt,virtualmachine,linux,centos" - -{% include "_linux.yaml" %} - + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/centos8.tpl.yaml b/templates/centos8.tpl.yaml index af6c22a8..fe4b86fb 100644 --- a/templates/centos8.tpl.yaml +++ b/templates/centos8.tpl.yaml @@ -1,14 +1,150 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "CentOS 8.0+ VM" description: >- Template for CentOS 8 VM or newer. A PVC with the CentOS disk image must be available. tags: "hidden,kubevirt,virtualmachine,linux,centos" - -{% include "_linux.yaml" %} - + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/deprecated-windows.tpl.yaml b/templates/deprecated-windows.tpl.yaml deleted file mode 100644 index a0218fec..00000000 --- a/templates/deprecated-windows.tpl.yaml +++ /dev/null @@ -1,148 +0,0 @@ -{% set version = "0.12.3" %} -apiVersion: template.openshift.io/v1 -kind: Template -metadata: - name: windows-{{ item.workload }}-{{ item.flavor }}-v{{ version }} - annotations: - openshift.io/display-name: "Microsoft Windows Server 2012 R2+ VM" - description: >- - Template for Microsoft Windows Server 2012 R2 VM or newer. - A PVC with the Windows disk image must be available. - tags: "hidden,kubevirt,virtualmachine,windows" - iconClass: "icon-windows" - openshift.io/provider-display-name: "KubeVirt" - openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" - openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" - template.openshift.io/bindable: "false" - - template.kubevirt.io/version: v1alpha1 - template.kubevirt.io/deprecated: "true" - defaults.template.kubevirt.io/disk: rootdisk - defaults.template.kubevirt.io/network: default - template.kubevirt.io/editable: | - /objects[0].spec.template.spec.domain.cpu.cores - /objects[0].spec.template.spec.domain.resources.requests.memory - /objects[0].spec.template.spec.domain.devices.disks - /objects[0].spec.template.spec.volumes - /objects[0].spec.template.spec.networks - - validations: | - [ - { - "name": "minimal-required-memory", - "path": "jsonpath::.spec.domain.resources.requests.memory", - "rule": "integer", - "message": "This VM requires more memory.", - "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} - }, { - "name": "windows-virtio-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", - "values": ["virtio"], - "justWarning": true - }, { - "name": "windows-disk-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "disk bus has to be either virtio or sata", - "values": ["virtio", "sata"] - }, { - "name": "windows-cd-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "rule": "enum", - "message": "cd bus has to be sata", - "values": ["sata"] - } - ] - - labels: - template.kubevirt.io/type: "base" - # Locking the template version as it is deprecated and should not receive any more updates - template.kubevirt.io/version: "v{{ version }}" - -objects: -- apiVersion: kubevirt.io/v1alpha3 - kind: VirtualMachine - metadata: - name: ${NAME} - labels: - vm.kubevirt.io/template: windows-{{ item.workload }}-{{ item.flavor }}-v{{ version }} - vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" - vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" - app: ${NAME} - spec: - running: false - template: - metadata: - labels: - kubevirt.io/domain: ${NAME} - kubevirt.io/size: {{ item.flavor }} - spec: - domain: - clock: - utc: {} - timer: - hpet: - present: false - pit: - tickPolicy: delay - rtc: - tickPolicy: catchup - hyperv: {} - cpu: - sockets: {{ item.cpus }} - cores: 1 - threads: 1 - resources: - requests: - memory: {{ item.memsize }} - features: - acpi: {} - apic: {} - hyperv: - relaxed: {} - vapic: {} - spinlocks: - spinlocks: 8191 - devices: - disks: - - disk: - bus: sata - name: rootdisk - interfaces: - - masquerade: {} - model: e1000e - name: default -{% if item.tablet %} - inputs: - - type: tablet - bus: usb - name: tablet -{% endif %} - terminationGracePeriodSeconds: 3600 - volumes: - - name: rootdisk - persistentVolumeClaim: - claimName: ${PVCNAME} - networks: - - name: default - pod: {} - -parameters: -- name: NAME - description: VM name - generate: expression - from: "windows-[a-z0-9]{6}" -- name: PVCNAME - description: Name of the PVC with the disk image - required: true -- name: SRC_PVC_NAME - description: Name of the PVC to clone - value: win2k19 -- name: SRC_PVC_NAMESPACE - description: Namespace of the source PVC - value: kubevirt-os-images diff --git a/templates/fedora.tpl.yaml b/templates/fedora.tpl.yaml index 670e19d7..28131650 100644 --- a/templates/fedora.tpl.yaml +++ b/templates/fedora.tpl.yaml @@ -1,17 +1,152 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Fedora 31+ VM" description: >- Template for Fedora 31 VM or newer. A PVC with the Fedora disk image must be available. - Recommended disk image: https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-32-1.6.x86_64.qcow2 tags: "hidden,kubevirt,virtualmachine,fedora" - -{% include "_linux.yaml" %} - + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/opensuse.tpl.yaml b/templates/opensuse.tpl.yaml index 494225be..5413e2f3 100644 --- a/templates/opensuse.tpl.yaml +++ b/templates/opensuse.tpl.yaml @@ -1,16 +1,152 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "OpenSUSE Leap 15.0 VM" description: >- Template for OpenSUSE Leap 15.0 VM. A PVC with the OpenSUSE disk image must be available. - Recommended disk image: https://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.0/images/ tags: "hidden,kubevirt,virtualmachine,linux,opensuse" - -{% include "_linux.yaml" %} + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/rhel6.tpl.yaml b/templates/rhel6.tpl.yaml index 2ce58852..95b1d465 100644 --- a/templates/rhel6.tpl.yaml +++ b/templates/rhel6.tpl.yaml @@ -1,16 +1,151 @@ -{% set version = "0.13.0" %} +{% set diskbus = diskbus |default("sata") %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Red Hat Enterprise Linux 6.0+ VM" description: >- Template for Red Hat Enterprise Linux 6 VM or newer. A PVC with the RHEL disk image must be available. tags: "hidden,kubevirt,virtualmachine,linux,rhel" - -{% set diskbus = diskbus |default("sata") %} - -{% include "_linux.yaml" %} - + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/rhel7.tpl.yaml b/templates/rhel7.tpl.yaml index b5d29ffd..a54e2b9d 100644 --- a/templates/rhel7.tpl.yaml +++ b/templates/rhel7.tpl.yaml @@ -1,14 +1,150 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Red Hat Enterprise Linux 7.0+ VM" description: >- Template for Red Hat Enterprise Linux 7 VM or newer. A PVC with the RHEL disk image must be available. tags: "hidden,kubevirt,virtualmachine,linux,rhel" - -{% include "_linux.yaml" %} - + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/rhel8.tpl.yaml b/templates/rhel8.tpl.yaml index 3443b9a8..d1928fcd 100644 --- a/templates/rhel8.tpl.yaml +++ b/templates/rhel8.tpl.yaml @@ -1,14 +1,150 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Red Hat Enterprise Linux 8.0+ VM" description: >- Template for Red Hat Enterprise Linux 8 VM or newer. A PVC with the RHEL disk image must be available. tags: "hidden,kubevirt,virtualmachine,linux,rhel" - -{% include "_linux.yaml" %} - + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/ubuntu.tpl.yaml b/templates/ubuntu.tpl.yaml index 9ce1372b..4292f42d 100644 --- a/templates/ubuntu.tpl.yaml +++ b/templates/ubuntu.tpl.yaml @@ -1,16 +1,152 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Ubuntu 18.04 (Xenial Xerus) VM" description: >- Template for Ubuntu 18.04 (Xenial Xerus) VM. A PVC with the Ubuntu disk image must be available. - Recommended disk image: http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img tags: "hidden,kubevirt,virtualmachine,ubuntu" - -{% include "_linux.yaml" %} + iconClass: "icon-{{ icon }}" + openshift.io/provider-display-name: "KubeVirt" + openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" + openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" + template.openshift.io/bindable: "false" + template.kubevirt.io/version: v1alpha1 + defaults.template.kubevirt.io/disk: rootdisk + template.kubevirt.io/editable: | + /objects[0].spec.template.spec.domain.cpu.sockets + /objects[0].spec.template.spec.domain.cpu.cores + /objects[0].spec.template.spec.domain.cpu.threads + /objects[0].spec.template.spec.domain.resources.requests.memory + /objects[0].spec.template.spec.domain.devices.disks + /objects[0].spec.template.spec.volumes + /objects[0].spec.template.spec.networks +{% for osl in oslabels %} + name.os.template.kubevirt.io/{{ osl }}: {{ lookup('osinfo', oslabels[0]).name }} or higher +{% endfor %} + labels: +{% for osl in oslabels %} + os.template.kubevirt.io/{{ osl }}: "true" +{% endfor %} + workload.template.kubevirt.io/{{ item.workload }}: "true" + flavor.template.kubevirt.io/{{ item.flavor }}: "true" + template.kubevirt.io/type: "base" + template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" +{% if item.default %} + template.kubevirt.io/default-os-variant: "true" +{% endif %} +objects: +- apiVersion: kubevirt.io/v1alpha3 + kind: VirtualMachine + metadata: + name: ${NAME} + labels: + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" + vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" + app: ${NAME} + annotations: + vm.kubevirt.io/os: "{{ os }}" + vm.kubevirt.io/workload: "{{ item.workload }}" + vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }} + } + ] + spec: + dataVolumeTemplates: + - apiVersion: cdi.kubevirt.io/v1beta1 + kind: DataVolume + metadata: + name: ${NAME} + spec: + pvc: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 30Gi + source: + pvc: + name: ${SRC_PVC_NAME} + namespace: ${SRC_PVC_NAMESPACE} + running: false + template: + metadata: + labels: + kubevirt.io/domain: ${NAME} + kubevirt.io/size: {{ item.flavor }} + spec: + domain: +{% if item.iothreads %} + ioThreadsPolicy: shared +{% endif %} + cpu: + sockets: {{ item.cpus }} + cores: 1 + threads: 1 +{% if cpumodel |default("") %} + model: {{ cpumodel }} +{% endif %} + resources: + requests: + memory: {{ item.memsize }} + devices: + rng: {} + networkInterfaceMultiqueue: true +{% if item.tablet %} + inputs: + - type: tablet + bus: virtio + name: tablet +{% endif %} + disks: + - disk: + bus: {{ diskbus | default("virtio") }} + name: ${NAME} + - disk: + bus: {{ diskbus | default("virtio") }} + name: cloudinitdisk + interfaces: + - masquerade: {} + name: default + terminationGracePeriodSeconds: 180 + networks: + - name: default + pod: {} + volumes: + - dataVolume: + name: ${NAME} + name: ${NAME} + - cloudInitNoCloud: + userData: |- + #cloud-config + user: {{ cloudusername }} + password: ${CLOUD_USER_PASSWORD} + chpasswd: { expire: False } + name: cloudinitdisk +parameters: +- description: VM name + from: '{{ os }}-[a-z0-9]{16}' + generate: expression + name: NAME +- name: SRC_PVC_NAME + description: Name of the PVC to clone + value: '{{ majorrelease }}' +- name: SRC_PVC_NAMESPACE + description: Namespace of the source PVC + value: kubevirt-os-images +- description: Randomized password for the cloud-init user {{ cloudusername }} + from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' + generate: expression + name: CLOUD_USER_PASSWORD diff --git a/templates/win2k12r2-deprecated.tpl.yaml b/templates/win2k12r2-deprecated.tpl.yaml deleted file mode 100644 index 82902fcf..00000000 --- a/templates/win2k12r2-deprecated.tpl.yaml +++ /dev/null @@ -1,142 +0,0 @@ -{% set version = "0.11.3" %} -apiVersion: template.openshift.io/v1 -kind: Template -metadata: - name: win2k12r2-{{ item.workload }}-{{ item.flavor }}-v{{ version }} - annotations: - openshift.io/display-name: "Microsoft Windows Server 2012 R2 VM" - description: >- - Template for Microsoft Windows Server 2012 R2 VM. - A PVC with the Windows disk image must be available. - tags: "hidden,kubevirt,virtualmachine,windows" - iconClass: "icon-windows" - openshift.io/provider-display-name: "KubeVirt" - openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" - openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" - template.openshift.io/bindable: "false" - - template.kubevirt.io/version: v1alpha1 - template.kubevirt.io/deprecated: "true" - defaults.template.kubevirt.io/disk: rootdisk - defaults.template.kubevirt.io/network: default - template.kubevirt.io/editable: | - /objects[0].spec.template.spec.domain.cpu.cores - /objects[0].spec.template.spec.domain.resources.requests.memory - /objects[0].spec.template.spec.domain.devices.disks - /objects[0].spec.template.spec.volumes - /objects[0].spec.template.spec.networks - - validations: | - [ - { - "name": "minimal-required-memory", - "path": "jsonpath::.spec.domain.resources.requests.memory", - "rule": "integer", - "message": "This VM requires more memory.", - "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} - }, { - "name": "windows-virtio-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", - "values": ["virtio"], - "justWarning": true - }, { - "name": "windows-disk-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "disk bus has to be either virtio or sata", - "values": ["virtio", "sata"] - }, { - "name": "windows-cd-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "rule": "enum", - "message": "cd bus has to be sata", - "values": ["sata"] - } - ] - - labels: - template.kubevirt.io/type: "base" - # Locking the template version as it is deprecated and should not receive any more updates - template.kubevirt.io/version: "v{{ version }}" - -objects: -- apiVersion: kubevirt.io/v1alpha3 - kind: VirtualMachine - metadata: - name: ${NAME} - labels: - vm.kubevirt.io/template: win2k12r2-{{ item.workload }}-{{ item.flavor }}-v{{ version }} - vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" - vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" - app: ${NAME} - spec: - running: false - template: - metadata: - labels: - kubevirt.io/domain: ${NAME} - kubevirt.io/size: {{ item.flavor }} - spec: - domain: - clock: - utc: {} - timer: - hpet: - present: false - pit: - tickPolicy: delay - rtc: - tickPolicy: catchup - hyperv: {} - cpu: - sockets: {{ item.cpus }} - cores: 1 - threads: 1 - resources: - requests: - memory: {{ item.memsize }} - features: - acpi: {} - apic: {} - hyperv: - relaxed: {} - vapic: {} - spinlocks: - spinlocks: 8191 - devices: - disks: - - disk: - bus: sata - name: rootdisk - interfaces: - - masquerade: {} - model: e1000e - name: default -{% if item.tablet %} - inputs: - - type: tablet - bus: usb - name: tablet -{% endif %} - terminationGracePeriodSeconds: 3600 - volumes: - - name: rootdisk - persistentVolumeClaim: - claimName: ${PVCNAME} - networks: - - name: default - pod: {} - -parameters: -- name: NAME - description: VM name - generate: expression - from: "win2k12-[a-z0-9]{6}" -- name: PVCNAME - description: Name of the PVC with the disk image - required: true diff --git a/templates/windows10.tpl.yaml b/templates/windows10.tpl.yaml index 34c92fb8..5ace445b 100644 --- a/templates/windows10.tpl.yaml +++ b/templates/windows10.tpl.yaml @@ -1,8 +1,7 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: windows10-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: windows10-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Microsoft Windows 10 VM" description: >- @@ -14,7 +13,6 @@ metadata: openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" template.openshift.io/bindable: "false" - template.kubevirt.io/version: v1alpha1 defaults.template.kubevirt.io/disk: rootdisk defaults.template.kubevirt.io/network: default @@ -24,42 +22,7 @@ metadata: /objects[0].spec.template.spec.domain.devices.disks /objects[0].spec.template.spec.volumes /objects[0].spec.template.spec.networks - name.os.template.kubevirt.io/win10: {{ lookup('osinfo', 'win10').name }} - - validations: | - [ - { - "name": "minimal-required-memory", - "path": "jsonpath::.spec.domain.resources.requests.memory", - "rule": "integer", - "message": "This VM requires more memory.", - "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64.ram"] }} - }, { - "name": "windows-virtio-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", - "values": ["virtio"], - "justWarning": true - }, { - "name": "windows-disk-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "disk bus has to be either virtio or sata", - "values": ["virtio", "sata"] - }, { - "name": "windows-cd-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "rule": "enum", - "message": "cd bus has to be sata", - "values": ["sata"] - } - ] - labels: os.template.kubevirt.io/win10: "true" workload.template.kubevirt.io/{{ item.workload }}: "true" @@ -69,14 +32,13 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} - objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: windows10-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + vm.kubevirt.io/template: windows10-{{ item.workload }}-{{ item.flavor }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} @@ -84,6 +46,38 @@ objects: vm.kubevirt.io/os: "windows10" vm.kubevirt.io/workload: "{{ item.workload }}" vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64.ram"] }} + }, { + "name": "windows-virtio-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", + "values": ["virtio"], + "justWarning": true + }, { + "name": "windows-disk-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "disk bus has to be either virtio or sata", + "values": ["virtio", "sata"] + }, { + "name": "windows-cd-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "rule": "enum", + "message": "cd bus has to be sata", + "values": ["sata"] + } + ] spec: dataVolumeTemplates: - apiVersion: cdi.kubevirt.io/v1beta1 @@ -166,7 +160,6 @@ objects: networks: - name: default pod: {} - parameters: - name: NAME description: VM name diff --git a/templates/windows2k12.tpl.yaml b/templates/windows2k12.tpl.yaml index ad942be0..bbdb2e2b 100644 --- a/templates/windows2k12.tpl.yaml +++ b/templates/windows2k12.tpl.yaml @@ -1,8 +1,7 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: windows2k12r2-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: windows2k12r2-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Microsoft Windows Server 2012 R2 VM" description: >- @@ -14,7 +13,6 @@ metadata: openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" template.openshift.io/bindable: "false" - template.kubevirt.io/version: v1alpha1 defaults.template.kubevirt.io/disk: rootdisk defaults.template.kubevirt.io/network: default @@ -24,42 +22,7 @@ metadata: /objects[0].spec.template.spec.domain.devices.disks /objects[0].spec.template.spec.volumes /objects[0].spec.template.spec.networks - name.os.template.kubevirt.io/win2k12r2: {{ lookup('osinfo', 'win2k12r2').name }} - - validations: | - [ - { - "name": "minimal-required-memory", - "path": "jsonpath::.spec.domain.resources.requests.memory", - "rule": "integer", - "message": "This VM requires more memory.", - "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} - }, { - "name": "windows-virtio-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", - "values": ["virtio"], - "justWarning": true - }, { - "name": "windows-disk-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "disk bus has to be either virtio or sata", - "values": ["virtio", "sata"] - }, { - "name": "windows-cd-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "rule": "enum", - "message": "cd bus has to be sata", - "values": ["sata"] - } - ] - labels: os.template.kubevirt.io/win2k12r2: "true" workload.template.kubevirt.io/{{ item.workload }}: "true" @@ -69,14 +32,13 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} - objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: windows2k12r2-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + vm.kubevirt.io/template: windows2k12r2-{{ item.workload }}-{{ item.flavor }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} @@ -84,6 +46,38 @@ objects: vm.kubevirt.io/os: "windows2k12r2" vm.kubevirt.io/workload: "{{ item.workload }}" vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} + }, { + "name": "windows-virtio-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", + "values": ["virtio"], + "justWarning": true + }, { + "name": "windows-disk-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "disk bus has to be either virtio or sata", + "values": ["virtio", "sata"] + }, { + "name": "windows-cd-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "rule": "enum", + "message": "cd bus has to be sata", + "values": ["sata"] + } + ] spec: dataVolumeTemplates: - apiVersion: cdi.kubevirt.io/v1beta1 @@ -166,7 +160,6 @@ objects: networks: - name: default pod: {} - parameters: - name: NAME description: VM name diff --git a/templates/windows2k16.tpl.yaml b/templates/windows2k16.tpl.yaml index 407babe7..6dcbd050 100644 --- a/templates/windows2k16.tpl.yaml +++ b/templates/windows2k16.tpl.yaml @@ -1,8 +1,7 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: windows2k16-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: windows2k16-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Microsoft Windows Server 2016 VM" description: >- @@ -14,7 +13,6 @@ metadata: openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" template.openshift.io/bindable: "false" - template.kubevirt.io/version: v1alpha1 defaults.template.kubevirt.io/disk: rootdisk defaults.template.kubevirt.io/network: default @@ -24,42 +22,7 @@ metadata: /objects[0].spec.template.spec.domain.devices.disks /objects[0].spec.template.spec.volumes /objects[0].spec.template.spec.networks - name.os.template.kubevirt.io/win2k16: {{ lookup('osinfo', 'win2k16').name }} - - validations: | - [ - { - "name": "minimal-required-memory", - "path": "jsonpath::.spec.domain.resources.requests.memory", - "rule": "integer", - "message": "This VM requires more memory.", - "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} - }, { - "name": "windows-virtio-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", - "values": ["virtio"], - "justWarning": true - }, { - "name": "windows-disk-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "disk bus has to be either virtio or sata", - "values": ["virtio", "sata"] - }, { - "name": "windows-cd-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "rule": "enum", - "message": "cd bus has to be sata", - "values": ["sata"] - } - ] - labels: os.template.kubevirt.io/win2k16: "true" workload.template.kubevirt.io/{{ item.workload }}: "true" @@ -69,14 +32,13 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} - objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: windows2k16-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + vm.kubevirt.io/template: windows2k16-{{ item.workload }}-{{ item.flavor }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} @@ -84,6 +46,38 @@ objects: vm.kubevirt.io/os: "windows2k16" vm.kubevirt.io/workload: "{{ item.workload }}" vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} + }, { + "name": "windows-virtio-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", + "values": ["virtio"], + "justWarning": true + }, { + "name": "windows-disk-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "disk bus has to be either virtio or sata", + "values": ["virtio", "sata"] + }, { + "name": "windows-cd-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "rule": "enum", + "message": "cd bus has to be sata", + "values": ["sata"] + } + ] spec: dataVolumeTemplates: - apiVersion: cdi.kubevirt.io/v1beta1 @@ -166,7 +160,6 @@ objects: networks: - name: default pod: {} - parameters: - name: NAME description: VM name diff --git a/templates/windows2k19.tpl.yaml b/templates/windows2k19.tpl.yaml index d22d7be3..1715ddf0 100644 --- a/templates/windows2k19.tpl.yaml +++ b/templates/windows2k19.tpl.yaml @@ -1,8 +1,7 @@ -{% set version = "0.13.0" %} apiVersion: template.openshift.io/v1 kind: Template metadata: - name: windows2k19-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + name: windows2k19-{{ item.workload }}-{{ item.flavor }} annotations: openshift.io/display-name: "Microsoft Windows Server 2019 VM" description: >- @@ -14,7 +13,6 @@ metadata: openshift.io/documentation-url: "https://github.com/kubevirt/common-templates" openshift.io/support-url: "https://github.com/kubevirt/common-templates/issues" template.openshift.io/bindable: "false" - template.kubevirt.io/version: v1alpha1 defaults.template.kubevirt.io/disk: rootdisk defaults.template.kubevirt.io/network: default @@ -24,42 +22,7 @@ metadata: /objects[0].spec.template.spec.domain.devices.disks /objects[0].spec.template.spec.volumes /objects[0].spec.template.spec.networks - name.os.template.kubevirt.io/win2k19: {{ lookup('osinfo', 'win2k19').name }} - - validations: | - [ - { - "name": "minimal-required-memory", - "path": "jsonpath::.spec.domain.resources.requests.memory", - "rule": "integer", - "message": "This VM requires more memory.", - "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} - }, { - "name": "windows-virtio-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", - "values": ["virtio"], - "justWarning": true - }, { - "name": "windows-disk-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", - "rule": "enum", - "message": "disk bus has to be either virtio or sata", - "values": ["virtio", "sata"] - }, { - "name": "windows-cd-bus", - "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", - "rule": "enum", - "message": "cd bus has to be sata", - "values": ["sata"] - } - ] - labels: os.template.kubevirt.io/win2k19: "true" workload.template.kubevirt.io/{{ item.workload }}: "true" @@ -69,14 +32,13 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} - objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: windows2k19-{{ item.workload }}-{{ item.flavor }}-v{{ version }} + vm.kubevirt.io/template: windows2k19-{{ item.workload }}-{{ item.flavor }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} @@ -84,6 +46,38 @@ objects: vm.kubevirt.io/os: "windows2k19" vm.kubevirt.io/workload: "{{ item.workload }}" vm.kubevirt.io/flavor: "{{ item.flavor }}" + vm.kubevirt.io/validations: | + [ + { + "name": "minimal-required-memory", + "path": "jsonpath::.spec.domain.resources.requests.memory", + "rule": "integer", + "message": "This VM requires more memory.", + "min": {{ lookup('osinfo', osinfoname)["minimum_resources.0.ram"] }} + }, { + "name": "windows-virtio-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "virto disk bus type has better performance, install virtio drivers in VM and change bus type", + "values": ["virtio"], + "justWarning": true + }, { + "name": "windows-disk-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].disk.bus", + "rule": "enum", + "message": "disk bus has to be either virtio or sata", + "values": ["virtio", "sata"] + }, { + "name": "windows-cd-bus", + "path": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "valid": "jsonpath::.spec.domain.devices.disks[*].cdrom.bus", + "rule": "enum", + "message": "cd bus has to be sata", + "values": ["sata"] + } + ] spec: dataVolumeTemplates: - apiVersion: cdi.kubevirt.io/v1beta1 @@ -166,7 +160,6 @@ objects: networks: - name: default pod: {} - parameters: - name: NAME description: VM name