From 3c5b7334a85fdbfb40cd707d1eeeac8495610a2c Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Fri, 11 Aug 2023 12:22:26 +0200 Subject: [PATCH] Add/update example configurations. --- dev-example/Readme.md | 15 +++++++++ dev-example/kustomization.yaml | 35 ++++++++++++++++++++ dev-example/test-vm-pv-system.yaml | 28 ++++++++++++++++ dev-example/test-vm.yaml | 45 ++++++++++++++++++++++++++ example/Readme.md | 10 ++++++ example/kustomization.yaml | 21 ++++++++++++ example/test-vm.yaml | 5 ++- example/vmop-image-repository-pvc.yaml | 15 --------- 8 files changed, 156 insertions(+), 18 deletions(-) create mode 100644 dev-example/Readme.md create mode 100644 dev-example/kustomization.yaml create mode 100644 dev-example/test-vm-pv-system.yaml create mode 100644 dev-example/test-vm.yaml create mode 100644 example/Readme.md create mode 100644 example/kustomization.yaml delete mode 100644 example/vmop-image-repository-pvc.yaml diff --git a/dev-example/Readme.md b/dev-example/Readme.md new file mode 100644 index 0000000..c84b3a9 --- /dev/null +++ b/dev-example/Readme.md @@ -0,0 +1,15 @@ +# Example setup for development + +The CRD must be deployed independently. Apart from that, the +`kustomize.yaml` + + * creates a small image repository and + + * deploys the operator in namespace `vmop-dev` with a replica of 0. + +This allows you to run the manager in your IDE. + +The `kustomize.yaml` also changes the image repository for the +operator to a private repository for development. You have to +either remove this or adapt it to your own repository if you +also want to test your development version in a container. diff --git a/dev-example/kustomization.yaml b/dev-example/kustomization.yaml new file mode 100644 index 0000000..2974028 --- /dev/null +++ b/dev-example/kustomization.yaml @@ -0,0 +1,35 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../deploy + +namespace: vmop-dev + +patches: +- patch: |- + kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: vmop-image-repository + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: local-path + +- target: + group: apps + version: v1 + kind: Deployment + name: vm-operator + patch: |- + - op: replace + path: /spec/template/spec/containers/0/image + value: docker-registry.lan.mnl.de/vmoperator/org.jdrupes.vmoperator.manager:latest + - op: replace + path: /spec/replicas + value: 0 + \ No newline at end of file diff --git a/dev-example/test-vm-pv-system.yaml b/dev-example/test-vm-pv-system.yaml new file mode 100644 index 0000000..f8a7808 --- /dev/null +++ b/dev-example/test-vm-pv-system.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: test-vm-system + labels: + app.kubernetes.io/name: vmrunner + app.kubernetes.io/instance: test-vm + vmrunner.jdrupes.org/disk: system +spec: + capacity: + storage: 40Gi + volumeMode: Block + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + claimRef: + name: system-disk-test-vm-0 + namespace: qemu-vms + local: + path: /dev/vgmain/test-vm + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - olymp diff --git a/dev-example/test-vm.yaml b/dev-example/test-vm.yaml new file mode 100644 index 0000000..9cc51c5 --- /dev/null +++ b/dev-example/test-vm.yaml @@ -0,0 +1,45 @@ +apiVersion: "vmoperator.jdrupes.org/v1" +kind: VirtualMachine +metadata: + namespace: vmop-dev + name: test-vm +spec: + image: + repository: docker-registry.lan.mnl.de + path: vmoperator/org.jdrupes.vmoperator.runner.qemu-arch + pullPolicy: Always + + vm: + state: Running + bootMenu: yes + maximumRam: "8 GiB" + currentRam: "4 GiB" + maximumCpus: 4 + currentCpus: 4 + + networks: + - tap: + mac: "00:16:3e:33:59:10" + disks: + - volumeClaimTemplate: + metadata: + name: system + spec: + storageClassName: "" + selector: + matchLabels: + app.kubernetes.io/name: vmrunner + app.kubernetes.io/instance: test-vm + vmrunner.jdrupes.org/disk: system + 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 + # image: "Fedora-Workstation-Live-x86_64-38-1.6.iso" + +# - hostDevice: /dev/vgmain/test-vm + display: + spice: + port: 5910 diff --git a/example/Readme.md b/example/Readme.md new file mode 100644 index 0000000..d8336f8 --- /dev/null +++ b/example/Readme.md @@ -0,0 +1,10 @@ +# Example setup for development + +The CRD must be deployed independently. Apart from that, the +`kustomize.yaml` defines a namespace for the manager (and the VMs +managed by it). You will most likely want to patch the PVC +for the image repository. + +The `kustomize.yaml` does not include the test VM. Before creating +the test VM, you will again most likely want to change the +disk definition. diff --git a/example/kustomization.yaml b/example/kustomization.yaml new file mode 100644 index 0000000..bb05a82 --- /dev/null +++ b/example/kustomization.yaml @@ -0,0 +1,21 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- https://github.com/mnlipp/VM-Operator/deploy + +namespace: vmop-demo + +# patches: +# - patch: |- +# kind: PersistentVolumeClaim +# apiVersion: v1 +# metadata: +# name: vmop-image-repository +# spec: +# accessModes: +# - ReadWriteOnce +# resources: +# requests: +# storage: 10Gi +# storageClassName: local-path diff --git a/example/test-vm.yaml b/example/test-vm.yaml index 3cb8898..8a9f8e8 100644 --- a/example/test-vm.yaml +++ b/example/test-vm.yaml @@ -1,7 +1,7 @@ apiVersion: "vmoperator.jdrupes.org/v1" kind: VirtualMachine metadata: - namespace: qemu-vms + namespace: vmop-demo name: test-vm spec: @@ -14,7 +14,7 @@ spec: vm: maximumCpus: 4 - currentCpus: 4 + currentCpus: 3 maximumRam: "8 GiB" currentRam: "4 GiB" @@ -36,7 +36,6 @@ spec: requests: storage: 40Gi -# - hostDevice: /dev/vgmain/test-vm display: spice: port: 5910 diff --git a/example/vmop-image-repository-pvc.yaml b/example/vmop-image-repository-pvc.yaml deleted file mode 100644 index a5b47df..0000000 --- a/example/vmop-image-repository-pvc.yaml +++ /dev/null @@ -1,15 +0,0 @@ -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: vmop-image-repository - namespace: qemu-vms - labels: - app.kubernetes.io/name: vmoperator -spec: - storageClassName: rook-cephfs - volumeMode: Filesystem - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 50Gi