Skip to content

Commit

Permalink
Merge pull request #35 from alperencelik/multiple-nic-and-disk
Browse files Browse the repository at this point in the history
feat: Add support for multiple NIC and disks
  • Loading branch information
alperencelik authored Jun 6, 2024
2 parents d246670 + 628bf89 commit db70047
Show file tree
Hide file tree
Showing 23 changed files with 457 additions and 91 deletions.
4 changes: 1 addition & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ builds:
flags:
- -trimpath
ldflags:
- -extldflags "-static"
- -s
- -w
- -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} -X main.treeState={{ .IsGitDirty }}
goos:
- darwin
- linux
Expand Down
4 changes: 2 additions & 2 deletions api/proxmox/v1alpha1/virtualmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ type VirtualMachineSpecTemplateDisk struct {
Storage string `json:"storage"`
// Size is the size of the disk in GB
Size int `json:"size"`
// Type is the type of the disk
Type string `json:"type"`
// Device is the name of the device
Device string `json:"device"`
}

type VirtualMachineSpecTemplateNetwork struct {
Expand Down
9 changes: 4 additions & 5 deletions charts/kubemox/templates/crds/virtualmachines.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down Expand Up @@ -102,19 +101,19 @@ spec:
description: Disks is the list of disks
items:
properties:
device:
description: Device is the name of the device
type: string
size:
description: Size is the size of the disk in GB
type: integer
storage:
description: Storage is the name of the storage
type: string
type:
description: Type is the type of the disk
type: string
required:
- device
- size
- storage
- type
type: object
type: array
memory:
Expand Down
80 changes: 72 additions & 8 deletions charts/kubemox/templates/crds/virtualmachinesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ spec:
description: Disks is the list of disks
items:
properties:
device:
description: Device is the name of the device
type: string
size:
description: Size is the size of the disk in GB
type: integer
storage:
description: Storage is the name of the storage
type: string
type:
description: Type is the type of the disk
type: string
required:
- device
- size
- storage
- type
type: object
type: array
memory:
Expand Down Expand Up @@ -95,13 +95,77 @@ spec:
status:
description: VirtualMachineSetStatus defines the observed state of VirtualMachineSet
properties:
condition:
conditions:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: string
required:
- condition
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions ]metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
type: object
type: object
served: true
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/proxmox.alperen.cloud_virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ spec:
description: Disks is the list of disks
items:
properties:
device:
description: Device is the name of the device
type: string
size:
description: Size is the size of the disk in GB
type: integer
storage:
description: Storage is the name of the storage
type: string
type:
description: Type is the type of the disk
type: string
required:
- device
- size
- storage
- type
type: object
type: array
memory:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ spec:
description: Disks is the list of disks
items:
properties:
device:
description: Device is the name of the device
type: string
size:
description: Size is the size of the disk in GB
type: integer
storage:
description: Storage is the name of the storage
type: string
type:
description: Type is the type of the disk
type: string
required:
- device
- size
- storage
- type
type: object
type: array
memory:
Expand Down
2 changes: 1 addition & 1 deletion docs/crds/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ spec:
network:
- model: virtio
bridge: vmbr0
```
```
2 changes: 1 addition & 1 deletion docs/crds/managedvirtualmachine.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ManagedVirtualMachine

`ManagedVirtualMachine` is a way to bring your existing VirtualMachines in Proxmox to Kubernetes. As an user you don't need to create `ManagedVirtualMachine` resource. Kubemox will create it for you after the deployment at startup of controller. `ManagedVirtualMachine` is also reconciled by the operator so if you do any change on those (delete, update, etc.) it will be reflected to Proxmox.
`ManagedVirtualMachine` is a way to bring your existing VirtualMachines in Proxmox to Kubernetes. As an user you don't need to create `ManagedVirtualMachine` resource. Kubemox will create `ManagedVirtualMachine` objects according to existing VirtualMachines in Proxmox who has a tag called `kubemox-managed-vm` by default. You can change the tag name by setting `MANAGED_VIRTUAL_MACHINE_TAG` environment variable in the controller. `ManagedVirtualMachine` is also reconciled by the operator so if you do any change on those (delete, update, etc.) it will be reflected to Proxmox.

!!! warning
You should not create `ManagedVirtualMachine` resource manually. Kubemox will create it for you after the deployment at startup of controller. That is way to bring your existing VirtualMachines in Proxmox to Kubernetes. You can delete or modify them but you should not create them manually.
6 changes: 5 additions & 1 deletion docs/crds/virtualmachine.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ spec:
socket: 1
# Memory to be allocated to the VM
memory: 4096 # As MB
# Deletion protection is whether to delete VM from Proxmox or not
deleteProtection: false
# VM should be started any time found in stopped state
enableAutostart: true
# Disk used by the VM
disk:
- storage: nvme
size: 50 # As GB
type: scsi
device: scsi0
# Network interfaces used by the VM
network:
- model: virtio
Expand Down
10 changes: 7 additions & 3 deletions docs/crds/virtualmachineset.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Virtual MachineSet

`VirtualMachineSet` is a way to create multiple VirtualMachines in Proxmox. The relationship between `VirtualMachineSet` and `VirtualMachine` is similar to the relationship between `Deployment` and `Pod`. `VirtualMachineSet` creates multiple `VirtualMachine` resources and Kubemox will create them for you in Proxmox. You can only use `VirtualMachineSet` with templates. Creating multiple VirtualMachines from scratch is not supported yet.
`VirtualMachineSet` is a way to create multiple VirtualMachines in Proxmox. The relationship between `VirtualMachineSet` and `VirtualMachine` is similar to the relationship between `Deployment` and `Pod`. `VirtualMachineSet` creates multiple `VirtualMachine` resources and Kubemox will create them for you in Proxmox. You can only use `VirtualMachineSet` with templates. Creating multiple VirtualMachines from scratch is not supported yet.

