Skip to content

Instantly share code, notes, and snippets.

View sub314xxl's full-sized avatar

Konstantin Mokhnatkin sub314xxl

  • Moscow, Russian Federation
View GitHub Profile
@sub314xxl
sub314xxl / clean-k8s.sh
Created March 27, 2024 20:35
clean up k8s cluster
for ns in $(kubectl get ns -o name | cut -d'/' -f2); do
for pod in $(kubectl get pods -n $ns --field-selector=status.phase!=Running -o name | cut -d'/' -f2); do
kubectl delete pod -n $ns $pod
done
for rs in $(kubectl get rs -n "$ns" -o name | cut -d'/' -f2); do
kubectl delete rs -n $ns $rs
done
done
kubectl get pods -A && kubectl top pods -A && kubectl top node
@sub314xxl
sub314xxl / kubectl.md
Created January 31, 2024 19:39 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@sub314xxl
sub314xxl / optimal_mtu.md
Created January 2, 2024 13:00 — forked from nitred/optimal_mtu.md
Wireguard Optimal MTU

About

  • I faced bandwidth issues between a WG Peer and a WG server. Download bandwidth when downloading from WG Server to WG peer was reduced significantly and upload bandwidth was practically non existent.
  • I found a few reddit posts that said that we need to choose the right MTU. So I wrote a script to find an optimal MTU.
  • Ideally I would have liked to have run all possible MTU configurations for both WG Server and WG Peer but for simplicity I choose to fix the WG Server to the original 1420 MTU and tried all MTUs from 1280 to 1500 for the WG Peer.

Testing

  • On WG server, I started an iperf3 server
  • On WG peer, I wrote a script that does the following:
    • wg-quick down wg0
  • Edit MTU in the /etc/wireguard/wg0.conf file
@sub314xxl
sub314xxl / kubedf
Created December 26, 2023 08:10 — forked from redmcg/kubedf
Bash script to show k8s PVC usage
#!/usr/bin/env bash
NODESAPI=/api/v1/nodes
function getNodes() {
kubectl get --raw $NODESAPI | jq -r '.items[].metadata.name'
}
function getPVCs() {
jq -s '[flatten | .[].pods[].volume[]? | select(has("pvcRef")) | '\
@sub314xxl
sub314xxl / systemd_service_hardening.md
Created October 14, 2023 18:14 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@sub314xxl
sub314xxl / Win11TaskBarTweaks.cmd
Created September 5, 2023 15:45
Windows 11 enable text ttles for taskbar buttons
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /V TaskbarGlomLevel /T REG_DWORD /D 2 /F
taskkill /f /im explorer.exe
start explorer.exe
@sub314xxl
sub314xxl / install-discord.bash
Created June 21, 2023 15:14 — forked from lnoering/install-discord.bash
Install discord (for the .tar.gz)
#!/usr/bin/env bash
cd ~/
mkdir -p ~/.local/bin
wget "https://discordapp.com/api/download/canary?platform=linux&format=tar.gz" -O discord.tar.gz
tar -xvf discord.tar.gz -C ~/.local/bin
sudo ln -s ~/.local/bin/DiscordCanary/discord.png /usr/share/icons/discord.png
sudo ln -s ~/.local/bin/DiscordCanary/DiscordCanary /usr/bin
wget https://gist.githubusercontent.com/AdrianKoshka/a12ca0bfe2f334a9f208aff72f8738c3/raw/9d606ad7ce7cc1dd23f6a99993e2396540538a02/discord.desktop -O discord.desktop
mkdir -p ~/.local/share/applications/
mv ~/discord.desktop ~/.local/share/applications/
@sub314xxl
sub314xxl / bash-cheatsheet.sh
Created May 29, 2023 12:39 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@sub314xxl
sub314xxl / .bashrc
Created May 29, 2023 10:28 — forked from michaelklapper/.bashrc
Color up your bash history with the date time information of called commands.
MY_BASH_BLUE="\033[0;34m" #Blue
MY_BASH_NOCOLOR="\033[0m"
HISTTIMEFORMAT=`echo -e ${MY_BASH_BLUE}[%F %T] $MY_BASH_NOCOLOR `
HISTSIZE=20000
HISTFILESIZE=20000
@sub314xxl
sub314xxl / wireshark-non-root.sh
Created May 20, 2023 08:27
Run WireShark without root
# Check CAP support in Kernel
cat /proc/config.gz | gunzip | grep CAPABILITY
/sbin/capsh --print
# Set CAP on core binary
sudo setcap cap_net_raw,cap_net_admin+eip /usr/bin/dumpcap
# Add current user to Wireshark group
sudo usermod -aG wireshark $USER