Skip to content

Instantly share code, notes, and snippets.

View alicefr's full-sized avatar

Alice Frosi alicefr

  • Red Hat
  • Germany
View GitHub Profile
@alicefr
alicefr / DRA - experimenting
Last active March 11, 2024 02:33
DRA - experimenting
1. Create a k8s cluster with DRA enabled. We use latest minikube (v1.30.1) as at the moment of writing this, it is only one of the few providing already k8s 1.27
```bash
$ minikube start --driver=kvm2 --feature-gates=DynamicResourceAllocation=true \
--kubernetes-version=v1.27.0-rc.0 \
--extra-config=apiserver.runtime-config='resource.k8s.io/v1alpha2=true'
```
2. Example:
```yaml
apiVersion: resource.k8s.io/v1alpha2
@alicefr
alicefr / SCSI persistent reservation.md
Last active July 25, 2022 12:41
Create local scsi disk and test scsi persistent reservation

Tools installation

yum install targetcli sg3_utils

Create loopback scsi target

modprobe tcm_loop
mount -t configfs configfs /sys/kernel/config/

mkdir -p /disks
@alicefr
alicefr / vm-rhcos.yaml
Created March 8, 2022 13:50
Example of persistent installation with KubeVirt and RHCOS
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: test-ign
name: test-ign
spec:
dataVolumeTemplates:
- metadata:
name: rhcos-dv
@alicefr
alicefr / import-original-image.yaml
Last active January 19, 2022 08:59
Import VM disk image and modify it in the cluster in KubeVirt
kubectl apply -f import-original-image.yaml
# Wait until the DV import has finished. Now you have imported the original image on your k8s cluster
# Modify the initial image with virt-customizee by using virtctl guestfs command. You can install additional packages or modify certain files
$ virtctl guestfs pvc-with-cloud-init
Use image: registry:5000/kubevirt/libguestfs-tools@sha256:4cfe1c07cc33999ed05bd43873b7a30b1b9127a4ae4922333e68a1bcd35169ce
The PVC has been mounted at /disk
If you don't see a command prompt, try pressing enter.
$ ls /disk/
disk.img
virt-customize --run-command 'echo "My awesome image" > /tmp/hello' --install cloud-init -a /disk/disk.img
@alicefr
alicefr / Access disk remotely using nbd
Last active March 11, 2021 09:04
Access remote disk
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc-test Bound local-pv-25a396e8 34Gi RWO local 52m
$ kubectl apply -f expose-pvc-nbd.yaml
service/virt configured
pod/virt configured
# In another console
$ kubectl port-forward pod/virt 8080:8080
Handling connection for 8080
@alicefr
alicefr / kubectl-run-with-pvc.sh
Created March 5, 2021 15:35 — forked from yuanying/kubectl-run-with-pvc.sh
kubectl run with PVCs
#!/bin/bash
IMAGE="gcr.io/google-containers/ubuntu-slim:0.14"
COMMAND="/bin/bash"
SUFFIX=$(date +%s | shasum | base64 | fold -w 10 | head -1 | tr '[:upper:]' '[:lower:]')
usage_exit() {
echo "Usage: $0 [-c command] [-i image] PVC ..." 1>&2
exit 1
}
<domain type='kvm' id='1'>
<name>default_vm-fedora</name>
<uuid>c9dc132f-1bb1-5f88-9891-deed35a6d803</uuid>
<metadata>
<kubevirt xmlns="http://kubevirt.io">
<uid>990631c2-166a-401d-90e6-7a19b5fb2f18</uid>
<graceperiod>
<deletionGracePeriodSeconds>0</deletionGracePeriodSeconds>
</graceperiod>
</kubevirt>