Skip to content

Commit

Permalink
Merge branch 'main' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlipp committed Nov 24, 2024
2 parents 5a68b97 + e839f7b commit 4c600e7
Show file tree
Hide file tree
Showing 84 changed files with 861 additions and 141 deletions.
59 changes: 59 additions & 0 deletions deploy/crds/vmpools-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: vmpools.vmoperator.jdrupes.org
spec:
group: vmoperator.jdrupes.org
# list of versions supported by this CustomResourceDefinition
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
permissions:
type: array
description: >-
Defines permissions for accessing and manipulating the Pool.
items:
type: object
description: >-
Permissions can be granted to a user or to a role.
oneOf:
- required:
- user
- required:
- role
properties:
user:
type: string
role:
type: string
may:
type: array
items:
type: string
enum:
- start
- stop
- reset
- accessConsole
- "*"
default: []
required:
- permissions
# either Namespaced or Cluster
scope: Namespaced
names:
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
plural: vmpools
# singular name to be used as an alias on the CLI and for display
singular: vmpool
# kind is normally the CamelCased singular type. Your resource manifests use this.
kind: VmPool
listKind: VmPoolList
7 changes: 7 additions & 0 deletions deploy/crds/vms-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,13 @@ spec:
- accessConsole
- "*"
default: []
pools:
type: array
description: >-
List of pools to which this VM belongs.
items:
type: string
default: []
loggingProperties:
type: string
description: >-
Expand Down
2 changes: 2 additions & 0 deletions dev-example/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/test-vm-ci.yaml
/kubeconfig.yaml
/crds/
6 changes: 3 additions & 3 deletions dev-example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"/Controller":
namespace: vmop-dev
"/Reconciler":
runnerData:
storageClassName: null
runnerDataPvc:
storageClassName: rook-cephfs
loadBalancerService:
labels:
label1: label1
Expand Down Expand Up @@ -65,7 +65,7 @@
other:
- org.jgrapes.webconlet.oidclogin.LoginConlet
"/ComponentCollector":
"/VmViewer":
"/VmAccess":
displayResource:
preferredIpVersion: ipv4
syncPreviewsFor:
Expand Down
47 changes: 47 additions & 0 deletions dev-example/gen-pool-vm-crds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

function usage() {
cat >&2 <<EOF
Usage: $0 [OPTION]... [TEMPLATE]
Generate VM CRDs using TEMPLATE.
-c, --count Count of VMs to generate
-d, --destination DIR Generate into given directory (default: ".")
-h, --help Print this help
-p, --prefix PREFIX Prefix for generated file (default: basename of template)
EOF
exit 1
}

count=0
destination=.
template=""
prefix=""

while [ "$#" -gt 0 ]; do
case "$1" in
-c|--count) shift; count=$1;;
-d|--destination) shift; destination="$1";;
-h|--help) shift; usage;;
-p|--prefix) shift; prefix="$1";;
-*) echo >&2 "Unknown option: $1"; exit 1;;
*) template="$1";;
esac
shift
done

if [ -z "$template" ]; then
usage
fi

if [ "$count" = "0" ]; then
exit 0
fi
for number in $(seq 1 $count); do
if [ -z "$prefix" ]; then
prefix=$(basename $template .tpl.yaml)
fi
name="$prefix$number"
index=$(($number - 1))
esh -o $destination/$name.yaml $template number=$number index=$index
done
2 changes: 1 addition & 1 deletion dev-example/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ patches:
other:
- org.jgrapes.webconlet.locallogin.LoginConlet
"/ComponentCollector":
"/VmViewer":
"/VmAccess":
displayResource:
preferredIpVersion: ipv4
syncPreviewsFor:
Expand Down
10 changes: 10 additions & 0 deletions dev-example/test-pool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: "vmoperator.jdrupes.org/v1"
kind: VmPool
metadata:
namespace: vmop-dev
name: test-vms
spec:
permissions:
- user: admin
may:
- accessConsole
10 changes: 10 additions & 0 deletions dev-example/test-vm-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
namespace: vmop-dev
name: test-vm-system-disk-snapshot
spec:
volumeSnapshotClassName: csi-rbdplugin-snapclass
source:
persistentVolumeClaimName: test-vm-system-disk
70 changes: 70 additions & 0 deletions dev-example/test-vm.tpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: "vmoperator.jdrupes.org/v1"
kind: VirtualMachine
metadata:
namespace: vmop-dev
name: test-vm<%= ${number} %>
annotations:
argocd.argoproj.io/sync-wave: "20"

spec:
image:
# repository: docker-registry.lan.mnl.de
# path: vmoperator/org.jdrupes.vmoperator.runner.qemu-arch
# pullPolicy: Always
# repository: ghcr.io
# path: mnlipp/org.jdrupes.vmoperator.runner.qemu-alpine
# version: "3.0.0"
source: registry.mnl.de/org/jdrupes/vm-operator/org.jdrupes.vmoperator.runner.qemu-arch:testing
pullPolicy: Always

permissions:
- role: admin
may:
- "*"
- user: test
may:
- accessConsole

guestShutdownStops: true

cloudInit:
metaData: {}

pools:
- test-vms

vm:
# state: Running
bootMenu: true
maximumCpus: 4
currentCpus: 2
maximumRam: 4Gi
currentRam: 3Gi

networks:
# No bridge on TC1
# - tap: {}
- user: {}

disks:
- volumeClaimTemplate:
metadata:
name: system
spec:
storageClassName: ceph-rbd3slow
dataSource:
name: test-vm-system-disk-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 40Gi
- cdrom:
image: ""
# image: https://download.fedoraproject.org/pub/fedora/linux/releases/38/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-38-1.6.iso

display:
spice:
port: <%= $((5910 + number)) %>
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ public class Constants {

/** The Constant VM_OP_KIND_VM. */
public static final String VM_OP_KIND_VM = "VirtualMachine";

/** The Constant VM_OP_KIND_VM_POOL. */
public static final String VM_OP_KIND_VM_POOL = "VmPool";
}
Loading

0 comments on commit 4c600e7

Please sign in to comment.