Skip to content

Instantly share code, notes, and snippets.

@zombar
zombar / tunnelmesh-tests.json
Last active March 11, 2026 22:11
Tunnelmesh Test Count
{"schemaVersion":1,"label":"tests","message":"1745","color":"brightgreen"}
@zombar
zombar / cordon.sh
Last active August 2, 2024 18:02
Drain and cordon all nodes of a type
set -e
label_match="spotinst.io/node-lifecycle in (spot,od)"
# kubectl function wrappers
function drain_and_cordon {
kubectl drain $1 --delete-emptydir-data --ignore-daemonsets --force
}
function list_nodes {
@zombar
zombar / restart.sh
Last active July 28, 2024 14:43
Restarts all Kubernetes workloads older than `skipWithinHours`
set -eo pipefail
touch done_namespace.tmp
skipWithinHours="${1:-48}"
workloadTypes=("ds" "deploy" "sts")
excludedNamespaces=("kube-system" "istio-system")
doneNamespaces=$(cat done_namespace.tmp)
podUpdateStrategyRegex="RollingUpdate"
podRolloutSleepTime=60
namespaces=$(kubectl get ns -o json | jq -r '.items[].metadata.name')
@zombar
zombar / lifecycle.sh
Created November 7, 2023 09:44
GCP machine lifecycle management script
#!/bin/sh
show_help() {
cat << EOF
Usage:
${0##*/} help
${0##*/} list
${0##*/} images
${0##*/} password
@zombar
zombar / import_ips.sh
Last active June 22, 2024 08:07
Some bash that eases a Terraform import task, makes use of env vars and awk
list=$(gcloud compute instances list --filter='tags.items=redis' --format="value(name,networkInterfaces[0].networkIP,networkInterfaces[0].subnetwork)")
IFS='
'
for entry in $list
do
# set some convenience vars
name=$(echo $entry | awk '{ print $1 }')
ip=$(echo $entry | awk '{ print $2 }')
region=$(echo $entry | gawk 'match($0, /regions\/(.+)\/subnetworks/, arr) { print arr[1] }')
@zombar
zombar / gist:856d9479537606d28833f8667a3e446b
Created December 2, 2022 11:41
Some disk space troubleshooting commands relating to ubuntu packages
# List kernel image and header package
sudo dpkg --list | egrep 'linux-image|linux-headers'
# Get the sizes of the kernel images
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | egrep 'linux-image|linux-headers' | sort -n
# Get list of package by size
@zombar
zombar / prometheus.yaml
Last active December 2, 2022 10:00
Sensible and readable Promethues configuration for Kubernetes monitoring (prometheus.yaml,prometheus.yml)
global:
scrape_interval: 60s
external_labels:
monitor: "prometheus"
cluster: monitoring-cluster
scrape_configs:
# Scrape volume stats from the Kubelet proxy at /metrics
- job_name: "kubernetes-kubelet"
kubernetes_sd_configs: