virtual-machine

This commit is contained in:
Andrei Kvapil
2024-02-06 11:35:00 +01:00
parent c48de3082e
commit 7fd409dcd2
11 changed files with 151 additions and 62 deletions

View File

@@ -213,12 +213,75 @@ kubectl get hr -A
#### Configure Storage
```
alias linstor='kubectl exec -n cozy-linstor deploy/linstor-controller -- linstor'
```
TODO
Create default storage classes:
```
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: linstor.csi.linbit.com
parameters:
linstor.csi.linbit.com/storagePool: "data"
linstor.csi.linbit.com/layerList: "storage"
linstor.csi.linbit.com/allowRemoteVolumeAccess: "false"
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: replicated
provisioner: linstor.csi.linbit.com
parameters:
linstor.csi.linbit.com/storagePool: "data"
linstor.csi.linbit.com/autoPlace: "3"
linstor.csi.linbit.com/layerList: "drbd storage"
linstor.csi.linbit.com/allowRemoteVolumeAccess: "true"
property.linstor.csi.linbit.com/DrbdOptions/auto-quorum: suspend-io
property.linstor.csi.linbit.com/DrbdOptions/Resource/on-no-data-accessible: suspend-io
property.linstor.csi.linbit.com/DrbdOptions/Resource/on-suspended-primary-outdated: force-secondary
property.linstor.csi.linbit.com/DrbdOptions/Net/rr-conflict: retry-connect
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
```
#### Configure Networking interconnection
TODO
```
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: cozystack
namespace: cozy-metallb
spec:
ipAddressPools:
- cozy-public
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: cozystack
namespace: cozy-metallb
spec:
addresses:
- 192.168.100.200-192.168.100.250
autoAssign: true
avoidBuggyIPs: false
```
#### Setup basic applications
Get token from `tenant-root`:

1
TODO
View File

@@ -27,3 +27,4 @@ fullnameOverride kamaji-etcd
specify nip.io domain by default
automatically delete provisioned services with the cluster
replicated storageclass
replicated and local storageclasses

View File

@@ -4,8 +4,8 @@
"properties": {
"host": {
"type": "string",
"form": true,
"title": "Domain name for this tenant",
"required": false,
"title": "Domain name for this kubernetes cluster",
"description": "This host will be used for all apps deployed in this tenant"
}
}

View File

@@ -1,2 +0,0 @@
IP: 10.66.0.23
login: fedora

View File

@@ -1,6 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: password
stringData:
root: asdasdasd

View File

@@ -0,0 +1,27 @@
{{- if .Values.external }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "virtual-machine.fullname" . }}
labels:
{{- include "virtual-machine.labels" . | nindent 4 }}
spec:
{{- if .Values.external }}
type: LoadBalancer
externalTrafficPolicy: Local
allocateLoadBalancerNodePorts: false
{{- end }}
selector:
{{- include "virtual-machine.labels" . | nindent 4 }}
ports:
- name: ssh
port: 22
targetPort: 22
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
{{- end }}

View File

@@ -1,5 +1,4 @@
---
apiVersion: kubevirt.io/v1
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
name: {{ include "virtual-machine.fullname" . }}
@@ -7,6 +6,29 @@ metadata:
{{- include "virtual-machine.labels" . | nindent 4 }}
spec:
running: true
dataVolumeTemplates:
- metadata:
name: {{ include "virtual-machine.fullname" . }}
spec:
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.disk | quote }}
storageClassName: replicated
source:
http:
{{- if eq .Values.image "cirros" }}
url: https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img
{{- else if eq .Values.image "ubuntu" }}
url: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
{{- else if eq .Values.image "fedora" }}
url: https://mirror.karneval.cz/pub/linux/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-39-1.5.x86_64.qcow2
{{- else if eq .Values.image "alpine" }}
url: https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso
{{- end }}
template:
metadata:
annotations:
@@ -16,33 +38,28 @@ spec:
spec:
domain:
cpu:
threads: 1
cores: 2
sockets: 1
memory:
guest: {{ .Values.resources.memory | quote }}
cores: {{ .Values.resources.cpu }}
devices:
disks:
- disk:
bus: virtio
name: containerdisk
bus: scsi
name: systemdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- name: default
bridge: {}
networks:
- name: default
pod: {}
machine:
type: ""
resources:
requests:
memory: {{ .Values.resources.memory | quote }}
terminationGracePeriodSeconds: 30
volumes:
- containerDisk:
image: kubevirt/fedora-cloud-container-disk-demo:latest
name: containerdisk
- dataVolume:
name: {{ include "virtual-machine.fullname" . }}
name: systemdisk
- cloudInitNoCloud:
userData: |-
#cloud-config
password: fedora
password: {{ .Values.password }}
chpasswd: { expire: False }
name: cloudinitdisk

