-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
schema.go
1041 lines (956 loc) · 36.4 KB
/
schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of the KubeVirt project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2017, 2018 Red Hat, Inc.
*
*/
package v1
import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/types"
)
type IOThreadsPolicy string
const (
IOThreadsPolicyShared IOThreadsPolicy = "shared"
IOThreadsPolicyAuto IOThreadsPolicy = "auto"
CPUModeHostPassthrough = "host-passthrough"
CPUModeHostModel = "host-model"
)
//go:generate swagger-doc
//go:generate openapi-gen -i . --output-package=kubevirt.io/kubevirt/pkg/api/v1 --go-header-file ../../../hack/boilerplate/boilerplate.go.txt
/*
ATTENTION: Rerun code generators when comments on structs or fields are modified.
*/
// Represents a disk created on the cluster level
// ---
// +k8s:openapi-gen=true
type HostDisk struct {
// The path to HostDisk image located on the cluster
Path string `json:"path"`
// Contains information if disk.img exists or should be created
// allowed options are 'Disk' and 'DiskOrCreate'
Type HostDiskType `json:"type"`
// Capacity of the sparse disk
// +optional
Capacity resource.Quantity `json:"capacity,omitempty"`
// Shared indicate whether the path is shared between nodes
Shared *bool `json:"shared,omitempty"`
}
// ConfigMapVolumeSource adapts a ConfigMap into a volume.
// More info: https://kubernetes.io/docs/concepts/storage/volumes/#configmap
// ---
// +k8s:openapi-gen=true
type ConfigMapVolumeSource struct {
v1.LocalObjectReference `json:",inline"`
// Specify whether the ConfigMap or it's keys must be defined
// +optional
Optional *bool `json:"optional,omitempty"`
}
// SecretVolumeSource adapts a Secret into a volume.
// ---
// +k8s:openapi-gen=true
type SecretVolumeSource struct {
// Name of the secret in the pod's namespace to use.
// More info: https://kubernetes.io/docs/concepts/storage/volumes#secret
// +optional
SecretName string `json:"secretName,omitempty"`
// Specify whether the Secret or it's keys must be defined
// +optional
Optional *bool `json:"optional,omitempty"`
}
// ServiceAccountVolumeSource adapts a ServiceAccount into a volume.
// ---
// +k8s:openapi-gen=true
type ServiceAccountVolumeSource struct {
// Name of the service account in the pod's namespace to use.
// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}
// Represents a cloud-init nocloud user data source.
// More info: http://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
// ---
// +k8s:openapi-gen=true
type CloudInitNoCloudSource struct {
// UserDataSecretRef references a k8s secret that contains NoCloud userdata.
// + optional
UserDataSecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
// UserDataBase64 contains NoCloud cloud-init userdata as a base64 encoded string.
// + optional
UserDataBase64 string `json:"userDataBase64,omitempty"`
// UserData contains NoCloud inline cloud-init userdata.
// + optional
UserData string `json:"userData,omitempty"`
// NetworkDataSecretRef references a k8s secret that contains NoCloud networkdata.
// + optional
NetworkDataSecretRef *v1.LocalObjectReference `json:"networkDataSecretRef,omitempty"`
// NetworkDataBase64 contains NoCloud cloud-init networkdata as a base64 encoded string.
// + optional
NetworkDataBase64 string `json:"networkDataBase64,omitempty"`
// NetworkData contains NoCloud inline cloud-init networkdata.
// + optional
NetworkData string `json:"networkData,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type DomainSpec struct {
// Resources describes the Compute Resources required by this vmi.
Resources ResourceRequirements `json:"resources,omitempty"`
// CPU allow specified the detailed CPU topology inside the vmi.
// +optional
CPU *CPU `json:"cpu,omitempty"`
// Memory allow specifying the VMI memory features.
// +optional
Memory *Memory `json:"memory,omitempty"`
// Machine type.
// +optional
Machine Machine `json:"machine,omitempty"`
// Firmware.
// +optional
Firmware *Firmware `json:"firmware,omitempty"`
// Clock sets the clock and timers of the vmi.
// +optional
Clock *Clock `json:"clock,omitempty"`
// Features like acpi, apic, hyperv, smm.
// +optional
Features *Features `json:"features,omitempty"`
// Devices allows adding disks, network interfaces, ...
Devices Devices `json:"devices"`
// Controls whether or not disks will share IOThreads.
// Omitting IOThreadsPolicy disables use of IOThreads.
// One of: shared, auto
// +optional
IOThreadsPolicy *IOThreadsPolicy `json:"ioThreadsPolicy,omitempty"`
}
// Represents the firmware blob used to assist in the domain creation process.
// Used for setting the QEMU BIOS file path for the libvirt domain.
// ---
// +k8s:openapi-gen=true
type Bootloader struct {
// If set (default), BIOS will be used.
// +optional
BIOS *BIOS `json:"bios,omitempty"`
// If set, EFI will be used instead of BIOS.
// +optional
EFI *EFI `json:"efi,omitempty"`
}
// If set (default), BIOS will be used.
// ---
// +k8s:openapi-gen=true
type BIOS struct {
}
// If set, EFI will be used instead of BIOS.
// ---
// +k8s:openapi-gen=true
type EFI struct {
}
// ---
// +k8s:openapi-gen=true
type ResourceRequirements struct {
// Requests is a description of the initial vmi resources.
// Valid resource keys are "memory" and "cpu".
// +optional
Requests v1.ResourceList `json:"requests,omitempty"`
// Limits describes the maximum amount of compute resources allowed.
// Valid resource keys are "memory" and "cpu".
// +optional
Limits v1.ResourceList `json:"limits,omitempty"`
// Don't ask the scheduler to take the guest-management overhead into account. Instead
// put the overhead only into the requested memory limits. This can lead to crashes if
// all memory is in use on a node. Defaults to false.
OvercommitGuestOverhead bool `json:"overcommitGuestOverhead,omitempty"`
}
// CPU allows specifying the CPU topology.
// ---
// +k8s:openapi-gen=true
type CPU struct {
// Cores specifies the number of cores inside the vmi.
// Must be a value greater or equal 1.
Cores uint32 `json:"cores,omitempty"`
// Sockets specifies the number of sockets inside the vmi.
// Must be a value greater or equal 1.
Sockets uint32 `json:"sockets,omitempty"`
// Threads specifies the number of threads inside the vmi.
// Must be a value greater or equal 1.
Threads uint32 `json:"threads,omitempty"`
// Model specifies the CPU model inside the VMI.
// List of available models https://github.com/libvirt/libvirt/blob/master/src/cpu/cpu_map.xml.
// It is possible to specify special cases like "host-passthrough" to get the same CPU as the node
// and "host-model" to get CPU closest to the node one.
// Defaults to host-model.
// +optional
Model string `json:"model,omitempty"`
// Features specifies the CPU features list inside the VMI.
// +optional
Features []CPUFeature `json:"features,omitempty"`
// DedicatedCPUPlacement requests the scheduler to place the VirtualMachineInstance on a node
// with enough dedicated pCPUs and pin the vCPUs to it.
// +optional
DedicatedCPUPlacement bool `json:"dedicatedCpuPlacement,omitempty"`
}
// CPUFeature allows specifying a CPU feature.
// ---
// +k8s:openapi-gen=true
type CPUFeature struct {
// Name of the CPU feature
Name string `json:"name"`
// Policy is the CPU feature attribute which can have the following attributes:
// force - The virtual CPU will claim the feature is supported regardless of it being supported by host CPU.
// require - Guest creation will fail unless the feature is supported by the host CPU or the hypervisor is able to emulate it.
// optional - The feature will be supported by virtual CPU if and only if it is supported by host CPU.
// disable - The feature will not be supported by virtual CPU.
// forbid - Guest creation will fail if the feature is supported by host CPU.
// Defaults to require
// +optional
Policy string `json:"policy,omitempty"`
}
// Memory allows specifying the VirtualMachineInstance memory features.
// ---
// +k8s:openapi-gen=true
type Memory struct {
// Hugepages allow to use hugepages for the VirtualMachineInstance instead of regular memory.
// +optional
Hugepages *Hugepages `json:"hugepages,omitempty"`
// Guest allows to specifying the amount of memory which is visible inside the Guest OS.
// The Guest must lie between Requests and Limits from the resources section.
// Defaults to the requested memory in the resources section if not specified.
// + optional
Guest *resource.Quantity `json:"guest,omitempty"`
}
// Hugepages allow to use hugepages for the VirtualMachineInstance instead of regular memory.
// ---
// +k8s:openapi-gen=true
type Hugepages struct {
// PageSize specifies the hugepage size, for x86_64 architecture valid values are 1Gi and 2Mi.
PageSize string `json:"pageSize,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type Machine struct {
// QEMU machine type is the actual chipset of the VirtualMachineInstance.
Type string `json:"type"`
}
// ---
// +k8s:openapi-gen=true
type Firmware struct {
// UUID reported by the vmi bios.
// Defaults to a random generated uid.
UUID types.UID `json:"uuid,omitempty"`
// Settings to control the bootloader that is used.
// +optional
Bootloader *Bootloader `json:"bootloader,omitempty"`
// The system-serial-number in SMBIOS
Serial string `json:"serial,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type Devices struct {
// Disks describes disks, cdroms, floppy and luns which are connected to the vmi.
Disks []Disk `json:"disks,omitempty"`
// Watchdog describes a watchdog device which can be added to the vmi.
Watchdog *Watchdog `json:"watchdog,omitempty"`
// Interfaces describe network interfaces which are added to the vmi.
Interfaces []Interface `json:"interfaces,omitempty"`
// Inputs describe input devices
Inputs []Input `json:"inputs,omitempty"`
// Whether to attach a pod network interface. Defaults to true.
AutoattachPodInterface *bool `json:"autoattachPodInterface,omitempty"`
// Whether to attach the default graphics device or not.
// VNC will not be available if set to false. Defaults to true.
AutoattachGraphicsDevice *bool `json:"autoattachGraphicsDevice,omitempty"`
// Whether to have random number generator from host
// +optional
Rng *Rng `json:"rng,omitempty"`
// Whether or not to enable virtio multi-queue for block devices
// +optional
BlockMultiQueue *bool `json:"blockMultiQueue,omitempty"`
// If specified, virtual network interfaces configured with a virtio bus will also enable the vhost multiqueue feature
// +optional
NetworkInterfaceMultiQueue *bool `json:"networkInterfaceMultiqueue,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type Input struct {
// Bus indicates the bus of input device to emulate.
// Supported values: virtio, usb.
Bus string `json:"bus,omitempty"`
// Type indicated the type of input device.
// Supported values: tablet.
Type string `json:"type"`
// Name is the device name
Name string `json:"name"`
}
// ---
// +k8s:openapi-gen=true
type Disk struct {
// Name is the device name
Name string `json:"name"`
// DiskDevice specifies as which device the disk should be added to the guest.
// Defaults to Disk.
DiskDevice `json:",inline"`
// BootOrder is an integer value > 0, used to determine ordering of boot devices.
// Lower values take precedence.
// Each disk or interface that has a boot order must have a unique value.
// Disks without a boot order are not tried if a disk with a boot order exists.
// +optional
BootOrder *uint `json:"bootOrder,omitempty"`
// Serial provides the ability to specify a serial number for the disk device.
// +optional
Serial string `json:"serial,omitempty"`
// dedicatedIOThread indicates this disk should have an exclusive IO Thread.
// Enabling this implies useIOThreads = true.
// Defaults to false.
// +optional
DedicatedIOThread *bool `json:"dedicatedIOThread,omitempty"`
// Cache specifies which kvm disk cache mode should be used.
// +optional
Cache DriverCache `json:"cache,omitempty"`
}
// Represents the target of a volume to mount.
// Only one of its members may be specified.
// ---
// +k8s:openapi-gen=true
type DiskDevice struct {
// Attach a volume as a disk to the vmi.
Disk *DiskTarget `json:"disk,omitempty"`
// Attach a volume as a LUN to the vmi.
LUN *LunTarget `json:"lun,omitempty"`
// Attach a volume as a floppy to the vmi.
Floppy *FloppyTarget `json:"floppy,omitempty"`
// Attach a volume as a cdrom to the vmi.
CDRom *CDRomTarget `json:"cdrom,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type DiskTarget struct {
// Bus indicates the type of disk device to emulate.
// supported values: virtio, sata, scsi.
Bus string `json:"bus,omitempty"`
// ReadOnly.
// Defaults to false.
ReadOnly bool `json:"readonly,omitempty"`
// If specified, the virtual disk will be placed on the guests pci address with the specifed PCI address. For example: 0000:81:01.10
// +optional
PciAddress string `json:"pciAddress,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type LunTarget struct {
// Bus indicates the type of disk device to emulate.
// supported values: virtio, sata, scsi.
Bus string `json:"bus,omitempty"`
// ReadOnly.
// Defaults to false.
ReadOnly bool `json:"readonly,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type FloppyTarget struct {
// ReadOnly.
// Defaults to false.
ReadOnly bool `json:"readonly,omitempty"`
// Tray indicates if the tray of the device is open or closed.
// Allowed values are "open" and "closed".
// Defaults to closed.
// +optional
Tray TrayState `json:"tray,omitempty"`
}
// TrayState indicates if a tray of a cdrom or floppy is open or closed.
// ---
// +k8s:openapi-gen=true
type TrayState string
const (
// TrayStateOpen indicates that the tray of a cdrom or floppy is open.
TrayStateOpen TrayState = "open"
// TrayStateClosed indicates that the tray of a cdrom or floppy is closed.
TrayStateClosed TrayState = "closed"
)
// ---
// +k8s:openapi-gen=true
type CDRomTarget struct {
// Bus indicates the type of disk device to emulate.
// supported values: virtio, sata, scsi.
Bus string `json:"bus,omitempty"`
// ReadOnly.
// Defaults to true.
ReadOnly *bool `json:"readonly,omitempty"`
// Tray indicates if the tray of the device is open or closed.
// Allowed values are "open" and "closed".
// Defaults to closed.
// +optional
Tray TrayState `json:"tray,omitempty"`
}
// Volume represents a named volume in a vmi.
// ---
// +k8s:openapi-gen=true
type Volume struct {
// Volume's name.
// Must be a DNS_LABEL and unique within the vmi.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
Name string `json:"name"`
// VolumeSource represents the location and type of the mounted volume.
// Defaults to Disk, if no type is specified.
VolumeSource `json:",inline"`
}
// Represents the source of a volume to mount.
// Only one of its members may be specified.
// ---
// +k8s:openapi-gen=true
type VolumeSource struct {
// HostDisk represents a disk created on the cluster level
// +optional
HostDisk *HostDisk `json:"hostDisk,omitempty"`
// PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace.
// Directly attached to the vmi via qemu.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
// +optional
PersistentVolumeClaim *v1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty"`
// CloudInitNoCloud represents a cloud-init NoCloud user-data source.
// The NoCloud data will be added as a disk to the vmi. A proper cloud-init installation is required inside the guest.
// More info: http://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
// +optional
CloudInitNoCloud *CloudInitNoCloudSource `json:"cloudInitNoCloud,omitempty"`
// ContainerDisk references a docker image, embedding a qcow or raw disk.
// More info: https://kubevirt.gitbooks.io/user-guide/registry-disk.html
// +optional
ContainerDisk *ContainerDiskSource `json:"containerDisk,omitempty"`
// Ephemeral is a special volume source that "wraps" specified source and provides copy-on-write image on top of it.
// +optional
Ephemeral *EphemeralVolumeSource `json:"ephemeral,omitempty"`
// EmptyDisk represents a temporary disk which shares the vmis lifecycle.
// More info: https://kubevirt.gitbooks.io/user-guide/disks-and-volumes.html
// +optional
EmptyDisk *EmptyDiskSource `json:"emptyDisk,omitempty"`
// DataVolume represents the dynamic creation a PVC for this volume as well as
// the process of populating that PVC with a disk image.
// +optional
DataVolume *DataVolumeSource `json:"dataVolume,omitempty"`
// ConfigMapSource represents a reference to a ConfigMap in the same namespace.
// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
// +optional
ConfigMap *ConfigMapVolumeSource `json:"configMap,omitempty"`
// SecretVolumeSource represents a reference to a secret data in the same namespace.
// More info: https://kubernetes.io/docs/concepts/configuration/secret/
// +optional
Secret *SecretVolumeSource `json:"secret,omitempty"`
// ServiceAccountVolumeSource represents a reference to a service account.
// There can only be one volume of this type!
// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
// +optional
ServiceAccount *ServiceAccountVolumeSource `json:"serviceAccount,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type DataVolumeSource struct {
// Name represents the name of the DataVolume in the same namespace
Name string `json:"name"`
}
// ---
// +k8s:openapi-gen=true
type EphemeralVolumeSource struct {
// PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace.
// Directly attached to the vmi via qemu.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
// +optional
PersistentVolumeClaim *v1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty"`
}
// EmptyDisk represents a temporary disk which shares the vmis lifecycle.
// ---
// +k8s:openapi-gen=true
type EmptyDiskSource struct {
// Capacity of the sparse disk.
Capacity resource.Quantity `json:"capacity"`
}
// Represents a docker image with an embedded disk.
// ---
// +k8s:openapi-gen=true
type ContainerDiskSource struct {
// Image is the name of the image with the embedded disk.
Image string `json:"image"`
// ImagePullSecret is the name of the Docker registry secret required to pull the image. The secret must already exist.
ImagePullSecret string `json:"imagePullSecret,omitempty"`
// Path defines the path to disk file in the container
Path string `json:"path,omitempty"`
}
// Exactly one of its members must be set.
// ---
// +k8s:openapi-gen=true
type ClockOffset struct {
// UTC sets the guest clock to UTC on each boot. If an offset is specified,
// guest changes to the clock will be kept during reboots and are not reset.
UTC *ClockOffsetUTC `json:"utc,omitempty"`
// Timezone sets the guest clock to the specified timezone.
// Zone name follows the TZ environment variable format (e.g. 'America/New_York').
Timezone *ClockOffsetTimezone `json:"timezone,omitempty"`
}
// UTC sets the guest clock to UTC on each boot.
// ---
// +k8s:openapi-gen=true
type ClockOffsetUTC struct {
// OffsetSeconds specifies an offset in seconds, relative to UTC. If set,
// guest changes to the clock will be kept during reboots and not reset.
OffsetSeconds *int `json:"offsetSeconds,omitempty"`
}
// ClockOffsetTimezone sets the guest clock to the specified timezone.
// Zone name follows the TZ environment variable format (e.g. 'America/New_York').
// ---
// +k8s:openapi-gen=true
type ClockOffsetTimezone string
// Represents the clock and timers of a vmi.
// ---
// +k8s:openapi-gen=true
type Clock struct {
// ClockOffset allows specifying the UTC offset or the timezone of the guest clock.
ClockOffset `json:",inline"`
// Timer specifies whih timers are attached to the vmi.
Timer *Timer `json:"timer,inline"`
}
// Represents all available timers in a vmi.
// ---
// +k8s:openapi-gen=true
type Timer struct {
// HPET (High Precision Event Timer) - multiple timers with periodic interrupts.
HPET *HPETTimer `json:"hpet,omitempty"`
// KVM (KVM clock) - lets guests read the host’s wall clock time (paravirtualized). For linux guests.
KVM *KVMTimer `json:"kvm,omitempty"`
// PIT (Programmable Interval Timer) - a timer with periodic interrupts.
PIT *PITTimer `json:"pit,omitempty"`
// RTC (Real Time Clock) - a continuously running timer with periodic interrupts.
RTC *RTCTimer `json:"rtc,omitempty"`
// Hyperv (Hypervclock) - lets guests read the host’s wall clock time (paravirtualized). For windows guests.
Hyperv *HypervTimer `json:"hyperv,omitempty"`
}
// HPETTickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
// ---
// +k8s:openapi-gen=true
type HPETTickPolicy string
// PITTickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
// ---
// +k8s:openapi-gen=true
type PITTickPolicy string
// RTCTickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
// ---
// +k8s:openapi-gen=true
type RTCTickPolicy string
const (
// HPETTickPolicyDelay delivers ticks at a constant rate. The guest time will
// be delayed due to the late tick
HPETTickPolicyDelay HPETTickPolicy = "delay"
// HPETTickPolicyCatchup Delivers ticks at a higher rate to catch up with the
// missed tick. The guest time should not be delayed once catchup is complete
HPETTickPolicyCatchup HPETTickPolicy = "catchup"
// HPETTickPolicyMerge merges the missed tick(s) into one tick and inject. The
// guest time may be delayed, depending on how the OS reacts to the merging
// of ticks.
HPETTickPolicyMerge HPETTickPolicy = "merge"
// HPETTickPolicyDiscard discards all missed ticks.
HPETTickPolicyDiscard HPETTickPolicy = "discard"
// PITTickPolicyDelay delivers ticks at a constant rate. The guest time will
// be delayed due to the late tick.
PITTickPolicyDelay PITTickPolicy = "delay"
// PITTickPolicyCatchup Delivers ticks at a higher rate to catch up with the
// missed tick. The guest time should not be delayed once catchup is complete.
PITTickPolicyCatchup PITTickPolicy = "catchup"
// PITTickPolicyDiscard discards all missed ticks.
PITTickPolicyDiscard PITTickPolicy = "discard"
// RTCTickPolicyDelay delivers ticks at a constant rate. The guest time will
// be delayed due to the late tick.
RTCTickPolicyDelay RTCTickPolicy = "delay"
// RTCTickPolicyCatchup Delivers ticks at a higher rate to catch up with the
// missed tick. The guest time should not be delayed once catchup is complete.
RTCTickPolicyCatchup RTCTickPolicy = "catchup"
)
// RTCTimerTrack specifies from which source to track the time.
// ---
// +k8s:openapi-gen=true
type RTCTimerTrack string
const (
// TrackGuest tracks the guest time.
TrackGuest RTCTimerTrack = "guest"
// TrackWall tracks the host time.
TrackWall RTCTimerTrack = "wall"
)
// ---
// +k8s:openapi-gen=true
type RTCTimer struct {
// TickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
// One of "delay", "catchup".
TickPolicy RTCTickPolicy `json:"tickPolicy,omitempty"`
// Enabled set to false makes sure that the machine type or a preset can't add the timer.
// Defaults to true.
// +optional
Enabled *bool `json:"present,omitempty"`
// Track the guest or the wall clock.
Track RTCTimerTrack `json:"track,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type HPETTimer struct {
// TickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
// One of "delay", "catchup", "merge", "discard".
TickPolicy HPETTickPolicy `json:"tickPolicy,omitempty"`
// Enabled set to false makes sure that the machine type or a preset can't add the timer.
// Defaults to true.
// +optional
Enabled *bool `json:"present,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type PITTimer struct {
// TickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
// One of "delay", "catchup", "discard".
TickPolicy PITTickPolicy `json:"tickPolicy,omitempty"`
// Enabled set to false makes sure that the machine type or a preset can't add the timer.
// Defaults to true.
// +optional
Enabled *bool `json:"present,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type KVMTimer struct {
// Enabled set to false makes sure that the machine type or a preset can't add the timer.
// Defaults to true.
// +optional
Enabled *bool `json:"present,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type HypervTimer struct {
// Enabled set to false makes sure that the machine type or a preset can't add the timer.
// Defaults to true.
// +optional
Enabled *bool `json:"present,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type Features struct {
// ACPI enables/disables ACPI insidejsondata guest.
// Defaults to enabled.
// +optional
ACPI FeatureState `json:"acpi,omitempty"`
// Defaults to the machine type setting.
// +optional
APIC *FeatureAPIC `json:"apic,omitempty"`
// Defaults to the machine type setting.
// +optional
Hyperv *FeatureHyperv `json:"hyperv,omitempty"`
// SMM enables/disables System Management Mode.
// TSEG not yet implemented.
// +optional
SMM *FeatureState `json:"smm,omitempty"`
}
// Represents if a feature is enabled or disabled.
// ---
// +k8s:openapi-gen=true
type FeatureState struct {
// Enabled determines if the feature should be enabled or disabled on the guest.
// Defaults to true.
// +optional
Enabled *bool `json:"enabled,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type FeatureAPIC struct {
// Enabled determines if the feature should be enabled or disabled on the guest.
// Defaults to true.
// +optional
Enabled *bool `json:"enabled,omitempty"`
// EndOfInterrupt enables the end of interrupt notification in the guest.
// Defaults to false.
// +optional
EndOfInterrupt bool `json:"endOfInterrupt,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type FeatureSpinlocks struct {
// Enabled determines if the feature should be enabled or disabled on the guest.
// Defaults to true.
// +optional
Enabled *bool `json:"enabled,omitempty"`
// Retries indicates the number of retries.
// Must be a value greater or equal 4096.
// Defaults to 4096.
// +optional
Retries *uint32 `json:"spinlocks,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type FeatureVendorID struct {
// Enabled determines if the feature should be enabled or disabled on the guest.
// Defaults to true.
// +optional
Enabled *bool `json:"enabled,omitempty"`
// VendorID sets the hypervisor vendor id, visible to the vmi.
// String up to twelve characters.
VendorID string `json:"vendorid,omitempty"`
}
// Hyperv specific features.
// ---
// +k8s:openapi-gen=true
type FeatureHyperv struct {
// Relaxed relaxes constraints on timer.
// Defaults to the machine type setting.
// +optional
Relaxed *FeatureState `json:"relaxed,omitempty"`
// VAPIC indicates whether virtual APIC is enabled.
// Defaults to the machine type setting.
// +optional
VAPIC *FeatureState `json:"vapic,omitempty"`
// Spinlocks indicates if spinlocks should be made available to the guest.
// +optional
Spinlocks *FeatureSpinlocks `json:"spinlocks,omitempty"`
// VPIndex enables the Virtual Processor Index to help windows identifying virtual processors.
// Defaults to the machine type setting.
// +optional
VPIndex *FeatureState `json:"vpindex,omitempty"`
// Runtime.
// Defaults to the machine type setting.
// +optional
Runtime *FeatureState `json:"runtime,omitempty"`
// SyNIC enable Synthetic Interrupt Controller.
// Defaults to the machine type setting.
// +optional
SyNIC *FeatureState `json:"synic,omitempty"`
// SyNICTimer enable Synthetic Interrupt Controller timer.
// Defaults to the machine type setting.
// +optional
SyNICTimer *FeatureState `json:"synictimer,omitempty"`
// Reset enables Hyperv reboot/reset for the vmi. Requires synic.
// Defaults to the machine type setting.
// +optional
Reset *FeatureState `json:"reset,omitempty"`
// VendorID allows setting the hypervisor vendor id.
// Defaults to the machine type setting.
// +optional
VendorID *FeatureVendorID `json:"vendorid,omitempty"`
// Frequencies improve Hyper-V on KVM (TSC clock source).
// Defaults to the machine type setting.
// +optional
Frequencies *FeatureState `json:"frequencies,omitempty"`
// Reenlightenment improve Hyper-V on KVM (TSC clock source).
// Defaults to the machine type setting.
// +optional
Reenlightenment *FeatureState `json:"reenlightenment,omitempty"`
// TLBFlush improves performances in overcommited environments. Requires vpindex.
// Defaults to the machine type setting.
// +optional
TLBFlush *FeatureState `json:"tlbflush,omitempty"`
// IPI improves performances in overcommited environments. Requires vpindex.
// Defaults to the machine type setting.
// +optional
IPI *FeatureState `json:"ipi,omitempty"`
// EVMCS Speeds up L2 vmexits, but disables other virtualization features. Requires vapic.
// Defaults to the machine type setting.
// +optional
EVMCS *FeatureState `json:"evmcs,omitempty"`
}
// WatchdogAction defines the watchdog action, if a watchdog gets triggered.
// ---
// +k8s:openapi-gen=true
type WatchdogAction string
const (
// WatchdogActionPoweroff will poweroff the vmi if the watchdog gets triggered.
WatchdogActionPoweroff WatchdogAction = "poweroff"
// WatchdogActionReset will reset the vmi if the watchdog gets triggered.
WatchdogActionReset WatchdogAction = "reset"
// WatchdogActionShutdown will shutdown the vmi if the watchdog gets triggered.
WatchdogActionShutdown WatchdogAction = "shutdown"
)
// Named watchdog device.
// ---
// +k8s:openapi-gen=true
type Watchdog struct {
// Name of the watchdog.
Name string `json:"name"`
// WatchdogDevice contains the watchdog type and actions.
// Defaults to i6300esb.
WatchdogDevice `json:",inline"`
}
// Hardware watchdog device.
// Exactly one of its members must be set.
// ---
// +k8s:openapi-gen=true
type WatchdogDevice struct {
// i6300esb watchdog device.
// +optional
I6300ESB *I6300ESBWatchdog `json:"i6300esb,omitempty"`
}
// i6300esb watchdog device.
// ---
// +k8s:openapi-gen=true
type I6300ESBWatchdog struct {
// The action to take. Valid values are poweroff, reset, shutdown.
// Defaults to reset.
Action WatchdogAction `json:"action,omitempty"`
}
// TODO ballooning, rng, cpu ...
func NewMinimalDomainSpec() DomainSpec {
domain := DomainSpec{}
domain.Resources.Requests = v1.ResourceList{
v1.ResourceMemory: resource.MustParse("8192Ki"),
}
return domain
}
// ---
// +k8s:openapi-gen=true
type Interface struct {
// Logical name of the interface as well as a reference to the associated networks.
// Must match the Name of a Network.
Name string `json:"name"`
// Interface model.
// One of: e1000, e1000e, ne2k_pci, pcnet, rtl8139, virtio.
// Defaults to virtio.
// TODO:(ihar) switch to enums once opengen-api supports them. See: https://github.com/kubernetes/kube-openapi/issues/51
Model string `json:"model,omitempty"`
// BindingMethod specifies the method which will be used to connect the interface to the guest.
// Defaults to Bridge.
InterfaceBindingMethod `json:",inline"`
// List of ports to be forwarded to the virtual machine.
Ports []Port `json:"ports,omitempty"`
// Interface MAC address. For example: de:ad:00:00:be:af or DE-AD-00-00-BE-AF.
MacAddress string `json:"macAddress,omitempty"`
// BootOrder is an integer value > 0, used to determine ordering of boot devices.
// Lower values take precedence.
// Each interface or disk that has a boot order must have a unique value.
// Interfaces without a boot order are not tried.
// +optional
BootOrder *uint `json:"bootOrder,omitempty"`
// If specified, the virtual network interface will be placed on the guests pci address with the specifed PCI address. For example: 0000:81:01.10
// +optional
PciAddress string `json:"pciAddress,omitempty"`
// If specified the network interface will pass additional DHCP options to the VMI
// +optional
DHCPOptions *DHCPOptions `json:"dhcpOptions,omitempty"`
}
// Extra DHCP options to use in the interface.
// ---
// +k8s:openapi-gen=true
type DHCPOptions struct {
// If specified will pass option 67 to interface's DHCP server
// +optional
BootFileName string `json:"bootFileName,omitempty"`
// If specified will pass option 66 to interface's DHCP server
// +optional
TFTPServerName string `json:"tftpServerName,omitempty"`
// If specified will pass the configured NTP server to the VM via DHCP option 042.
// +optional
NTPServers []string `json:"ntpServers,omitempty"`
// If specified will pass extra DHCP options for private use, range: 224-254
// +optional
PrivateOptions []DHCPPrivateOptions `json:"privateOptions,omitempty"`
}
// DHCPExtraOptions defines Extra DHCP options for a VM.
type DHCPPrivateOptions struct {
// Option is an Integer value from 224-254
// Required.
Option int `json:"option"`
// Value is a String value for the Option provided
// Required.
Value string `json:"value"`
}
// Represents the method which will be used to connect the interface to the guest.
// Only one of its members may be specified.
// ---
// +k8s:openapi-gen=true
type InterfaceBindingMethod struct {
Bridge *InterfaceBridge `json:"bridge,omitempty"`
Slirp *InterfaceSlirp `json:"slirp,omitempty"`
Masquerade *InterfaceMasquerade `json:"masquerade,omitempty"`
SRIOV *InterfaceSRIOV `json:"sriov,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type InterfaceBridge struct{}
// ---
// +k8s:openapi-gen=true
type InterfaceSlirp struct{}
// ---
// +k8s:openapi-gen=true
type InterfaceMasquerade struct{}
// ---
// +k8s:openapi-gen=true
type InterfaceSRIOV struct{}
// Port repesents a port to expose from the virtual machine.
// Default protocol TCP.
// The port field is mandatory
// ---
// +k8s:openapi-gen=true
type Port struct {
// If specified, this must be an IANA_SVC_NAME and unique within the pod. Each
// named port in a pod must have a unique name. Name for the port that can be
// referred to by services.
// +optional
Name string `json:"name,omitempty"`
// Protocol for port. Must be UDP or TCP.
// Defaults to "TCP".
// +optional
Protocol string `json:"protocol,omitempty"`
// Number of port to expose for the virtual machine.
// This must be a valid port number, 0 < x < 65536.
Port int32 `json:"port"`
}
// Network represents a network type and a resource that should be connected to the vm.
// ---
// +k8s:openapi-gen=true
type Network struct {
// Network name.
// Must be a DNS_LABEL and unique within the vm.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
Name string `json:"name"`
// NetworkSource represents the network type and the source interface that should be connected to the virtual machine.
// Defaults to Pod, if no type is specified.
NetworkSource `json:",inline"`
}
// Represents the source resource that will be connected to the vm.
// Only one of its members may be specified.
// ---
// +k8s:openapi-gen=true
type NetworkSource struct {