Skip to content

Commit eed957f

Browse files
authored
Merge pull request #64 from sp-yduck/develop/v0.3.0
release v0.3.0
2 parents 9aa4667 + 398a609 commit eed957f

34 files changed

+1121
-386
lines changed

.github/workflows/golangci-lint.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: golangci-lint
22

33
on:
44
pull_request:
5-
types: [opened, edited, synchronize, reopened]
5+
types: [opened, synchronize, reopened]
66

77
# Remove all permissions from GITHUB_TOKEN except metadata.
88
permissions: {}
@@ -15,10 +15,10 @@ jobs:
1515
- uses: actions/checkout@v3
1616
- uses: actions/setup-go@v4
1717
with:
18-
go-version: 1.19
18+
go-version: 1.20.5
1919
check-latest: true
2020
- name: golangci-lint
2121
uses: golangci/[email protected]
2222
with:
23-
version: v1.52.2
23+
version: v1.53.3
2424
args: --timeout 5m

Makefile

+11-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ fmt: ## Run go fmt against code.
5757
vet: ## Run go vet against code.
5858
go vet ./...
5959

60+
.PHONY: lint
61+
lint: ## Run golangci-lint
62+
$(GOLANGCI_LINT) run
63+
6064
CLUSTER_NAME := cappx-test
6165

6266
.PHONY: create-workload-cluster
@@ -180,6 +184,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
180184
ENVTEST ?= $(LOCALBIN)/setup-envtest
181185
ENVSUBST ?= $(LOCALBIN)/envsubst
182186
KUBECTL ?= $(LOCALBIN)/kubectl
187+
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
183188

184189
## Tool Versions
185190
KUSTOMIZE_VERSION ?= v5.0.0
@@ -222,4 +227,9 @@ $(KUBECTL): $(LOCALBIN)
222227
.PHONY: setup-envtest
223228
setup-envtest: $(SETUP_ENVTEST)
224229
$(SETUP_ENVTEST): go.mod # Build setup-envtest from tools folder.
225-
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_VER)
230+
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_VER)
231+
232+
.PHONY: golangci-lint
233+
golangci-lint: $(GOLANGCI_LINT)
234+
$(GOLANGCI_LINT): $(LOCALBIN)
235+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) v1.54.0

README.md

