Skip to content

Instantly share code, notes, and snippets.

View flrichar's full-sized avatar
Gitops Platform Curation

Fred Richards flrichar

Gitops Platform Curation
View GitHub Profile
@flrichar
flrichar / rke-object-count.txt
Created March 21, 2022 21:32
count all objects in etcd from RKE
docker exec etcd etcdctl get /registry --prefix=true --keys-only | grep -v ^$ | awk -F'/' '{ if ($3 ~ /cattle.io/) {h[$3"/"$4]++} else { h[$3]++ }} END { for(k in h) print h[k], k }' | sort -n > etcd-count-objecttype.txt
@flrichar
flrichar / inotify-count.txt
Created March 22, 2022 13:19
inotity count
#!/bin/bash
find /proc/*/fd -lname anon_inode:inotify |
cut -d/ -f3 |
xargs -I '{}' -- ps --no-headers -o '%p %U %c' -p '{}' |
uniq -c |
sort -nr
## check for max_user_watches and/or max_user_instances
@flrichar
flrichar / copy-temp-backups.sh
Last active May 21, 2022 13:26
copy-temp-backups
#!/bin/sh
POD=$(kubectl get pods --no-headers -n cattle-system -l app=rancher26x -o custom-columns=":metadata.name")
PVC=$(kubectl exec -n cattle-system $POD -- find /opt/local-path-provisioner/ -maxdepth 1 -type d -not -path /opt/local-path-provisioner/)
printf "Found pod: %s\n" $POD
printf "Found pvc: %s\n" $PVC
kubectl cp cattle-system/$POD:/opt/local-path-provisioner ./temp-backups/
ls ./temp-backups/pvc-*
@flrichar
flrichar / the-suc
Last active April 4, 2022 16:13
the-suc.txt
# install system upgrade controller
kubectl apply -f https://raw.githubusercontent.com/rancher/system-upgrade-controller/master/manifests/system-upgrade-controller.yaml
# First, label the target node
kubectl label node/k3d-zues-server-0 k3s-upgrade=true
# Then create the plan object in the cluster
kubectl apply -f upgrade_plan.yml
...
@flrichar
flrichar / suse-network-manager.txt
Last active April 8, 2022 15:18
suse-network-manager.txt
Just some bits of wisdom ... whenever you use a SUSE os, tumbleweed, SLES, MicroOs, SLE Micro, LEAP,
first thing to do ...
# systemctl disable --now NetworkManager
# zypper in wicked -y
# systemctl enable --now wicked
Replace NetworkManager with wicked & use normal /etc/sysconfig/network/ifcfg-* config files.
NM seems to be a desktop-first tool, IMHO, and wicked is very easy and simple to set up.
@flrichar
flrichar / microos-kernel-opts.txt
Last active May 22, 2022 15:43
kernel opts for microos
sed -i '/^GRUB_CMDLINE_LINUX/ s/"$/ systemd.unified_cgroup_hierarchy=0"/' /etc/default/grub
transactional-update grub2-mkconfig -o /boot/grub2/grub.cfg
...
@flrichar
flrichar / find-fetch.yaml
Last active November 7, 2022 21:41
find-fetch.yaml
---
- hosts: bionic
become: true
vars_files: ~/YAML/vars/become.yml
vars:
today: "{{ lookup('pipe', 'date +%Y_%m%d') }}"
cluster_home: "{{ lookup('pipe', 'pwd') }}"
tasks:
- name: find tmp/ logfiles
@flrichar
flrichar / fio-test.sh
Created April 21, 2022 13:03
fio-test.sh
#!/bin/sh
[[ -d ./fio-test ]] || mkdir fio-test
fio --rw=write --ioengine=sync --size=200m --bs=2300 --directory=./fio-test --name=io-test
@flrichar
flrichar / audit-log-pretty-print.txt
Last active June 4, 2022 12:21
audit-log-pretty-print.txt
awk '{$1="";print $0 }' somepath/k8s/podlogs/k8s_rancher-audit-log_rancher-7fdc4d94b4-j4tf2_cattle-system_6f9f3596-8473-46c4-8d63-5b462f693fa4_0 | jql
## lop off first field, send rest to jql func/alias
## seen here -- https://gist.github.com/flrichar/7f6ebacfb4405988913e327d6ec5adc5
## ignoring non-json may be better -- https://gist.github.com/flrichar/163c7c2d296e8dfc7a14191ecd790803
@flrichar
flrichar / group-mux-screens.sh
Last active January 16, 2024 16:18
screen sessions in tmux groups
#!/bin/bash
if $(tmux has-session); then
echo "Tmux has-sessions, exiting..."; exit
else
echo "Tmux no sessions, creating..."
fi
SCREENWIN=$(printf 'C-a c %0.s' {1..5})
TSESSION="tmux"