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

Towards Beta #95

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 14 additions & 1 deletion api/v1beta1/proxmoxcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (

const (
// ClusterFinalizer
ClusterFinalizer = "proxmoxcluster.infrastructure.cluster.x-k8s.io"
ClusterFinalizer = "proxmoxcluster.infrastructure.cluster.x-k8s.io"
ClusterSecretFinalizer = ClusterFinalizer + "/secret"
)

// ProxmoxClusterSpec defines the desired state of ProxmoxCluster
Expand All @@ -38,6 +39,18 @@ type ProxmoxClusterSpec struct {
// storage is for proxmox storage used by vm instances
// +optional
Storage Storage `json:"storage"`

// Nodes to be used for vm instances
// +optional
Nodes []string `json:"nodes,omitempty"`

// Provide config to enable failure domains
// +optional
FailureDomainConfig *ClusterFailureDomainConfig `json:"failureDomain,omitempty"`

// Proxmox resource pool to be used for all vms created
// +optional
ResourcePool string `json:"resourcePool,omitempty"`
}

// ProxmoxClusterStatus defines the observed state of ProxmoxCluster
Expand Down
12 changes: 9 additions & 3 deletions api/v1beta1/proxmoxmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (

const (
// MachineFinalizer
MachineFinalizer = "proxmoxmachine.infrastructure.cluster.x-k8s.io"
MachineFinalizer = "proxmoxmachine.infrastructure.cluster.x-k8s.io"
MachineFinalizerIPAddressClaim = "proxmoxmachine.infrastructure.cluster.x-k8s.io/IPAddressClaim"
)

// ProxmoxMachineSpec defines the desired state of ProxmoxMachine
Expand All @@ -35,13 +36,17 @@ type ProxmoxMachineSpec struct {

// Node is proxmox node hosting vm instance which used for ProxmoxMachine
// +optional
Node string `json:"node,omitempty"`
Node *string `json:"node,omitempty"`

// +kubebuilder:validation:Minimum:=0
// VMID is proxmox qemu's id
// +optional
VMID *int `json:"vmID,omitempty"`

// Pool the vm is attached to
// +optional
Pool *string `json:"pool,omitempty"`

// Image is the image to be provisioned
Image Image `json:"image"`

Expand Down Expand Up @@ -94,7 +99,8 @@ type ProxmoxMachineStatus struct {
//+kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this VSphereMachine belongs"
// +kubebuilder:printcolumn:name="Machine",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Machine\")].name",description="Machine object which owns with this ProxmoxMachine",priority=1
// +kubebuilder:printcolumn:name="vmid",type=string,JSONPath=`.spec.vmID`,priority=1
// +kubebuilder:printcolumn:name="VmID",type=string,JSONPath=`.spec.vmID`,priority=1
// +kubebuilder:printcolumn:name="Node",type=string,JSONPath=`.spec.node`,priority=2
// +kubebuilder:printcolumn:name="ProviderID",type=string,JSONPath=`.spec.providerID`
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.instanceStatus`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Machine"
Expand Down
51 changes: 43 additions & 8 deletions api/v1beta1/proxmoxmachinetemplate_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 Teppei Sudo.
Copyright 2023 Simplysoft GmbH.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,18 +21,53 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ProxmoxMachineTemplateSpec defines the desired state of ProxmoxMachineTemplate
type ProxmoxMachineTemplateSpec struct {
Template ProxmoxMachineTemplateResource `json:"template"`
Template ProxmoxMachineTemplateSpecTemplate `json:"template"`

// VM ID Range that will be used for individual machines
// +optional
VMIDs *ProxmoxMachineTemplateVmIdRange `json:"vmIDs,omitempty"`

// Restrict template to specific proxmox nodes. When failure domains are enabled, they will have
// priority the configured nodes in the template
// +optional
Nodes []string `json:"nodes,omitempty"`
}

type ProxmoxMachineTemplateResource struct {
type ProxmoxMachineTemplateSpecTemplate struct {
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata.omitempty"`
Spec ProxmoxMachineTemplateSpecTemplateSpec `json:"spec"`
}

type ProxmoxMachineTemplateSpecTemplateSpec struct {
// Image is the image to be provisioned
Image Image `json:"image"`

// CloudInit defines options related to the bootstrapping systems where
// CloudInit is used.
// +optional
CloudInit CloudInit `json:"cloudInit,omitempty"`

// Hardware
Hardware Hardware `json:"hardware,omitempty"`

// Network
Network Network `json:"network,omitempty"`

// Options
// +optional
Options Options `json:"options,omitempty"`
}

type ProxmoxMachineTemplateVmIdRange struct {
// Start of VM ID range
Start int `json:"start"`

// End of VM ID range
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata.omitempty"`
Spec ProxmoxMachineSpec `json:"spec"`
End int `json:"end,omitempty"`
}

// ProxmoxMachineTemplateStatus defines the observed state of ProxmoxMachineTemplate
Expand Down
27 changes: 26 additions & 1 deletion api/v1beta1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1beta1

import (
"fmt"
corev1 "k8s.io/api/core/v1"
"strings"

"github.com/sp-yduck/proxmox-go/api"
Expand Down Expand Up @@ -83,10 +84,14 @@ type Hardware struct {
// SCSI controller model
// SCSIHardWare SCSIHardWare `json:"scsiHardWare,omitempty"`

// hard disk size
// boot disk size
// +kubebuilder:validation:Pattern:=\+?\d+(\.\d+)?[KMGT]?
// +kubebuilder:default:="50G"
Disk string `json:"disk,omitempty"`

// Storage name for the boot disk. If none is provided, the ProxmoxCluster storage name will be used
// +optional
StorageName string `json:"storage,omitempty"`
}

// Network
Expand All @@ -101,6 +106,14 @@ type Network struct {

// search domain
SearchDomain string `json:"searchDomain,omitempty"`

// +kubebuilder:default:="virtio"
Model string `json:"model,omitempty"`

// +kubebuilder:default:="vmbr0"
Bridge string `json:"bridge,omitempty"`

Tag int `json:"vlanTag,omitempty"`
}

// IPConfig defines IP addresses and gateways for corresponding interface.
Expand All @@ -117,6 +130,12 @@ type IPConfig struct {

// gateway IPv6
Gateway6 string `json:"gateway6,omitempty"`

// IPv4FromPoolRef is a reference to an IP pool to allocate an address from.
IPv4FromPoolRef *corev1.TypedLocalObjectReference `json:"IPv4FromPoolRef,omitempty"`

// IPv6FromPoolRef is a reference to an IP pool to allocate an address from.
IPv6FromPoolRef *corev1.TypedLocalObjectReference `json:"IPv6FromPoolRef,omitempty"`
}

func (c *IPConfig) String() string {
Expand Down Expand Up @@ -156,3 +175,9 @@ var (
InstanceStatusRunning = InstanceStatus(api.ProcessStatusRunning)
InstanceStatusStopped = InstanceStatus(api.ProcessStatusStopped)
)

type ClusterFailureDomainConfig struct {
// Treat each node as a failure domain for cluster api
// +optional
NodeAsFailureDomain bool `json:"nodeAsFailureDomain,omitempty"`
}
113 changes: 102 additions & 11 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading