Skip to content

Instantly share code, notes, and snippets.

Jonathan Kosgei jonathan-kosgei

Block or report user

Report or block jonathan-kosgei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jonathan-kosgei / Vagrantfile
Created Jul 19, 2017
Kubernetes Vagrant Setup
View Vagrantfile
$script = <<SCRIPT
# Install docker
curl -fsSL | sh
# Install kubectl
curl -LO$(curl -s
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
# Install kubeadm
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
jonathan-kosgei /
Last active Jul 15, 2017
Delete all images in order of dependency excluding selected base images for faster builds
function list_include_item { local list="$1"; local item="$2"; if [[ $list =~ (^|[[:space:]])"$item"($|[[:space:]]) ]] ; then result=0; else result=1; fi; return $result;};
bases="alpine:latest nginx:1.11.3-alpine"
# append latest tag to each image
for item in $(docker images --format "{{.Repository}}:{{.Tag}}@{{.ID}}")
export IFS=' '
IFS='@'; arr=($item); unset IFS;
jonathan-kosgei /
Last active Jul 12, 2017
Clear all images on a Docker host except base images
# set variable with base image names
# get base image ids and set in other list
#base_image_names="alpine linux"
#ids=`docker images --no-trunc -q $(base_image_names)`
bases="sha256:7328f6f8b41890597575cbaadc884e7386ae0acc53b747401ebce5cf0d624560 sha256:33aa78cbda15ae84375c46dfc3fc07560c9af8e7b8f37745d2c6542e2affec9f"
docker images -q --no-trunc > $all_images
jonathan-kosgei / thirdpartypaths.json
Created May 3, 2017
Kubernetes Third Party Path json
View thirdpartypaths.json
"/apis/{fqdn}/v1/{resource}": {
"get": {
"security": [
"Bearer": [
View Dockerfile
FROM debian:jessie
MAINTAINER a.mulholland
RUN apt-get update && apt-get upgrade -y &&\
curl -sS | apt-key add - &&\
echo "deb stable main" | tee /etc/apt/sources.list.d/yarn.list &&\
curl -sL | bash -
apt-get install -y nodejs yarn nginx php5-fpm php5-mysqlnd php5-curl php5-mcrypt php5-gd git curl mysql-client openssh-client
RUN curl -sS | php -- --install-dir=/usr/local/bin --filename=composer
jonathan-kosgei /
Created Apr 19, 2017
AWS Lambda backup EBS volumes with BOTO3
# Scheduling the above script hourly. Ensure you're properly authenticated via aws configure.
aws lambda create-function --function-name ebs-backup-worker \
--runtime python2.7 \
--role "arn for your lambda user's role" \
--handler lambda_handler \
--zip-file fileb:///
""" Make sure to create the "backup" tag on the volumes you want to backup.
For authentication, setup the aws policy and user as specified in the snapshot-trust.json and snapshot-policy.json
Inspired by:
from time import gmtime, strftime
import boto3
region = "us-west-2"
backup_tag = "backup"
jonathan-kosgei /
Last active Mar 5, 2017
Find largest number in nested number list Python
def max_in_nested_number_list(numbers):
largest = 0
for item in numbers:
if isinstance(item, list):
largest = item if item>largest else largest
return largest
jonathan-kosgei /
Created Feb 25, 2017
Command to get internal ip programmatically
# From this askubuntu question
ip route get | awk '{print $NF; exit}'
jonathan-kosgei /
Last active Mar 3, 2017
Installing Calico for Docker Networking
# Setup Calico for Docker on Ubuntu 16.04
# Change to the internal ip of your node
NODE_IP=ip route get | awk '{print $NF; exit}'
# Install docker
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
You can’t perform that action at this time.