-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from MarSik/meta-templating
Meta templating
- Loading branch information
Showing
19 changed files
with
436 additions
and
438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "ci"] | ||
path = ci | ||
url = https://github.com/fabiand/traviskube/ | ||
[submodule "osinfo-db"] | ||
path = osinfo-db | ||
url = https://gitlab.com/libosinfo/osinfo-db.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,80 @@ | ||
[![Build Status](https://travis-ci.com/kubevirt/common-templates.svg?branch=master)](https://travis-ci.com/kubevirt/common-templates) | ||
|
||
A set of Templates to create KubeVirt VMs. | ||
A set of (meta-)Templates to create KubeVirt VMs. | ||
|
||
# Overview | ||
|
||
All VMs are provided as [OpenShift templates](https://docs.okd.io/latest/dev_guide/templates.html). | ||
These templates can be used straight forward with OpenShift itself, or they | ||
can be transformed into regular objects for use with Kubernetes. | ||
This repository provides VM templates in the form compatible with [OpenShift templates](https://docs.okd.io/latest/dev_guide/templates.html) and kubevirt UI and those can further be transformed into regular objects for use with plain Kubernetes. | ||
|
||
Every template consists of two objects: | ||
The VM templates are generated from [meta-templates](templates/) via [Ansible](https://www.ansible.com/) and [libosinfo](https://libosinfo.org/). The generated templates are parametrized according to three aspects: the guest OS, the workload type and the size. The generated content is stored in [dist/](dist/). | ||
|
||
1. A VirtualMachineInstancePreset definition for the specific guest, this is | ||
comparable to a "flavor" | ||
2. A VirtualMachine definition which can be used to launch the guest, if a disk | ||
image is available (see below) | ||
The [Ansible playbook](https://docs.ansible.com/ansible/latest/user_guide/playbooks.html) [generate-templates.yaml](generate-templates.yaml) describes all combinations that should be generated. | ||
|
||
The presets allow to keep all the guest specific machine configuration in a | ||
single place. This configuration is applied to the VMs once they are started. | ||
Every template consists of a VirtualMachine definition which can be used to launch the guest, if a disk image is available (see below). | ||
|
||
# Requirements | ||
|
||
Is it necessary to install the following components to be able to run the Ansible generator and the CI suite: | ||
|
||
- jq | ||
- ansible >= 2.4 | ||
- libosinfo | ||
- python-gobject | ||
|
||
# Usage | ||
|
||
By default the snippets below from the table will fetch the template and | ||
process it. It fails if a parameter (like the PVC name) is required, but not | ||
provided. In such a case the parameter is appended to the snippet, i.e. | ||
`PVCNAME`. | ||
By default the process below takes a generated template and converts it to an VM object that can be used to start a virtual machine. | ||
The conversion fails if a parameter (like the PVC name) is required, but not | ||
provided (i.e.`PVCNAME`). | ||
|
||
```bash | ||
# Define the generic instance types: | ||
$ kubectl apply -f https://raw.githubusercontent.com/fabiand/common-templates/master/presets/instancetypes.yaml | ||
# Clone the repository | ||
$ git clone https://github.com/kubevirt/common-templates | ||
|
||
# Pull all submodules | ||
$ git submodule init update | ||
|
||
$ oc process --local -f https://git.io/fNp4Z | ||
The Template "win2k12r2" is invalid: template.parameters[1]: Required value: | ||
# Generate the template matrix | ||
$ pushd common-templates/templates | ||
$ ansible-playbook generate-templates.yaml | ||
|
||
# Pick a template by selecting | ||
# - the guest OS - win2k12r2 | ||
# - the workload type - generic | ||
# - the size - medium | ||
|
||
# Use the template | ||
$ oc process --local -f dist/templates/win2k1r2-generic-medium.dist.yaml | ||
The Template "win2k1r2-generic-medium" is invalid: template.parameters[1]: Required value: | ||
template.parameters[1]: parameter PVCNAME is required and must be specified | ||
|
||
$ oc process --local -f https://git.io/fNp4Z --parameters | ||
$ oc process --local -f dist/templates/win2k1r2-generic-medium.dist.yaml --parameters | ||
NAME DESCRIPTION GENERATOR VALUE | ||
NAME Name of the new VM expression windows2012r2-[a-z0-9]{6} | ||
PVCNAME Name of the PVC with the disk image | ||
|
||
$ oc process --local -f https://git.io/fNp4Z PVCNAME=mydisk | ||
$ oc process --local -f dist/templates/win2k1r2-generic-medium.dist.yaml PVCNAME=mydisk | ||
… | ||
|
||
$ oc process --local -f https://git.io/fNp4Z PVCNAME=mydisk | kubectl apply -f - | ||
virtualmachineinstancepreset.kubevirt.io/win2k12r2 created | ||
$ oc process --local -f dist/templates/win2k1r2-generic-medium.dist.yaml PVCNAME=mydisk | kubectl apply -f - | ||
virtualmachine.kubevirt.io/windows2012r2-rt1ap2 created | ||
|
||
$ | ||
``` | ||
|
||
# Templates | ||
|
||
The table below lists the guest operating systems that are covered by the templates. The meta-templates are not directly consumable, please use the [generator](generate-templates.yaml) to prepare the properly parametrized templates first. | ||
|
||
> **Note:** The templates are tuned for a specific guest version, but is often | ||
> usable with different versions as well, i.e. the Fedora 28 template is also | ||
> usable with Fedora 27 or 26. | ||
| Template | Snippet | | ||
| Guest OS | Meta-template | | ||
|---|---| | ||
| Microsoft Windows Server 2012 R2 (no CI) | [`oc process --local -f https://git.io/fNp4Z`](templates/win2k12r2.yaml) | | ||
| Fedora 28 | [`oc process --local -f https://git.io/fNpBU`](templates/fedora28.yaml) | | ||
| Red Hat Enterprise Linux 7.5 | [`oc process --local -f https://git.io/fNpuq`](templates/rhel75.yaml) | | ||
| Ubuntu 18.04 LTS | [`oc process --local -f https://git.io/fA4q5`](templates/ubuntu1804.yaml) | | ||
| OpenSUSE Leap 15.0 (no CI) | [`oc process --local -f https://git.io/fNpz2`](templates/opensuse15.yaml) | | ||
| CoreOS Container Linux | TBD | | ||
| Microsoft Windows Server 2012 R2 (no CI) | [win2k12r2](templates/win2k12r2.tpl.yaml) | | ||
| Fedora 28 | [fedora](templates/fedora.tpl.yaml) | | ||
| Red Hat Enterprise Linux 7.5 | [rhel7](templates/rhel7.tpl.yaml) | | ||
| Ubuntu 18.04 LTS | [ubuntu](templates/ubuntu.tpl.yaml) | | ||
| OpenSUSE Leap 15.0 (no CI) | [opensuse](templates/opensuse.tpl.yaml) | | ||
| Cent OS 7 | [centos7](templates/centos7.tpl.yaml) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
- connection: local | ||
hosts: 127.0.0.1 | ||
tasks: | ||
- name: Prepare dist directory | ||
file: | ||
path: "{{ playbook_dir }}/dist/templates" | ||
state: directory | ||
|
||
- name: Generate RHEL 7 templates | ||
template: | ||
src: rhel7.tpl.yaml | ||
dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" | ||
with_items: | ||
- {flavor: tiny, workload: generic, memsize: "1G", cores: 1, iothreads: False} | ||
- {flavor: tiny, workload: highperformance, memsize: "1G", cores: 1, iothreads: True} | ||
- {flavor: small, workload: generic, memsize: "2G", cores: 1, iothreads: False} | ||
- {flavor: small, workload: highperformance, memsize: "2G", cores: 1, iothreads: True} | ||
- {flavor: medium, workload: generic, memsize: "4G", cores: 1, iothreads: False} | ||
- {flavor: medium, workload: highperformance, memsize: "4G", cores: 1, iothreads: True} | ||
- {flavor: large, workload: generic, memsize: "8G", cores: 2, iothreads: False} | ||
- {flavor: large, workload: highperformance, memsize: "8G", cores: 2, iothreads: True} | ||
vars: | ||
os: rhel7 | ||
icon: rhel | ||
password: redhat | ||
oslabels: | ||
- rhel7.0 | ||
- rhel7.1 | ||
- rhel7.2 | ||
- rhel7.3 | ||
- rhel7.4 | ||
- rhel7.5 | ||
osinfoname: "{{ oslabels[0] }}" | ||
|
||
- name: Generate CentOS 7 templates | ||
template: | ||
src: centos7.tpl.yaml | ||
dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" | ||
with_items: | ||
- {flavor: tiny, workload: generic, memsize: "1G", cores: 1, iothreads: False} | ||
- {flavor: small, workload: generic, memsize: "2G", cores: 1, iothreads: False} | ||
- {flavor: medium, workload: generic, memsize: "4G", cores: 1, iothreads: False} | ||
- {flavor: large, workload: generic, memsize: "8G", cores: 2, iothreads: False} | ||
vars: | ||
os: centos7 | ||
icon: centos | ||
password: centos | ||
oslabels: | ||
- centos7.0 | ||
osinfoname: "{{ oslabels[0] }}" | ||
|
||
- name: Generate Fedora templates | ||
template: | ||
src: fedora.tpl.yaml | ||
dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" | ||
with_items: | ||
- {flavor: tiny, workload: generic, memsize: "1G", cores: 1, iothreads: False} | ||
- {flavor: tiny, workload: highperformance, memsize: "1G", cores: 1, iothreads: True} | ||
- {flavor: small, workload: generic, memsize: "2G", cores: 1, iothreads: False} | ||
- {flavor: small, workload: highperformance, memsize: "2G", cores: 1, iothreads: True} | ||
- {flavor: medium, workload: generic, memsize: "4G", cores: 1, iothreads: False} | ||
- {flavor: medium, workload: highperformance, memsize: "4G", cores: 1, iothreads: True} | ||
- {flavor: large, workload: generic, memsize: "8G", cores: 2, iothreads: False} | ||
- {flavor: large, workload: highperformance, memsize: "8G", cores: 2, iothreads: True} | ||
vars: | ||
os: fedora | ||
icon: fedora | ||
password: fedora | ||
oslabels: | ||
- fedora26 | ||
- fedora27 | ||
- fedora28 | ||
osinfoname: "{{ oslabels[0] }}" | ||
|
||
- name: Generate OpenSUSE templates | ||
template: | ||
src: opensuse.tpl.yaml | ||
dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" | ||
with_items: | ||
- {flavor: tiny, workload: generic, memsize: "1G", cores: 1, iothreads: False} | ||
- {flavor: small, workload: generic, memsize: "2G", cores: 1, iothreads: False} | ||
- {flavor: medium, workload: generic, memsize: "4G", cores: 1, iothreads: False} | ||
- {flavor: large, workload: generic, memsize: "8G", cores: 2, iothreads: False} | ||
vars: | ||
os: opensuse | ||
icon: opensuse | ||
password: opensuse | ||
oslabels: | ||
- opensuse15.0 | ||
osinfoname: "{{ oslabels[0] }}" | ||
|
||
- name: Generate Ubuntu templates | ||
template: | ||
src: ubuntu.tpl.yaml | ||
dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" | ||
with_items: | ||
- {flavor: tiny, workload: generic, memsize: "1G", cores: 1, iothreads: False} | ||
- {flavor: small, workload: generic, memsize: "2G", cores: 1, iothreads: False} | ||
- {flavor: medium, workload: generic, memsize: "4G", cores: 1, iothreads: False} | ||
- {flavor: large, workload: generic, memsize: "8G", cores: 2, iothreads: False} | ||
vars: | ||
cpumodel: Conroe | ||
os: ubuntu | ||
icon: ubuntu | ||
password: ubuntu | ||
oslabels: | ||
- ubuntu18.04 | ||
osinfoname: "{{ oslabels[0] }}" | ||
|
||
- name: Generate Windows templates | ||
template: | ||
src: win2k12r2.tpl.yaml | ||
dest: "{{ playbook_dir }}/dist/templates/win2k12r2-{{ item.workload }}-{{ item.flavor }}.yaml" | ||
with_items: | ||
- {flavor: medium, workload: generic, memsize: "4G", cores: 1, iothreads: False} | ||
- {flavor: large, workload: generic, memsize: "8G", cores: 2, iothreads: False} | ||
vars: | ||
osinfoname: win2k12r2 | ||
|
||
|
Oops, something went wrong.