Skip to content

Instantly share code, notes, and snippets.

@fl64
fl64 / ngc.yaml
Created October 2, 2023 15:22
ngc.yaml
apiVersion: deckhouse.io/v1alpha1
kind: NodeGroupConfiguration
metadata:
name: containerd-dvcr-config.sh
spec:
weight: 49
nodeGroups: ["*"]
bundles: ["*"]
content: |
mkdir -p /etc/containerd/conf.d
@fl64
fl64 / remove-kubevirt.sh
Created August 30, 2023 08:41
remove-kubevirt.sh
#!/usr/bin/env bash
export namespace=d8-virtualization
export labels=("operator.kubevirt.io" "operator.cdi.kubevirt.io" "kubevirt.io" "cdi.kubevirt.io")
export namespaces=(d8-cdi ${namespace})
# We need to delete kubevirt resource before operator!
kubectl -n ${namespace} delete kubevirt kubevirt --force --grace-period=0
kubectl -n ${namespace} patch kubevirt kubevirt --type=json -p '[{ "op": "remove", "path": "/metadata/finalizers" }]'
@fl64
fl64 / bundle.yaml
Last active August 10, 2023 12:27
linstor-kubevirt-test
apiVersion: v1
kind: Namespace
metadata:
name: vms
---
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
annotations:
cdi.kubevirt.io/storage.bind.immediate.requested: ""
@fl64
fl64 / books.md
Last active February 20, 2026 20:59
books
@fl64
fl64 / config sinppets
Last active June 2, 2023 11:56
path to sway wm
## Screenshots
https://www.reddit.com/r/swaywm/comments/hczg3k/comment/fx9ur54/?utm_source=share&utm_medium=web2x&context=3
mode "print" {
bindsym y exec grim -g "$(slurp)" - | wl-copy; mode "default"
bindsym g exec grim -g "$(slurp)" "$(xdg-user-dir PICTURES)/Grimshot $(date +%c).png"; mode "default"
bindsym s exec grim -g "$(slurp)" - | swappy -f -; mode "default"
bindsym w exec swaymsg -t get_tree | jq -r '.. | (.nodes? // empty)[] | select(.focused) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)"' | grim -g - - | swappy -f -; mode "default"
bindsym Escape mode "default"
}
@fl64
fl64 / config
Last active May 31, 2023 14:14
sway snippets
# Workaround for GTK apps hanging during init
# See https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start
# See https://github.com/swaywm/sway/issues/5732
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
exec dbus-update-activation-environment 2>/dev/null && \
dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
# End of workaround
# Your preferred terminal emulator
set $term terminator
@fl64
fl64 / kubernetes pods cgroup info.bash
Last active May 28, 2023 11:25
kubernetes pods cgroup info
```bash
kubectl get pods -n test echo-lim-1000m-req-1000m -o json | jq '.spec.nodeName' -r  virt/vms ⎈    14:14:00 
# virtlab-pt-1
kubectl get nodes $(kubectl get pods -n test echo-lim-1000m-req-1000m -o json | jq '.spec.nodeName' -r) -o json | jq '.status.addresses[] | select(.type=="InternalIP") | .address' -r
# 172.18.18.21
kubectl get pods -n test echo-lim-1000m-req-1000m -o json | jq '.status.containerStatuses[0].containerID | split("://")[1]' -r  virt/vms ⎈  SIGINT(2) ↵  14:16:52 
# b11ef417a0240e9e95cb4eb6cb0263a5f2f771ec8e10fc1d0f9abee4578f87ba
@fl64
fl64 / yq.sh
Last active May 18, 2023 11:48
jq queries
kubectl get nodes -o json | jq -rc '.items[].status.addresses | reduce .[] as $node ({}; . + { "\($node.type)": "\($node.address)" })'
# output example:
# {"InternalIP":"192.168.199.238","ExternalIP":"172.16.66.221","Hostname":"dev0-istio-f6dfc5a3-78d85-bwzgf"}
# {"InternalIP":"192.168.199.42","ExternalIP":"172.16.66.46","Hostname":"dev0-worker-f6dfc5a3-86445-7db72"}
kubectl get nodes -o json 2>/dev/null | jq '[ .items[] | {int: .status.addresses[] | select(.type=="InternalIP") | .address , ext: .status.addresses[] | select(.type=="ExternalIP") | .address, name: .metadata.name } ]'
# !!! It doesn't work if ExternalIP does not exist
@fl64
fl64 / get-all.sh
Last active April 23, 2023 14:45
get all resources in ns and their owners
#!/usr/bin/env bash
orange=$(tput setaf 3)
green=$(tput setaf 2)
red=$(tput setaf 1)
sgr0=$(tput sgr0)
if [[ ${1} != "" ]]; then
if ! kubectl get namespace ${1} >/dev/null 2>&1; then echo "Namespace ${1} doesn't exist"; exit; fi
fi
@fl64
fl64 / controller.go
Last active March 22, 2023 12:48
k8s controller example
// SRC: https://www.zhaohuabing.com/post/2023-03-09-how-to-create-a-k8s-controller/
package main
import (
"flag"
"fmt"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/informers"
"time"