View File

@@ -4,22 +4,25 @@
"properties": {
"running": {
"type": "boolean",
"title": "Running",
"form": "useSelfHostedDatabase"
"title": "Running"
},
"external": {
"type": "boolean",
"title": "Enable external Access"
},
"image": {
"type": "string",
"form": true,
"enum": ["ubuntu", "centos", "alpine", "fedora"],
"title": "Database Type",
"description": "Choose image"
"enum": ["ubuntu", "cirros", "alpine", "fedora"],
"title": "Choose image"
},
"password": {
"type": "string",
"title": "Password"
},
"disk": {
"type": "string",
"title": "Disk Size",
"x-display": "slider",
"minimum": 1,
"maximum": 100
"title": "Disk Size"
},
"resources": {
"type": "object",

View File

@@ -1,5 +1,8 @@
image: fedora
disk: 10Gi
external: false
running: true
password: hackme
image: ubuntu
disk: 5Gi
resources:
cpu: 2
cpu: 1
memory: 1024M

View File

@@ -1,14 +1,14 @@
{
"containerimage.config.digest": "sha256:09f4e6e5841f426c8816bf416e55c36c07994895438253ef532ae411c5c13d25",
"containerimage.config.digest": "sha256:4e65da7e421b109937f549285f453934de37a88f3100cc046d75d5e5cfdc1ef5",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"digest": "sha256:443d8daa9f826e128ff013d43c5598bb2cf1915c427b5157e6c9f3f9c791db0f",
"digest": "sha256:f5a78fff1dc9241a707c16a3d719c2ebfbdbc81dba704ff2c80e24fd820307dd",
"size": 2074,
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
"containerimage.digest": "sha256:443d8daa9f826e128ff013d43c5598bb2cf1915c427b5157e6c9f3f9c791db0f",
"containerimage.digest": "sha256:f5a78fff1dc9241a707c16a3d719c2ebfbdbc81dba704ff2c80e24fd820307dd",
"image.name": "ghcr.io/aenix-io/cozystack/installer:latest"
}

View File

@@ -1,7 +1,7 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: linstor-lvm
name: local
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: linstor.csi.linbit.com
@@ -14,23 +14,6 @@ allowVolumeExpansion: true
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: linstor-drbd-lvm
provisioner: linstor.csi.linbit.com
parameters:
linstor.csi.linbit.com/storagePool: "data"
linstor.csi.linbit.com/autoPlace: "3"
linstor.csi.linbit.com/layerList: "drbd storage"
linstor.csi.linbit.com/allowRemoteVolumeAccess: "false"
property.linstor.csi.linbit.com/DrbdOptions/auto-quorum: suspend-io
property.linstor.csi.linbit.com/DrbdOptions/Resource/on-no-data-accessible: suspend-io
property.linstor.csi.linbit.com/DrbdOptions/Resource/on-suspended-primary-outdated: force-secondary
property.linstor.csi.linbit.com/DrbdOptions/Net/rr-conflict: retry-connect
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: replicated
provisioner: linstor.csi.linbit.com