Skip to content

Instantly share code, notes, and snippets.

@fl64
fl64 / virt.xml
Created May 3, 2024 12:16
kubevirt-xml
<domstatus state='running' reason='booted' pid='93'>
<taint flag='custom-monitor'/>
<monitor path='/var/lib/libvirt/qemu/domain-1-mvp-static_static-vm/monitor.sock' type='unix'/>
<vcpus>
<vcpu id='0' pid='98'/>
<vcpu id='1' pid='99'/>
<vcpu id='2' pid='100'/>
<vcpu id='3' pid='101'/>
</vcpus>
<qemuCaps>
@fl64
fl64 / main.go
Last active February 26, 2024 16:39
validate cloud provider spec
package main
import (
"fmt"
"log"
"os"
dhctl "github.com/deckhouse/deckhouse/dhctl/pkg/config"
)
@fl64
fl64 / disk.tf
Last active January 29, 2024 12:54
dvp terraform examples
resource "kubernetes_manifest" "vmd" {
manifest = {
"apiVersion" = "virtualization.deckhouse.io/v1alpha2"
"kind" = "VirtualMachineDisk"
"metadata" = {
"name" = var.root_disk_name
"namespace" = var.namespace
}
@fl64
fl64 / check-images-and-blobs.sh
Created January 23, 2024 10:06
check virtualization modules images
#!/usr/bin/env bash
# Scripts checks images and its layers for currently used virtualization module
# mpo virtualization is needed!
rst='\033[0m' # Text Reset
red='\033[0;31m' # Red
@fl64
fl64 / dvp.sh
Last active January 24, 2024 08:03
virtctl vnc | serial replacement
#!/bin/bash
trap 'other_commands' EXIT
other_commands() {
echo "Closing..."
jobs -p | xargs kill 2>/dev/null
}
random_port() {
echo $((10000 + $RANDOM % 20000))
@fl64
fl64 / check.sh
Created December 11, 2023 10:08
broken images check
#!/usr/bin/env bash
rst='\033[0m' # Text Reset
red='\033[0;31m' # Red
module_image_path="dev-registry.deckhouse.io/sys/deckhouse-oss/modules/virtualization"
virtualization_image_digest=$(kubectl get mpo virtualization -o json | jq .status.imageDigest -r)
module_images=$(crane export ${module_image_path}@${virtualization_image_digest} | tar -Oxf - images_digests.json | jq '. | to_entries | .[]' -c)
@fl64
fl64 / filter.py
Last active December 5, 2023 07:00
CRD filter
#!/usr/bin/env python3
import argparse
import yaml
keepIt = ["description"]
def custom_represent(dumper, data):
if len(data) > 30: # Set a condition for when to use the |
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
@fl64
fl64 / getvms.sh
Created November 22, 2023 20:50
get vms and it's linstor nodes
ns=tfprod
vms=$(kubectl -n ${ns} get pods -l vm.kubevirt.io/name -o json | jq '.items[] | select(.status.phase=="Running") | { ns: .metadata.namespace, name: .metadata.name, node: .spec.nodeName, claims: [.spec.volumes[] | select(.persistentVolumeClaim!=null) | .persistentVolumeClaim.claimName] }' -cr)
for vm in ${vms}; do
echo ${vm} | jq '. | {ns,name,node}' -c
pvcs=$(echo ${vm} | jq .claims[] -r)
for pvc in ${pvcs}; do
volume_name=$(kubectl -n ${ns} get pvc ${pvc} -o json | jq .spec.volumeName -r)
echo "${pvc} / ${volume_name}"
kubectl exec -n d8-linstor deploy/linstor-controller -- linstor r l -r ${volume_name}
@fl64
fl64 / Makefile
Last active November 20, 2023 12:29
convert images for testcases
TMP_DIR=./tmp
IMAGE_NAME=cirros-0.5.1
IMAGE_PATH=${TMP_DIR}/${IMAGE_NAME}
# https://docs.openstack.org/image-guide/obtain-images.html
bold := $(shell tput bold)
red := $(shell tput setaf 1)
green := $(shell tput setaf 2)
@fl64
fl64 / clenup.go
Created November 17, 2023 07:19
deckhouse hooks
package hooks
import (
"github.com/flant/addon-operator/pkg/module_manager/go_hook"
"github.com/flant/addon-operator/sdk"
"github.com/flant/shell-operator/pkg/kube/object_patch"
)
var _ = sdk.RegisterFunc(&go_hook.HookConfig{
OnAfterDeleteHelm: &go_hook.OrderedConfig{Order: 10},