-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CNV-53430: make examples compatible with s390x arch
- Loading branch information
1 parent
6b5bc33
commit 1f9e306
Showing
4 changed files
with
275 additions
and
163 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,95 +1,147 @@ | ||
import { TemplateModel } from '@kubevirt-ui/kubevirt-api/console'; | ||
import { TemplateModel, V1Template } from '@kubevirt-ui/kubevirt-api/console'; | ||
import { isClusterOnS390X, safeDump } from '@kubevirt-utils/utils/utils'; | ||
|
||
export const defaultVMTemplateYamlTemplate = ` | ||
apiVersion: ${TemplateModel.apiGroup}/${TemplateModel.apiVersion} | ||
kind: ${TemplateModel.kind} | ||
metadata: | ||
name: example | ||
labels: | ||
template.kubevirt.io/type: vm | ||
os.template.kubevirt.io/fedora: 'true' | ||
workload.template.kubevirt.io/server: 'true' | ||
annotations: | ||
name.os.template.kubevirt.io/fedora: Fedora | ||
description: VM template example | ||
openshift.io/display-name: "Fedora VM" | ||
iconClass: icon-fedora | ||
objects: | ||
- apiVersion: kubevirt.io/v1 | ||
kind: VirtualMachine | ||
metadata: | ||
name: '\${NAME}' | ||
annotations: | ||
description: VM example | ||
labels: | ||
app: '\${NAME}' | ||
vm.kubevirt.io/template: example | ||
os.template.kubevirt.io/fedora: 'true' | ||
spec: | ||
runStrategy: Halted | ||
template: | ||
metadata: | ||
annotations: | ||
vm.kubevirt.io/flavor: small | ||
vm.kubevirt.io/os: fedora | ||
vm.kubevirt.io/workload: server | ||
labels: | ||
kubevirt.io/domain: '\${NAME}' | ||
kubevirt.io/size: small | ||
spec: | ||
domain: | ||
cpu: | ||
cores: 1 | ||
sockets: 1 | ||
threads: 1 | ||
devices: | ||
disks: | ||
- disk: | ||
bus: virtio | ||
name: rootdisk | ||
- disk: | ||
bus: virtio | ||
name: cloudinitdisk | ||
interfaces: | ||
- masquerade: {} | ||
model: virtio | ||
name: default | ||
networkInterfaceMultiqueue: true | ||
rng: {} | ||
features: | ||
acpi: {} | ||
smm: | ||
enabled: true | ||
firmware: | ||
bootloader: | ||
efi: {} | ||
machine: | ||
type: q35 | ||
memory: | ||
guest: 2Gi | ||
hostname: '\${NAME}' | ||
networks: | ||
- name: default | ||
pod: {} | ||
terminationGracePeriodSeconds: 180 | ||
volumes: | ||
- name: rootdisk | ||
containerDisk: | ||
image: 'quay.io/containerdisks/fedora' | ||
- cloudInitNoCloud: | ||
userData: |- | ||
#cloud-config | ||
user: fedora | ||
password: '\${CLOUD_USER_PASSWORD}' | ||
chpasswd: { expire: False } | ||
name: cloudinitdisk | ||
parameters: | ||
- name: NAME | ||
description: Name for the new VM | ||
generate: expression | ||
from: 'example-[a-z0-9]{16}' | ||
- name: CLOUD_USER_PASSWORD | ||
description: Randomized password for the cloud-init user | ||
generate: expression | ||
from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}' | ||
`; | ||
const defaultTemplate: V1Template = { | ||
apiVersion: `${TemplateModel.apiGroup}/${TemplateModel.apiVersion}`, | ||
kind: `${TemplateModel.kind}`, | ||
metadata: { | ||
annotations: { | ||
description: 'VM template example', | ||
iconClass: 'icon-fedora', | ||
'name.os.template.kubevirt.io/fedora': 'Fedora', | ||
'openshift.io/display-name': 'Fedora VM', | ||
}, | ||
labels: { | ||
'os.template.kubevirt.io/fedora': 'true', | ||
'template.kubevirt.io/type': 'vm', | ||
'workload.template.kubevirt.io/server': 'true', | ||
}, | ||
name: 'example', | ||
}, | ||
objects: [ | ||
{ | ||
apiVersion: 'kubevirt.io/v1', | ||
kind: 'VirtualMachine', | ||
metadata: { | ||
annotations: { | ||
description: 'VM example', | ||
}, | ||
labels: { | ||
app: '\\${NAME}', | ||
'os.template.kubevirt.io/fedora': 'true', | ||
'vm.kubevirt.io/template': 'example', | ||
}, | ||
name: '\\${NAME}', | ||
}, | ||
spec: { | ||
runStrategy: 'Halted', | ||
template: { | ||
metadata: { | ||
annotations: { | ||
'vm.kubevirt.io/flavor': 'small', | ||
'vm.kubevirt.io/os': 'fedora', | ||
'vm.kubevirt.io/workload': 'server', | ||
}, | ||
labels: { | ||
'kubevirt.io/domain': '\\${NAME}', | ||
'kubevirt.io/size': 'small', | ||
}, | ||
}, | ||
spec: { | ||
domain: { | ||
cpu: { | ||
cores: 1, | ||
sockets: 1, | ||
threads: 1, | ||
}, | ||
devices: { | ||
disks: [ | ||
{ | ||
disk: { | ||
bus: 'virtio', | ||
}, | ||
name: 'rootdisk', | ||
}, | ||
{ | ||
disk: { | ||
bus: 'virtio', | ||
}, | ||
name: 'cloudinitdisk', | ||
}, | ||
], | ||
interfaces: [ | ||
{ | ||
masquerade: {}, | ||
model: 'virtio', | ||
name: 'default', | ||
}, | ||
], | ||
networkInterfaceMultiqueue: true, | ||
rng: {}, | ||
}, | ||
|
||
...(!isClusterOnS390X && { | ||
features: { | ||
acpi: {}, | ||
smm: { | ||
enabled: true, | ||
}, | ||
}, | ||
firmware: { | ||
bootloader: { | ||
efi: {}, | ||
}, | ||
}, | ||
machine: { | ||
type: 'q35', | ||
}, | ||
}), | ||
memory: { | ||
guest: '2Gi', | ||
}, | ||
}, | ||
hostname: '\\${NAME}', | ||
networks: [ | ||
{ | ||
name: 'default', | ||
pod: {}, | ||
}, | ||
], | ||
terminationGracePeriodSeconds: 180, | ||
volumes: [ | ||
{ | ||
containerDisk: { | ||
image: 'quay.io/containerdisks/fedora', | ||
}, | ||
name: 'rootdisk', | ||
}, | ||
{ | ||
cloudInitNoCloud: { | ||
userData: | ||
"#cloud-config\nuser: fedora\npassword: '\\${CLOUD_USER_PASSWORD}'\nchpasswd: { expire: False }", | ||
}, | ||
name: 'cloudinitdisk', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
parameters: [ | ||
{ | ||
description: 'Name for the new VM', | ||
from: 'example-[a-z0-9]{16}', | ||
generate: 'expression', | ||
name: 'NAME', | ||
}, | ||
{ | ||
description: 'Randomized password for the cloud-init user', | ||
from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}', | ||
generate: 'expression', | ||
name: 'CLOUD_USER_PASSWORD', | ||
}, | ||
], | ||
}; | ||
|
||
export const defaultVMTemplateYamlTemplate = safeDump(defaultTemplate); |
Oops, something went wrong.