Skip to content

Instantly share code, notes, and snippets.

I have 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. No mission-critical feature, or incredibly convenient really nice to have feature in Kubernetes that I'm go

@jonathan-kosgei
jonathan-kosgei / timer.py
Last active June 14, 2021 05:01
Python Decorator to Time a Function
""" A simple decorator that times the duration of a function's execution. More info on Decorators at https://pythonconquerstheuniverse.wordpress.com/2009/08/06/introduction-to-python-decorators-part-1/"""
import timeit
def timer(function):
def new_function():
start_time = timeit.default_timer()
function()
elapsed = timeit.default_timer() - start_time
print('Function "{name}" took {time} seconds to complete.'.format(name=function.__name__, time=elapsed))
return new_function()
@jonathan-kosgei
jonathan-kosgei / README.md
Last active December 19, 2018 17:28
Deploy PHP site to AWS Elasticbeanstalk with Bitbucket Pipelines

ElasticBeanstalk on AWS

Getting Started

To deploy a new Magento store automatically via Bitbucket CI. Follow the following steps.

1. Set the following environment variables for the bitbucket repo with the magento store source code

AWS_ACCESS_KEY_ID=
@jonathan-kosgei
jonathan-kosgei / python-object-size.py
Created April 13, 2018 16:39
Get the size of any object in Python
import sys
def get_size(obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
obj_id = id(obj)
if obj_id in seen:
return 0
@jonathan-kosgei
jonathan-kosgei / schedule_function.sh
Created April 19, 2017 03:52
AWS Lambda backup EBS volumes with BOTO3
# Scheduling the above script hourly. Ensure you're properly authenticated via aws configure.
#!/bin/bash
zip ebs-backup-worker.zip .schedule-ebs-snapshot-backups.py
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:///ebs-backup-worker.zip

Keybase proof

I hereby claim:

  • I am jonathan-kosgei on github.
  • I am jkosgei (https://keybase.io/jkosgei) on keybase.
  • I have a public key whose fingerprint is 4A3A EC85 E348 E5A8 4FD5 E82B 1C9F 43F8 656B 81FF

To claim this, I am signing this object:

@jonathan-kosgei
jonathan-kosgei / pypi.md
Created October 25, 2017 09:00
deploying to pypi
git push origin master
git tag 1.3 -m "desc"
git push --tags origin master
python setup.py sdist upload
@jonathan-kosgei
jonathan-kosgei / stats.txt
Created September 8, 2017 14:41
API Stats for ipdata.co
./hey -m GET -n 1000000 https://ipdata.co -more
Summary:
Total: 476.9207 secs
Slowest: 5.0308 secs
Fastest: 0.0010 secs
Average: 0.0225 secs
Requests/sec: 2096.7846
Total data: 315238010 bytes
Size/request: 315 bytes
ERROR: extension "pgcrypto" already exists
Buildfile: /opt/dspace/dspace/target/dspace-installer/build.xml
init_installation:
[mkdir] Created dir: /dspace/bin
[mkdir] Created dir: /dspace/config
[mkdir] Created dir: /dspace/lib
[mkdir] Created dir: /dspace/etc
[mkdir] Created dir: /dspace/webapps
[mkdir] Created dir: /dspace/triplestore

Getting Started

kubectl apply -f storageclass.yml
kubectl apply -f neo4j-service.yml
kubectl apply -f neo4j-statefulset.yml