Skip to content

Instantly share code, notes, and snippets.

View gadiener's full-sized avatar

Gabriele gadiener

View GitHub Profile
@gadiener
gadiener / delete-crds.sh
Created May 26, 2023 11:46
Delete crds and all resources matching a suffix
#!/bin/bash
CRD_SUFFIX=${1}
if [ -z "${CRD_SUFFIX}" ]; then
echo "Missing CRD suffix"
exit 1
fi
echo "Removing CRDs with suffix ${CRD_SUFFIX}"
@gadiener
gadiener / replace-eks-nodes.sh
Last active December 22, 2023 12:09
Replace EKS nodes
#!/bin/bash
region=$(kubectl get nodes -o jsonpath="{.items[0].metadata.labels['topology\.kubernetes\.io/region']}")
nodes=$(kubectl get nodes -o jsonpath="{.items[*].metadata.name}")
for node in ${nodes[@]}; do
ec2_instance_id=$(kubectl get nodes -o jsonpath="{.items[0].spec.providerID}" | cut -d "/" -f 5)
echo "[INFO] Starting node '${node}' with instance ID '${ec2_instance_id}' in the '${region}' region"
echo "[INFO] Draining node '${node}'"
@gadiener
gadiener / download_from_minio.sh
Last active October 14, 2021 20:02 — forked from JustinTimperio/download_from_minio.sh
Download a File to Minio with Curl and Zero External Libraries or Programs
#!/usr/bin/env sh
# Example: ./download_minio.sh example.url.com username password bucket-name minio/path/to/file.txt.zst /download/path/to/file.txt.zst
if [ -z $1 ]; then
echo "You have NOT specified a MINIO URL!"
exit 1
fi
if [ -z $2 ]; then
@gadiener
gadiener / sni_tcpdump.sh
Last active March 8, 2021 17:01
SNI Client Hello Check with tcpdump
#!/bin/sh
tcpdump -i any -s 1500 '(tcp[((tcp[12:1] & 0xf0) >> 2)+5:1] = 0x01) and (tcp[((tcp[12:1] & 0xf0) >> 2):1] = 0x16)' -An
# sudo tcpdump dst port 9443 -A
@gadiener
gadiener / cluster_export.sh
Last active June 8, 2021 08:47
Script to get all the resources yaml file from the Kubernetes context
#!/bin/bash
# How to run: `./backup_cluster.sh | tee export-$(date +%s).log`
set -e
if [ -n "${DEBUG}" ]; then
set -x
fi
@gadiener
gadiener / tmux-iterm2.md
Created October 24, 2020 09:30 — forked from royling/tmux-iterm2.md
tmux in iTerm2 cheatsheet
@gadiener
gadiener / tmux-iterm2.md
Created October 24, 2020 09:30 — forked from royling/tmux-iterm2.md
tmux in iTerm2 cheatsheet
@gadiener
gadiener / echo.yaml
Created July 1, 2020 16:28
Echo service useful for troubleshooting
apiVersion: v1
kind: Service
metadata:
labels:
app: echo
name: echo
spec:
ports:
- port: 8080
name: high
@gadiener
gadiener / signal.go
Created May 26, 2020 17:34 — forked from reiki4040/signal.go
signal handling example for golang
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
@gadiener
gadiener / curl_request_url.sh
Last active January 10, 2020 19:02
Get http request info from curl command
#!/bin/bash
local template='lookup: %{time_namelookup}\nconnect: %{time_connect}\nappconnect: %{time_appconnect}\npretransfer: %{time_pretransfer}\nredirect: %{time_redirect}\nstarttransfer: %{time_starttransfer}\ntotal: %{time_total}\nhttp_code: %{http_code}\nnum_connects: %{num_connects}\nnum_redirects: %{num_redirects}\ntime_connect: %{time_connect}\ntime_namelookup: %{time_namelookup}\ntime_pretransfer: %{time_pretransfer}\ntime_starttransfer: %{time_starttransfer}\ntime_redirect: %{time_redirect}\ntime_total: %{time_total}\nsize_download: %{size_download}\nsize_upload: %{size_upload}\nspeed_download: %{speed_download}\nspeed_upload: %{speed_upload}'
curl -L --output /dev/null --silent --show-error --write-out "${template}" ${@}