Skip to content

Instantly share code, notes, and snippets.

@smreed
smreed / Kubernetes REST client configuration fallback.md
Last active April 20, 2016 18:31
Go code that will connect to a production Kubernetes API if run in cluster, or to the whichever cluster you have `kubectl` configured to hit.

I find myself writing this a lot for code that I want to work in production, but also in a development environment.

This has been tested on k8s 1.2.2.

You must have the correct version of github.com/imdario/mergo vendored. Look at k8s.io/kubernetes/Godeps/Godeps.json to see which commit is used by Kubernetes.

TODO: add the vendor/manifest file that gb could use to restore vendored dependencies, since minimizing that just to get the code below to work is a monumental effort as well.

@smreed
smreed / main.go
Created October 28, 2015 21:57
reproduce goroutine leak in bigtable/client+grpc
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"runtime"
"time"
Note that the PD is mounted in two locations.
$ df -h | grep redis
/dev/disk/by-id/google-redis-3-storage 493G 11G 457G 3% /var/lib/kubelet/global/pd/rw/redis-3-storage
/dev/disk/by-id/google-redis-3-storage 493G 11G 457G 3% /var/lib/kubelet/redis-3/volumes/gce-pd/redis-master-storage
@smreed
smreed / docker ps -a
Last active August 29, 2015 14:13
cadvisor problem on k8s 0.8.0
sreed@kubernetes-minion-4:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f01f5894d23 kubernetes/pause:go "/pause" 2 seconds ago k8s_net.1509ae25_cadvisor-agent.default.file_cadvisormanifes12uqn2ohido76855gdecd9roadm7l0_3af445a9
46b0e8b9a850 kubernetes/pause:go "/pause" 12 seconds ago k8s_net.1509ae25_cadvisor-agent.default.file_cadvisormanifes12uqn2ohido76855gdecd9roadm7l0_a1ca4847
7a22f825d2f8 kubernetes/pause:go "/pause" 22 seconds ago k8s_n
@smreed
smreed / start-local-registry.sh
Last active February 27, 2016 18:16
Shell script that starts up a local docker registry with a Google Cloud Storage backend using local credentials.
#!/bin/bash
LOCAL_REGISTRY_NAME=local-docker-registry
GCS_BUCKET=some-bucket
CONFIG_DIR=$HOME/.config
LOCAL_REGISTRY_ID=`docker ps -q $LOCAL_REGISTRY_NAME`
if [ ! -z "$LOCAL_REGISTRY_ID" ]; then
@smreed
smreed / nsqadmin-service.json
Last active August 29, 2015 14:10 — forked from bketelsen/nsqadmin-service.json
This gist represents all the manifests you'll need to run a redundant and fault-tolerant NSQ cluster on Kubernetes. NSQ Admin's http interface is available on port 14171 on any node. There's an issue with NSQ Admin if you're running more than one lookupd service, so I recommend running just one lookupd until I figure it out.
{
"id": "nsqadmin-http",
"kind": "Service",
"apiVersion": "v1beta1",
"containerPort": 4171,
"port": 14171,
"protocol": "TCP",
"selector": { "name": "nsqadmin" },
"createExternalLoadBalancer": true
}
require 'rubygems'
require 'sinatra'
get '/' do
"Hello from Sinatra running on Java!"
end
export MAVEN_OPTS="-server -Xmx1g -Xms64m"
export SVN_EDITOR="mate -w"
export HISTCONTROL=erasedups
export HISTSIZE=10000
shopt -s histappend
# git status with a dirty flag
function __git_status_flag {
git_status="$(git status 2> /dev/null)"
remote_pattern="^# Your branch is (.*) of"