This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"]') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}]' | |
eval BOLD_${COLOR}='$fg_bold[${(L)COLOR}]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include /etc/nginx/conf.d/upstreams/*.conf; | |
server { | |
listen 8080; | |
resolver 10.99.254.254; | |
server_name ~^(?<svc>[a-zA-Z0-9]+)(?<env>[\-a-zA-Z0-9]*)\..*\.com$; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
URL=$1 | |
CODE="200" | |
[[ -n "$URL" ]] || { echo "Please specify a URL to watch"; exit 1; } | |
[[ -n "$2" ]] && CODE=$2 | |
while true; do | |
STATUS=$(curl -o /dev/null --insecure --silent --head --write-out '%{http_code}' ${URL}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: wupiao [ip] [port] | |
# inspired by script of same name from Kubernetes project | |
# we're going to test any port, though, not just HTTP | |
[ -n "$1" ] && [ -n "$2" ] && while ! nc -z $1 $2; do sleep 1 && echo -n .; done; | |
exit $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Kubernetes API Server | |
Documentation=https://github.com/GoogleCloudPlatform/kubernetes | |
Requires=setup-network-environment.service etcd2.service generate-serviceaccount-key.service | |
After=setup-network-environment.service etcd2.service generate-serviceaccount-key.service | |
[Service] | |
EnvironmentFile=/etc/network-environment | |
ExecStartPre=-/usr/bin/mkdir -p /opt/bin | |
ExecStartPre=-/usr/bin/mv /opt/bin/kube-apiserver /opt/bin/kube-apiserver.backup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GATEWAY=$(ifconfig | grep 192.168 | grep "\-\->" | awk '{ print $2 }') | |
sudo /sbin/route add -net 10.0.0.0 -netmask 255.0.0.0 -gateway $GATEWAY |
NewerOlder