Skip to content

Instantly share code, notes, and snippets.

@timoyuen
timoyuen / save-load-docker-images.sh
Created March 16, 2018 09:44 — forked from mmrko/save-load-docker-images.sh
Script to (selectively) save/load multiple Docker images
#!/usr/bin/env bash
# Script to (selectively) save/load multiple Docker images to/from a directory.
# Run ./save-load-docker-images.sh for help.
set -e
directory=$PWD
filter=""
compress=0
@timoyuen
timoyuen / kube-registry.yaml
Created March 19, 2018 09:41 — forked from coco98/kube-registry.yaml
Docker registry on minikube
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
@timoyuen
timoyuen / start_docker_registry.bash
Created March 19, 2018 23:45 — forked from PieterScheffers/start_docker_registry.bash
Start docker registry with letsencrypt certificates (Linux Ubuntu)
#!/usr/bin/env bash
# install docker
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
# install docker-compose
# https://docs.docker.com/compose/install/
# install letsencrypt
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
@timoyuen
timoyuen / latency.txt
Created March 25, 2018 14:20 — forked from mikea/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 4x mutex op, 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
@timoyuen
timoyuen / coredns.yaml
Created March 26, 2018 14:22 — forked from rothgar/coredns.yaml
CoreDNS for Kubernetes
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
log stdout
health
$ kubectl create configmap cloud-xml --from-file=cloud.xml
configmap "cloud-xml" created
@timoyuen
timoyuen / onchange.sh
Created March 27, 2018 13:41 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
 mc admin heal --force --remove --recursive --advanced --fake ALIAS[/Bucket/Prefix]

format.json is always healed.

Healing of a bucket implies:

  • if a "bucket" does not exist on any of the drives then it gets created there.
  • all bucket meta files are healed (like policy.json)
package main
import (
"fmt"
"log"
"os"
"path"
"runtime"
"strings"
"syscall"
@timoyuen
timoyuen / refresh.sh
Created May 7, 2018 00:36 — forked from jmound/refresh.sh
Bash function to refresh all pods in all deployments by namespace
# based on the "patch deployment" strategy in this comment:
# https://github.com/kubernetes/kubernetes/issues/13488#issuecomment-372532659
# requires jq
# $1 is a valid namespace
function refresh-all-pods() {
echo
DEPLOYMENT_LIST=$(kubectl -n $1 get deployment -o json|jq -r .items[].metadata.name)
green "Refreshing pods in all Deployments"
for deployment_name in $DEPLOYMENT_LIST ; do