Skip to content

Instantly share code, notes, and snippets.

@jonathan-kosgei
jonathan-kosgei / internal_ip.sh
Created February 25, 2017 10:50
Command to get internal ip programmatically
# From this askubuntu question http://askubuntu.com/a/604691/280044
ip route get 8.8.8.8 | awk '{print $NF; exit}'

I've been an aggressive Kubernetes evangelist over the last few years. It has been the hammer with which I have approached almost all my deployments, and the one tool I have mentioned (shoved down clients throats) in almost all my foremost communications with clients, and it was my go to choice when I was mocking my first startup (saharacluster.com).

A few weeks ago Docker 1.13 was released and I was tasked with replicating a client's Kubernetes deployment on Swarm, more specifically testing running compose on Swarm.

And it was a dream!

All our apps were already dockerised and all I had to do was make a few modificatons to an existing compose file that I had used for testing before prior said deployment on Kubernetes.

And, with the ease with which I was able to expose our endpoints, manage volumes, handle networking, deploy and tear down the setup. I in all honesty see no reason to not use Swarm. Or any mission-critical feature, or incredibly convenient really nice to have feature in Kubernetes that I'm

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: mongo
spec:
serviceName: mongo
template:
metadata:
labels:
name: mongo
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mongo-data-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv0001
labels:
name: pv0001
type: local
spec:
capacity:
storage: 5Gi
>>> list2
[5, 5, 5, 5, 5, 4, 4, 2, 1]
>>> def insertion_sort(list2):
... for index in range(1,len(list2)):
... position=index
... currentvalue=list2[index]
... while position>0 and currentvalue<list2[position-1]:
... list2[position]=list2[position-1]
... list2[position-1]=currentvalue
... position-=1
@jonathan-kosgei
jonathan-kosgei / post-receive
Last active September 1, 2016 20:26 — forked from lemiorhan/post-receive
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="production"
working_tree="PATH_TO_DEPLOY"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then
FROM jkosgei/php-nginx:v1
MAINTAINER Jonathan Kosgei <jonathankosgei1000@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
RUN wget http://wordpress.org/latest.tar.gz
RUN tar xzvf latest.tar.gz;\
rsync -avP wordpress/ /var/www/html/ ;\
@jonathan-kosgei
jonathan-kosgei / terraform-bestpractices
Created June 21, 2016 18:08
Terraform Best Practices
Managing Multiple Environments
Terraform in Atlas makes it easy to reuse configurations and manage multiple environments. Common configurations should be written as modules, and then referenced in the main Terraform file for each environment. For example, the usual tree for managing multiple environments is:
- prod
- main.tf
- .terraform
- terraform.tfstate
- prod.tfvars
- qa