+12-15
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,20 @@ for more information : https://cluster-api.sigs.k8s.io/user/quick-start.html#ini
1717
```sh
1818
# install cluster-api components
1919
export EXP_CLUSTER_RESOURCE_SET=true
20-
clusterctl init --infrastructure=proxmox:v0.2.3 --config https://raw.githubusercontent.com/sp-yduck/cluster-api-provider-proxmox/main/clusterctl.yaml
20+
clusterctl init --infrastructure=proxmox:v0.3.0 --config https://raw.githubusercontent.com/sp-yduck/cluster-api-provider-proxmox/main/clusterctl.yaml
2121
```
2222
**Note:** container images are available at [ghcr.io/sp-yduck/cluster-api-provider-proxmox:\<tag\>](https://github.com/sp-yduck/cluster-api-provider-proxmox/pkgs/container/cluster-api-provider-proxmox)
2323

2424
2. Create your first workload cluster
2525
```sh
2626
# export env variables
27-
export CONTROLPLANE_HOST=X.X.X.X # control-plane vip
27+
export CONTROLPLANE_HOST=X.X.X.X # control-plane vip
2828
export PROXMOX_URL=https://X.X.X.X:8006/api2/json
29-
# export PROXMOX_PASSWORD=password # (optional)
30-
# export PROXMOX_USER=user@pam # (optional)
31-
export PROXMOX_TOKENID='root@pam!api-token-id' # (optional)
32-
export PROXMOX_SECRET=aaaaaaaa-bbbb-cccc-dddd-ee12345678 # (optional)
33-
export NODE_URL=node.ssh.url:22
34-
export NODE_USER=node-ssh-user
35-
export NODE_PASSWORD=node-ssh-password
29+
export PROXMOX_PASSWORD=password
30+
export PROXMOX_USER=user@pam
3631

3732
# generate manifests (available flags: --target-namespace, --kubernetes-version, --control-plane-machine-count, --worker-machine-count)
38-
clusterctl generate cluster cappx-test --control-plane-machine-count=3 --infrastructure=proxmox:v0.2.3 --config https://raw.githubusercontent.com/sp-yduck/cluster-api-provider-proxmox/main/clusterctl.yaml > cappx-test.yaml
33+
clusterctl generate cluster cappx-test --control-plane-machine-count=3 --infrastructure=proxmox:v0.3.0 --config https://raw.githubusercontent.com/sp-yduck/cluster-api-provider-proxmox/main/clusterctl.yaml > cappx-test.yaml
3934

4035
# inspect and edit
4136
vi cappx-test.yaml
@@ -62,21 +57,23 @@ kubectl delete cluster cappx-test
6257

6358
## Fetures
6459

65-
- No need to prepare vm templates. You can specify any vm image in `ProxmoxMachine.Spec.Image`.
60+
- No need to prepare vm templates. You can specify any vm image in `ProxmoxMachine.Spec.Image`. CAPPX bootstrap your vm from scratch.
6661

67-
- Supports custom cloud-config (user data). CAPPX uses ssh for bootstrapping nodes so it can applies custom cloud-config that can not be achieved by only Proxmox API.
62+
- Supports mutiple image format. CAPPX uses VNC websocket for downloading/installing node images so it can support multiple image format not only ISO (Proxmox API can only support ISO)
63+
64+
- Supports custom cloud-config (user data). CAPPX uses VNC websockert for bootstrapping nodes so it can applies custom cloud-config that can not be achieved by only Proxmox API.
6865

6966
### Node Images
7067

71-
CAPPX is compatible with `qcow2` image. You can build your own node image and use it for `ProxmoxMachine`.
68+
CAPPX is compatible with `iso`, `qcow2`, `qed`, `raw`, `vdi`, `vpc`, `vmdk` format of image. You can build your own node image and use it for `ProxmoxMachine`.
7269

7370
CAPPX relies on a few prerequisites which have to be already installed in the used operating system images, e.g. a container runtime, kubelet, kubeadm,.. .
7471

7572
To build your custom node image, you can use [kubernetes-sigs/image-builder](https://github.com/kubernetes-sigs/image-builder) project.
7673

7774
Also there are some available out-of-box images published other communities such as [Metal3](https://github.com/metal3-io). For example https://artifactory.nordix.org/ui/native/metal3/images/. Example MD can be found [metal3-ubuntu2204-k8s127.yaml](examples/machine_deployment/metal3-ubuntu2204-k8s127.yaml).
7875

79-
If it isn't possible to pre-install those prerequisites in the image, you can always deploy and execute some custom scripts through the `ProxmoxMachine.spec.cloudInit` or `KubeadmConfig` . Example MD can be found [ubuntu2204.yaml](examples/machine_deployment/ubuntu2204.yaml).
76+
If it isn't possible to pre-install those prerequisites in the image, you can always deploy and execute some custom scripts through the `ProxmoxMachine.spec.cloudInit` or `KubeadmConfig`. Example MD can be found [ubuntu2204.yaml](examples/machine_deployment/ubuntu2204.yaml).
8077

8178
## Compatibility
8279

@@ -99,7 +96,7 @@ This project aims to follow the Cluster API [Provider contract](https://cluster-
9996

10097
### ProxmoxCluster
10198

102-
Because Proxmox-VE does not provide LBaaS solution, CAPPX does not follow the [typical infra-cluster logic](https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior). ProxmoxCluster controller reconciles only Proxmox storages used for instances. You need to prepare control plane load balancer by yourself if you creates HA control plane workload cluster.
99+
Because Proxmox-VE does not provide LBaaS solution, CAPPX does not follow the [typical infra-cluster logic](https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior). ProxmoxCluster controller reconciles only Proxmox storages used for instances. You need to prepare control plane load balancer by yourself if you creates HA control plane workload cluster. In the [cluster-template.yaml](./templates/cluster-template.yaml), you can find HA control plane example with [kube-vip](https://github.com/kube-vip/kube-vip).
103100

104101
### ProxmoxMachine
105102

api/v1beta1/options_types.go

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

api/v1beta1/proxmoxcluster_types.go

-6
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"
@@ -38,9 +35,6 @@ type ProxmoxClusterSpec struct {
3835
// ServerRef is used for configuring Proxmox client
3936
ServerRef ServerRef `json:"serverRef"`
4037

41-
// NodesRef contains reference of nodes used for ProxmoxCluster
42-
NodeRefs []NodeRef `json:"nodeRefs,omitempty"`
43-
4438
// storage is for proxmox storage used by vm instances
4539
// +optional
4640
Storage Storage `json:"storage"`

api/v1beta1/proxmoxmachine_types.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,27 @@ 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

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

40+
// +kubebuilder:validation:Minimum:=0
4541
// VMID is proxmox qemu's id
4642
// +optional
4743
VMID *int `json:"vmID,omitempty"`
@@ -60,9 +56,11 @@ type ProxmoxMachineSpec struct {
6056
// Network
6157
Network Network `json:"network,omitempty"`
6258

59+
// Options
60+
// +optional
61+
Options Options `json:"options,omitempty"`
62+
6363
// 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.
6664
FailureDomain *string `json:"failureDomain,omitempty"`
6765
}
6866

@@ -84,7 +82,10 @@ type ProxmoxMachineStatus struct {
8482
// Conditions
8583
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
8684

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

0 commit comments

Comments
 (0)