Skip to content

Instantly share code, notes, and snippets.

View jcderr's full-sized avatar

Jeremy Derr jcderr

  • Amsterdam
View GitHub Profile
@jcderr
jcderr / wucfd
Created July 12, 2016 15:43
(W)ait (U)ntil (C)loud(F)ormation (D)one
#!/bin/zsh
autoload colors
if [[ "$terminfo[colors]" -gt 8 ]]; then
colors
fi
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval ${COLOR}='$fg_no_bold[${(L)COLOR}]'
@jcderr
jcderr / cloud-config
Created September 13, 2016 14:54
secured kubernetes cloud-config
#cloud-config
write-files:
- path: /opt/bin/wupiao
permissions: '0755'
content: |
#!/bin/bash
# [w]ait [u]ntil [p]ort [i]s [a]ctually [o]pen
[ -n "$1" ] && [ -n "$2" ] && while ! curl --output /dev/null \
--silent --head --fail \
http://${1}:${2}; do sleep 1 && echo -n .; done;
@jcderr
jcderr / k8scopy.sh
Last active January 26, 2021 18:34
Copy a Kubernetes Context
#!/bin/bash
FROM=$1
[[ -n "$FROM" ]] || exit 1
for ITEM in ns secrets configmaps rc deployments svc; do
for OBJ in $(kubectl --context=$FROM get $ITEM -o name); do
kubectl --context=$FROM get $OBJ -o yaml | kubectl create -f -
done
@jcderr
jcderr / devnull
Created June 7, 2017 19:59
K8S Deployment Dev-nuller
#!/bin/bash
# Usage: devnuller <deployment>
# When troubleshooting k8s deployments, it is sometimes helpful to set command: ["tail", "-f", "/dev/null"]
# so that you have a long-running null-command, allowing you to `kubectl exec ...` in and troubleshoot the
# environment. This will do that, and tell you how to roll back your command.
DEPLOYMENT="
P_REV=$(kubectl get deployment/${DEPLOYMENT} -o json | \
jq -r '.metadata.annotations["deployment.kubernetes.io/revision"]')