Skip to content

Commit ad64157

Browse files
committed
add vm options
1 parent 56fead8 commit ad64157

9 files changed

+706
-47
lines changed

api/v1beta1/options_types.go

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package v1beta1
2+
3+
// import "encoding/json"
4+
5+
// +kubebuilder:validation:Enum:=x86_64;aarch64
6+
type Arch string
7+
8+
// +kubebuilder:validation:Enum:=seabios;ovmf
9+
type BIOS string
10+
11+
// +kubebuilder:validation:Enum:=0;2;1024
12+
type HugePages int
13+
14+
// +kubebuilder:validation:Enum:=backup;clone;create;migrate;rollback;snapshot;snapshot-delete;suspending;suspended
15+
type Lock string
16+
17+
// +kubebuilder:validation:Enum:=other;wxp;w2k;w2k3;w2k8;wvista;win7;win8;win10;win11;l24;l26;solaris
18+
type OSType string
19+
20+
// Options
21+
type Options struct {
22+
// Enable/Disable ACPI. Defaults to true.
23+
ACPI bool `json:"acpi,omitempty"`
24+
25+
// Virtual processor architecture. Defaults to the host. x86_64 or aarch64.
26+
Arch Arch `json:"arch,omitempty"`
27+
28+
// +kubebuilder:validation:Minimum:=0
29+
// Amount of target RAM for the VM in MiB. Using zero disables the ballon driver.
30+
Balloon int `json:"balloon,omitempty"`
31+
32+
// Description for the VM. Shown in the web-interface VM's summary.
33+
// This is saved as comment inside the configuration file.
34+
Description string `json:"description,omitempty"`
35+
36+
// Script that will be executed during various steps in the vms lifetime.
37+
// HookScripts []Hookscript `json:"hookScripts,omitempty"`
38+
39+
// enable hotplug feature. list og devices.
40+
// network, disk, cpu, memory, usb. Defaults to [network, disk, usb].
41+
// HotPlug []HotPlugDevice `json:"hotPlug,omitempty"`
42+
43+
// enable/disable hugepages memory. 0 or 2 or 1024. 0 indicated 'any'
44+
HugePages HugePages `json:"hugePages,omitempty"`
45+
46+
// Use together with hugepages. If enabled, hugepages will not not be deleted
47+
// after VM shutdown and can be used for subsequent starts. Defaults to false.
48+
KeepHugePages bool `json:"keepHugePages,omitempty"`
49+
50+
// Enable/disable KVM hardware virtualization. Defaults to true.
51+
KVM bool `json:"kvm,omitempty"`
52+
53+
// Set the real time clock (RTC) to local time.
54+
// This is enabled by default if the `ostype` indicates a Microsoft Windows OS.
55+
LocalTime bool `json:"localTime,omitempty"`
56+
57+
// Lock/unlock the VM.
58+
Lock Lock `json:"lock,omitempty"`
59+
60+
// Set maximum tolerated downtime (in seconds) for migrations.
61+
// MigrateDowntime json.Number `json:"migrateDowntime,omitempty"`
62+
63+
// Set maximum speed (in MB/s) for migrations. Value 0 is no limit.
64+
// MigrateSpeed `json:"migrateSpeed,omitempty"`
65+
66+
// Enable/disable NUMA.
67+
NUMA bool `json:"numa,omitempty"`
68+
69+
// Specifies whether a VM will be started during system bootup.
70+
OnBoot bool `json:"onBoot,omitempty"`
71+
72+
// Specify guest operating system. This is used to enable special
73+
// optimization/features for specific operating systems.
74+
OSType OSType `json:"osType,omitempty"`
75+
76+
// Sets the protection flag of the VM.
77+
// This will disable the remove VM and remove disk operations.
78+
// Defaults to false.
79+
Protection bool `json:"protection,omitempty"`
80+
81+
// Allow reboot. If set to 'false' the VM exit on reboot.
82+
// Defaults to true.
83+
Reboot bool `json:"reboot,omitempty"`
84+
85+
// +kubebuilder:validation:Minimum:=0
86+
// +kubebuilder:validation:Maximum:=5000
87+
// Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets.
88+
// Number is relative to weights of all other running VMs. Using zero disables auto-ballooning.
89+
// Auto-ballooning is done by pvestatd. 0 ~ 5000. Defaults to 1000.
90+
Shares int `json:"shares,omitempty"`
91+
92+
// Set the initial date of the real time clock.
93+
// Valid format for date are:'now' or '2006-06-17T16:01:21' or '2006-06-17'.
94+
// Defaults to 'now'.
95+
// StartDate string `json:"startDate,omitempty"`
96+
97+
// StartUp string `json:"startUp,omitempty`
98+
99+
// Enable/disable the USB tablet device. This device is usually needed to allow
100+
// absolute mouse positioning with VNC. Else the mouse runs out of sync with normal VNC clients.
101+
// If you're running lots of console-only guests on one host,
102+
// you may consider disabling this to save some context switches.
103+
// This is turned off by default if you use spice (`qm set <vmid> --vga qxl`).
104+
// Defaults to true.
105+
Tablet bool `json:"tablet,omitempty"`
106+
107+
// Tags of the VM. This is only meta information.
108+
Tags []string `json:"tags,omitempty"`
109+
110+
// Enable/disable time drift fix. Defaults to false.
111+
TimeDriftFix bool `json:"timeDriftFix,omitempty"`
112+
113+
// Enable/disable Template. Defaults to false.
114+
Template bool `json:"template,omitempty"`
115+
116+
// TPMState string `json:"tpmState,omitempty"`
117+
118+
// +kubebuilder:validation:Minimum:=0
119+
// Number of hotplugged vcpus. Defaults to 0.
120+
VCPUs int `json:"vcpus,omitempty"`
121+
122+
// VGA string `json:"vga,omitempty"`
123+
124+
// The VM generation ID (vmgenid) device exposes a 128-bit integer value identifier to the guest OS.
125+
// This allows to notify the guest operating system when the virtual machine is executed with a different configuration
126+
// (e.g. snapshot execution or creation from a template).
127+
// The guest operating system notices the change, and is then able to react as appropriate by marking its copies of distributed databases as dirty,
128+
// re-initializing its random number generator, etc.
129+
// Note that auto-creation only works when done through API/CLI create or update methods, but not when manually editing the config file.
130+
// regex: (?:[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}|[01]). Defaults to 1 (autogenerated)
131+
VMGenerationID string `json:"vmGenerationID,omitempty"`
132+
133+
// Default storage for VM state volumes/files.
134+
// VMStateStorage string `json:"vmStateStorage,omitempty"`
135+
136+
// Create a virtual hardware watchdog device. Once enabled (by a guest action),
137+
// the watchdog must be periodically polled by an agent inside the guest or else
138+
// the watchdog will reset the guest (or execute the respective action specified)
139+
// WatchDog string `json:"watchDog,omitempty"`
140+
}

