View keybase.md

Keybase proof

I hereby claim:

  • I am ajohnstone on github.
  • I am ajohnstone (https://keybase.io/ajohnstone) on keybase.
  • I have a public key whose fingerprint is 3657 5228 12EA F1FF 9A2E B738 1B09 88E9 DD22 D552

To claim this, I am signing this object:

View get-elb-usage.sh
START="$(date +'%Y-%m-%dT%H:%M:%S' --date '-5 minutes')";
END="$(date +'%Y-%m-%dT%H:%M:%S')";
aws elb describe-load-balancers | jq -r '.LoadBalancerDescriptions[].LoadBalancerName' | while read LB; do
DATA=$(aws cloudwatch get-metric-statistics \
--namespace AWS/ELB \
--metric-name "RequestCount" \
--dimensions '[{"Name":"LoadBalancerName","Value":"'$LB'"}]' \
--start-time "$START" \
--end-time "$END" \
--period 60 \
View gist:232ed3d51a69128e79c295e96ee71042

The kubernetes cluster has nodes of m3.medium and only have a emphemeral storage capacity of 4gb.

This is easily utilized, and therefore need to increase the total size.

I've allocated the following so technically the LVM group could utilise the following. However its unclear how to automatically get it to expand the volume.

export MASTER_DISK_TYPE='gp2';
export MASTER_DISK_SIZE=250
View gist:d10a17e51ca808ca82733f8f307de297
function kubernetes::deployment::wait {
deployment=$1
ns=${2:-'default'};
k_cmd="kubectl --namespace=$ns get deployments $deployment";
while true; do
observed=$($k_cmd -o 'jsonpath={.status.observedGeneration}');
generated=$($k_cmd -o 'jsonpath={.metadata.Generation}');
[ "$?" -ne 0 ] && break;
[ "${observed}" -ge "${generated}" ] && {
updated_replicas=$($k_cmd -o 'jsonpath={.status.updatedReplicas}');
View ingress-pod
$ kubectl exec --tty -i nginx-ingress-controller-9xccu -- ls -alh --color
total 6.2M
drwxr-xr-x 46 root root 4.0K May 1 12:47 .
drwxr-xr-x 46 root root 4.0K May 1 12:47 ..
-rwxr-xr-x 1 root root 0 May 1 12:46 .dockerenv
-rwxr-xr-x 1 root root 0 May 1 12:46 .dockerinit
drwxr-xr-x 2 root root 4.0K Apr 28 00:50 bin
drwxr-xr-x 2 root root 4.0K Nov 27 13:59 boot
drwxr-xr-x 5 root root 380 May 1 12:46 dev
drwxr-xr-x 45 root root 4.0K May 1 12:46 etc
View example.py
import boto3
r53_client = boto3.client('route53')
hosted_zone = 'alias.photobox.com.'
def lambda_handler(event = {}, context = {}):
aws_region = event['detail']['awsRegion']
elb_client = boto3.client('elb', region_name=aws_region)
View index.js
'use strict';
console.log('Loading event');
var logGroupName = 'vpc-flow-logs',
region = 'eu-west-1';
var AWS = require('aws-sdk'),
Promise = require('bluebird'),
async = require('async'),
View create-elbs.sh
ELBS="`aws elb describe-load-balancers`";
echo "$ELBS" | jq -c '.LoadBalancerDescriptions[] | select(.LoadBalancerName|contains("production-services"))' | tr -d '^J' | while read line; do
NAME=$(echo $line | jq -r '.LoadBalancerName')
echo $NAME | grep tmp$ && continue;
LISTENERS=$(echo $line | jq -c '.ListenerDescriptions[].Listener'| tr -d '^J' | tr '\n' ',' | sed 's/^/\[/g;s/,$/]/g');
SCHEME=$(echo $line | jq -r '.Scheme')
aws elb create-load-balancer --load-balancer-name "${NAME}tmp" --listeners "${LISTENERS}" --scheme "${SCHEME}" --security-groups sg-3c7df658 --subnets subnet-f598ee9d
done;
View event.json
{
"Records": [
{
"awsRegion": "eu-west-1",
"eventID": "0ed50878-9f42-4e73-a361-2d19ee0a61d7",
"eventName": "LookupEvents",
"eventSource": "cloudtrail.amazonaws.com",
"eventTime": "2015-11-22T12:26:22Z",
"eventType": "AwsApiCall",
"eventVersion": "1.04",
View update-elb-policy.sh
#!/usr/bin/env bash
UPDATE_ELB_POLICY=${UPDATE_ELB_POLICY:-0};
TMPFILE=`mktemp -t example.XXXXXXXXXX` && {
printf "Region|Status|Current security policy|Expected security policy|ELB|Action\n" >> "${TMPFILE}";
aws ec2 describe-regions |awk -F'"' '/RegionName/ {print $4}' | while read region; do
LATEST_PREDEFINED_SECURITY_GROUP=$(aws --region=$region elb describe-load-balancer-policies | grep -i PolicyName | awk -F '"' '{print $4}' | head -n1 | sed 's/[ \r\n]//g');