Skip to content

Instantly share code, notes, and snippets.

View jakoberpf's full-sized avatar

Jakob Boghdady jakoberpf

View GitHub Profile
@jakoberpf
jakoberpf / Watch for warning events in all namespaces.sh
Created September 21, 2021 15:35
Watches for events with the type warning in all namespaces of a kubernetes cluster
watch -n -5 kubectl get events --all-namespaces=true --field-selector type=Warning
@jakoberpf
jakoberpf / finalize namespace stuck in terminating state
Last active May 16, 2022 12:47
This script will terminate a given namespace, even if its stuck in the terminating state. Note that this will not trigger any ressource cleanup.
echo ATTENTION: THIS IS UNSAFE!
echo Which namespace would you like me to terminate\?
read NAMESPACE_TO_DESTROY
echo I will terminate namespace $NAMESPACE_TO_DESTROY\!
(
kubectl proxy &
kubectl get namespace $NAMESPACE_TO_DESTROY -o json |jq '.spec = {"finalizers":[]}' >temp.json
@jakoberpf
jakoberpf / rsync.md
Last active December 16, 2021 09:54

rsync commands

Basics

rsync -avzh <source> <username>@<ip>:<destination>

Advanced

exclude files/dirs based on patterns

redirect traffic incoming on a specific port to a different IP address / another server

2.2.2.2:4000 -> 1.1.1.1:3000

Solution

iptables -t nat -A PREROUTING -p tcp --dport 4000 -j DNAT --to-destination 1.1.1.1:3000
iptables -t nat -A POSTROUTING -p tcp -d 2.2.2.2 --dport 4000 -j SNAT --to-source 1.1.1.1
iptables -t nat -A POSTROUTING -j MASQUERADE

iptables cheatsheet

Show iptables rules

This will show the now current state of iptables

iptables -S

This will show all current iptable rules

[manual] create ceph filesystem

Configure MDS (MetaData Server) on a Node which you'd like to set MDS. It sets to [node01] on this exmaple.

ceph-deploy mds create node01

Create at least 2 RADOS pools on MDS Node and activate MetaData Server. For pg_num which is specified at the end of a creating command, refer to official document and decide appropriate value. Documentation

@jakoberpf
jakoberpf / [script] add host to hosts file
Created January 5, 2022 15:47
Add a new host to the /etc/hosts file
#!/bin/bash
# insert/update hosts entry
ip_address="192.168.x.x"
host_name="my.hostname.example.com"
# find existing instances in the host file and save the line numbers
matches_in_hosts="$(grep -n $host_name /etc/hosts | cut -f1 -d:)"
host_entry="${ip_address} ${host_name}"
echo "Please enter your password if requested."
@jakoberpf
jakoberpf / [troubleshooting] macOS M1 minikube network issue.md
Created January 18, 2022 09:24
how to fix minikube start docker network issue on macOS M1

[troubleshooting] macOS M1 minikube network issue

When starting minikube, we see a docker network related error.

Issue

$ minikube start
😄  minikube v1.24.0 auf Darwin 12.0.1 (arm64)
✨  Automatically selected the docker driver
@jakoberpf
jakoberpf / [manual] ceph client setup.md
Last active January 19, 2022 22:00
Cheatsheet for setting up a new ceph client

[manual] ceph client setup

Cheatsheet for setting up a new ceph client

Gather key and config

From any autheticated ceph host/client.

root@ceph:~$ ceph auth get-or-create client.fs
@jakoberpf
jakoberpf / [manual] create erasure-coding ceph filesystem pool.md
Last active January 20, 2022 09:22
Cheatsheet how to setup a erasure coding pool, add it to a ceph filesystem and configure files/directories to use the ec pool.

[manual] create erasure-coding ceph filesystem pool

Cheatsheet how to setup a erasure coding pool, add it to a ceph filesystem and configure files/directories to use the ec pool.

root@ceph:~$ ceph osd erasure-code-profile set ec-62-profile k=6 m=2 crush-failure-domain=osd crush-device-class=hdd
root@ceph:~$ ceph osd pool create glacier_data_ec-62 erasure ec-62-profile
root@ceph:~$ ceph osd pool set glacier_data_ec-62 allow_ec_overwrites true
root@ceph:~$ ceph osd pool application enable glacier_data_ec-62 cephfs
root@ceph:~$ ceph fs add_data_pool glacier glacier_data_ec-62