api/v1beta1/proxmoxcluster_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ import (
2121
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2222
)
2323

24-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
25-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
26-
2724
const (
2825
// ClusterFinalizer
2926
ClusterFinalizer = "proxmoxcluster.infrastructure.cluster.x-k8s.io"

api/v1beta1/proxmoxmachine_types.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,19 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"github.com/sp-yduck/proxmox-go/api"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2223
"sigs.k8s.io/cluster-api/errors"
2324
)
2425

25-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
26-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
27-
2826
const (
2927
// MachineFinalizer
3028
MachineFinalizer = "proxmoxmachine.infrastructure.cluster.x-k8s.io"
3129
)
3230

3331
// ProxmoxMachineSpec defines the desired state of ProxmoxMachine
3432
type ProxmoxMachineSpec struct {
35-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
36-
// Important: Run "make" to regenerate code after modifying this file
37-
3833
// ProviderID
3934
ProviderID *string `json:"providerID,omitempty"`
4035

@@ -60,9 +55,11 @@ type ProxmoxMachineSpec struct {
6055
// Network
6156
Network Network `json:"network,omitempty"`
6257

58+
// Options
59+
// +optional
60+
Options Options `json:"options,omitempty"`
61+
6362
// FailureDomain is the failure domain unique identifier this Machine should be attached to, as defined in Cluster API.
64-
// For this infrastructure provider, the ID is equivalent to an AWS Availability Zone.
65-
// If multiple subnets are matched for the availability zone, the first one returned is picked.
6663
FailureDomain *string `json:"failureDomain,omitempty"`
6764
}
6865

@@ -84,7 +81,10 @@ type ProxmoxMachineStatus struct {
8481
// Conditions
8582
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
8683

87-
// InstanceStatus is the status of the GCP instance for this machine.
84+
// Configuration
85+
Config api.VirtualMachineConfig `json:"config,omitempty"`
86+
87+
// InstanceStatus is the status of the proxmox instance for this machine.
8888
// +optional
8989
InstanceStatus *InstanceStatus `json:"instanceStatus,omitempty"` // InstanceStatus
9090
}

api/v1beta1/type.go

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,12 @@ type ServerRef struct {
2222
SecretRef *ObjectReference `json:"secretRef"`
2323
}
2424

25-
// NodeRef
26-
type NodeRef struct {
27-
Name string `json:"name"`
28-
SecretRef *ObjectReference `json:"secretRef"`
29-
}
30-
3125
// ObjectReference is a reference to another Kubernetes object instance.
3226
type ObjectReference struct {
3327
// Namespace of the referent.
3428
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
3529
Namespace string `json:"namespace,omitempty"`
30+
3631
// Name of the referent.
3732
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
3833
// +kubebuilder:validation:Required
@@ -53,15 +48,38 @@ type Image struct {
5348

5449
// Hardware
5550
type Hardware struct {
51+
// amount of RAM for the VM in MiB : 16 ~
52+
// +kubebuilder:validation:Minimum:=16
53+
// +kubebuilder:default:=4096
54+
Memory int `json:"memory,omitempty"`
55+
5656
// number of CPU cores : 1 ~
5757
// +kubebuilder:validation:Mimimum:=1
5858
// +kubebuilder:default:=2
5959
CPU int `json:"cpu,omitempty"`
6060

61-
// amount of RAM for the VM in MiB : 16 ~
62-
// +kubebuilder:validation:Minimum:=16
63-
// +kubebuilder:default:=4096
64-
Memory int `json:"memory,omitempty"`
61+
// emulated cpu type
62+
// CPUType string `json:"cpuType,omitempty"`
63+
64+
// +kubebuilder:validation:Minimum:=1
65+
// The number of CPU sockets. Defaults to 1.
66+
Sockets int `json:"sockets,omitempty"`
67+
68+
// +kubebuilder:validation:Minimum:=0
69+
// Limit of CPU usage. If the computer has 2 CPUs, it has total of '2' CPU time.
70+
// Value '0' indicates no CPU limit. Defaults to 0.
71+
CPULimit int `json:"cpuLimit,omitempty"`
72+
73+
// Select BIOS implementation. Defaults to seabios. seabios or ovmf.
74+
// Defaults to seabios.
75+
BIOS BIOS `json:"bios,omitempty"`
76+
77+
// Specifies the QEMU machine type.
78+
// regex: (pc|pc(-i440fx)?-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|q35|pc-q35-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|virt(?:-\d+(\.\d+)+)?(\+pve\d+)?)
79+
// Machine string `json:"machine,omitempty"`
80+
81+
// SCSI controller model
82+
// SCSIHardWare SCSIHardWare `json:"scsiHardWare,omitempty"`
6583

6684
// hard disk size
6785
// +kubebuilder:default:="50G"
@@ -86,10 +104,13 @@ type Network struct {
86104
type IPConfig struct {
87105
// IPv4 with CIDR
88106
IP string `json:"ip,omitempty"`
107+
89108
// gateway IPv4
90109
Gateway string `json:"gateway,omitempty"`
110+
91111
// IPv6 with CIDR
92112
IP6 string `json:"ip6,omitempty"`
113+
93114
// gateway IPv6
94115
Gateway6 string `json:"gateway6,omitempty"`
95116
}

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 15 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)