## Creating VirtualMachineSet

Expand Down Expand Up @@ -32,14 +32,18 @@ spec:
socket: 1
# Memory to be allocated to the VM
memory: 4096 # As MB
# Deletion protection is whether to delete VM from Proxmox or not
deleteProtection: false
# VM should be started any time found in stopped state
enableAutostart: true
# Disk used by the VM
disk:
- storage: nvme
size: 50 # As GB
type: scsi
device: scsi0
# Network interfaces used by the VM
network:
- model: virtio
bridge: vmbr0
EOF
```
```
5 changes: 3 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ helm install kubemox alperencelik/kubemox --set \

### Clone from the source

* You can also clone the repository and run the operator locally with Make.
* You can also clone the repository and run the operator locally with Make.

```bash
git clone https://github.com/alperencelik/kubemox.git
Expand All @@ -56,4 +56,5 @@ tilt up

## Creating your first Proxmox resource

You can create different Proxmox resources using the Kubemox CRDs. For more information, you can check the [Custom Resources](crds/virtualmachine.md). Example resource manifests can be found in the [examples](https://github.com/alperencelik/kubemox/tree/main/examples) directory.

You can create different Proxmox resources using the Kubemox CRDs. For more information, you can check the [Custom Resources](crds/virtualmachine.md). Example resource manifests can be found in the [examples](https://github.com/alperencelik/kubemox/tree/main/examples) directory.
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# What is Kubemox?
# What is Kubemox?

[![Pipeline Status](https://img.shields.io/github/actions/workflow/status/alperencelik/kubemox/.github/workflows/publish.yaml?branch=main)](https://github.com/alperencelik/kubemox/actions)
[![Latest Release](https://img.shields.io/github/v/release/alperencelik/kubemox)](https://github.com/alperencelik/kubemox/releases)
Expand All @@ -12,4 +12,3 @@ Kubemox is a Kubernetes operator for Proxmox VE. It allows you to manage Proxmox
<div style="text-align:center;">
<img src="images/kubemox.jpg" alt="Logo" width="150" height="150">
</div>

2 changes: 1 addition & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ EOF

For visualization, you can use Grafana. The example can be found in `grafana/custom-metrics/custom-metrics-dashboard.json`. You can import that dashboard to your Grafana instance. Here is how dashboard looks like.

![Custom Metrics Dashboard](images/grafana-dashboard.jpg)
![Custom Metrics Dashboard](images/grafana-dashboard.jpg)
1 change: 0 additions & 1 deletion docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

The project is aiming to support most of the Proxmox features. The project is still in early development phase and there are lots of things to do. The testing part is totally missing and the project doesn't have so much known coverage. The aim of the Project is having declarative Proxmox management via Kubernetes CRDs and covering the Proxmox API as much as possible.


- [ ] Add more CRDs for Proxmox resources (LXC(Containers), Storage, Networking etc.)
- [x] Add more options for Proxmox client (TLS and different authentication methods)
- [ ] Add more features to the operator (HA, configuration, etc.)
Expand Down
15 changes: 12 additions & 3 deletions examples/virtualmachineclone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ spec:
socket: 1
# Memory to be allocated to the VM
memory: 4096 # As MB
# Deletion protection is whether to delete VM from Proxmox or not
deleteProtection: false
# VM should be started any time found in stopped state
enableAutostart: true
# Disk used by the VM
disk:
- storage: nvme
size: 50 # As GB
type: scsi
device: scsi0
- storage: nvme
size: 20 # As GB
device: scsi1
# Network interfaces used by the VM
network:
- model: virtio
Expand All @@ -47,11 +54,13 @@ spec:
disk:
- storage: nvme
size: 50 # As GB
type: scsi
device: scsi0
# Network interfaces used by the VM
network:
- model: virtio
bridge: vmbr0
- model: virtio
bridge: vmbr0
---
apiVersion: proxmox.alperen.cloud/v1alpha1
kind: VirtualMachine
Expand All @@ -74,7 +83,7 @@ spec:
disk:
- storage: nvme
size: 50 # As GB
type: scsi
device: scsi0
# Network interfaces used by the VM
network:
- model: virtio
Expand Down
12 changes: 10 additions & 2 deletions examples/virtualmachineset-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ spec:
socket: 1
# Memory to be allocated to the VM
memory: 4096 # As MB
# Deletion protection is whether to delete VM from Proxmox or not
deleteProtection: false
# VM should be started any time found in stopped state
enableAutostart: true
# Disk used by the VM
disk:
- storage: nvme
size: 50 # As GB
type: scsi
device: scsi
# Network interfaces used by the VM
network:
- model: virtio
Expand Down Expand Up @@ -54,11 +58,15 @@ spec:
socket: 1
# Memory to be allocated to the VM
memory: 32768 # As MB
# Deletion protection is whether to delete VM from Proxmox or not
deleteProtection: false
# VM should be started any time found in stopped state
enableAutostart: true
# Disk used by the VM
disk:
- storage: nvme
size: 50 # As GB
type: scsi
device: scsi
# Network interfaces used by the VM
network:
- model: virtio
Expand Down
Loading

0 comments on commit db70047

Please sign in to comment.