Skip to content

Instantly share code, notes, and snippets.

View eparis's full-sized avatar

Eric Paris eparis

  • Red Hat
  • Raleigh, NC
View GitHub Profile
@eparis
eparis / gist:ddbf2b41ad14f5e0d993
Created April 16, 2015 21:29
My thoughts on the kubernetes Mount() function
func doMount(source string, target string, fstype string, options []string) (string, error) {
// Build mount command as follows:
// mount [-t $fstype] [-o $options] [--source $source] --target $target
mountArgs := []string{}
if len(fstype) > 0 {
mountArgs = append(mountArgs, "-t", fstype)
}
if options != nil && len(options) > 0 {
mountArgs = append(mountArgs, "-o", strings.Join(options, ","))
}
@eparis
eparis / gist:183e866b1d85f408db6e
Created April 20, 2015 00:04
SchedulingDisabled Test
{
minion: api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo2"},
Spec: api.NodeSpec{Unschedulable: true},
Status: api.NodeStatus{Conditions: []api.NodeCondition{
{Type: api.NodeReady, Status: api.ConditionTrue},
{Type: api.NodeReady, Status: api.ConditionTrue}}},
},
status: "Ready,SchedulingDisabled",
},
# rm -rf /var/lib/kubelet/*
# docker run --rm -ti -v /var/lib/kubelet:/var/lib/kubelet fedora /bin/bash
bash-4.3# ls -l /var/lib/kubelet/
total 0

Outside of the container, on the host

# mkdir /var/lib/kubelet/subdir
// argsMinusFirstX removes only the first x from args. Otherwise, commands that look like
// openshift admin policy add-role-to-user admin my-user, lose the admin argument (arg[4]).
func argsMinusFirstX(args []string, x string) []string {
for i, y := range args {
if x == y {
return append(args[:i], args[i+1:]...)
}
}
return args
}
diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl
index 639d768..5f546db 100644
--- a/contrib/completions/bash/kubectl
+++ b/contrib/completions/bash/kubectl
@@ -157,14 +157,13 @@ __handle_word()
}
# call kubectl get $1,
-# use the first column in compgen
-# we could use templates, but then would need a template per resource
@eparis
eparis / gist:e5a445964ce8a54996e9
Last active September 2, 2015 16:12
Kubernetes - who wrote

gitdm (git data mine) is a tool written by Jonathan Corbet at LWN which he uses to do his 'who wrote the kernel' articles. I spent a couple of minutes (ended up being a couple of hours hacking on gitcm) to run it against kube.

I explicitly ignore merge commits and generated filed (Sorry Patrick Reilly, you had the some huge generated files).

My list of files/dirs I'm ignoring:

@eparis
eparis / gist:3a7488e5aa5acf3fedbe
Last active August 29, 2015 14:21
Openshift - Who Wrote
Ignore filter on "(Godeps|third_party|api/swagger-spec|pkg/ui/datafile.go|www/.*/shared/assets/sampleData1.json|pkg/assets/bindata.go)"
Grabbing changesets...done       
Processed 1692 csets from 73 developers
3 employers found
A total of 240876 lines added, 105802 removed (delta 135074)

Developers with the most changesets

@eparis
eparis / gist:f8b3005671e06547665a
Last active August 29, 2015 14:21
Docker - who wrote

Corp Contributors to Docker

I'm ignoring all merge commits and I'm ignoring all files that match the following regex. This cuts out huge numbers of automatically generated files which hugely skew results.

Ignore filter on "(Godeps|third_party|vendor|docs/theme|.svg|api/swagger-spec|pkg/ui/datafile.go|www/.*/shared/assets/sampleData1.json|pkg/assets/bindata.go)"

Top changeset contributors by employer

(Unknown)                 4520 (47.9%)
"Docker"                  3821 (40.5%)
# etcdctl get /coreos.com/network/config
{"Network": "4.0.0.0/8", "SubnetLen": 24, "Backend": {"Type": "vxlan"}}
# etcdctl ls /coreos.com/network/subnets
server:
flanneld --etcd-endpoints="http://127.0.0.1:4001" --listen=":8081"
client1:
flanneld --remote="10.12.6.179:8081"
@eparis
eparis / gist:2380a2daa7ff6c0b52a6
Created June 1, 2015 17:18
etcdctl bash completions
#!/bin/bash
__debug()
{
if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
fi
}