Skip to content

Instantly share code, notes, and snippets.

View epcim's full-sized avatar

Petr Michalec epcim

View GitHub Profile
@epcim
epcim / keybase.md
Created March 24, 2020 07:05 — forked from webframp/keybase.md
Signing git commits on github using keybase.io gpg key

Probably one of the easiest things you'll ever do with gpg

Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH

First get the public key

keybase pgp export | gpg --import

Next get the private key

@epcim
epcim / az.md
Last active February 19, 2020 16:11
Azure az queries

Interesting Ops queris for Azure / AKS

Account, Subscription

az account list --query '[*].{Name:name}' --output table

Resource groups

List:

@epcim
epcim / indexer
Last active February 13, 2020 16:13
udev rules ordered interface
#!/bin/sh
#if [ $# -lt 1 ]; then
# echo "Usage: $0 prefix [initial] [database/file] " >&2
# exit 1
#fi
key="${1:-"eth"}"
initial="${2:-0}"
datfile="${3:-/run/indexerdb_$key}"
@epcim
epcim / k8s_job_replay.sh
Last active January 7, 2020 12:14
kubernetes job
kubectl get job -n sre kibana-config -o json | jq 'del(.spec.selector)' | jq 'del(.spec.template.metadata.labels)' | kubectl replace --force -f -
@epcim
epcim / kubernetes_pods_docker_disk_usage.md
Last active February 20, 2025 20:07
docker disk space introspection kubernetes docker overlay

identify big pods/containers

investigage big files

DST=/mnt
find /var/lib -type f -size +1G -exec ls -lh {} \; | tee  $DST/bigfiles_var_lib_$(date "+%H%M").log
find /var/lib -type f -size +1G -exec ls -lh {} \; | awk '{ print $5 ": " $9 }' | sort -rh > $DST/bigfiles_var_lib_$(date "+%H%M").sorted.log

misbehave processes

@epcim
epcim / hab clustered etcd
Created September 16, 2019 08:58
etcd habitat docker-compose hab
# See more: https://gist.github.com/epcim/80d2dda18e2b3022e4ab07f161f59823
# hab clustered etcd
## compose
cat <<EOF > docker-compose.yml
version: '3'
services:
etcd1:
@epcim
epcim / wait_for_http_200.sh
Created August 26, 2019 09:53 — forked from rgl/wait_for_http_200.sh
Wait for an HTTP endpoint to return 200 OK with Bash and curl
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
@epcim
epcim / needle.sh
Last active June 18, 2019 20:05
split needle csplit
# example usage: to split yaml with multiple documents
needle() {
SUFFIX=${1##*.}
NEEDLE=${2:----}
csplit -b "%03d.$SUFFIX" -zsf $(basename $1 .$SUFFIX) $1 /$NEEDLE/+1 {*}
}
needle vega-objects.yaml
#!/bin/env python3
import gitlab
import sys
# private token or personal token authentication
gl = gitlab.Gitlab('https://gitlab.com/', private_token='******')
if len(sys.argv) > 1:
if sys.argv[1].find("/") > 0:
@epcim
epcim / habitat_systemd.md
Last active September 16, 2019 08:56
hab habitat hab-sup deployment etcd

Simple deployment script to install habitat container with the app as systemd service.

export ALT=500 # Prefix for all the service names/ports used (apply to habitat/ inner service service)
# cleanup
systemctl stop etcd-$ALT
sleep 3
rm -f /etc/systemd/system/etcd-$ALT.service /etc/default/etcd-$ALT*
rm -rf /srv/etcd-$ALT