Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNV-53430: make examples compatible with s390x arch clusters #2328

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 146 additions & 94 deletions src/templates/vm-template-yaml.ts
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);
Loading
Loading