Skip to content

Instantly share code, notes, and snippets.

@grrywlsn
grrywlsn / gist:250cdfa3d1233e3e8404744d345c98db
Created April 22, 2020 10:50
Delete all AWS backups from a vault
#!/bin/bash
while [[ backup ]] ; do
backup=`aws backup list-recovery-points-by-backup-vault --backup-vault-name @@@@ --max-results 1 | jq -r ".RecoveryPoints[].RecoveryPointArn"`
echo "Deleting $backup..."
`aws backup delete-recovery-point --backup-vault-name @@@@ --recovery-point-arn $backup`
done
@grrywlsn
grrywlsn / gist:5895e14049d05edc049294ba6d89d80e
Created December 10, 2018 10:54
Get the name and version of every deployment in a namespace
kubectl get deployment -n production -o wide | awk '{n=split($8,A,":"); print $1 " " A[n]}'
@grrywlsn
grrywlsn / k8switch
Created December 13, 2017 12:17
k8switch
#!/bin/bash
cp ~/.kube/$1-admin.kubeconfig ~/.kube/config
@grrywlsn
grrywlsn / gist:6e3fb1760db99275f0010dfa86d35fff
Last active October 12, 2017 09:00
Cycle through worker nodes to terminate and renew instances
#!/bin/bash
set -e
# set -x
RED='\033[0;31m'
BLUE='\033[0;34m'
GREEN='\033[1;32m'
NC='\033[0m' # No Color
@grrywlsn
grrywlsn / AWS instance price from jq
Last active September 25, 2017 13:40
jq to grab AWS instance hourly cost
curl --silent "http://www.ec2instances.info/instances.json" | jq '.[] | select(.instance_type=="r4.large").pricing["eu-west-1"].linux.ondemand'
@grrywlsn
grrywlsn / cycle-nodes
Created July 3, 2017 12:52
cycle-nodes
#!/bin/bash
set -e
# set -x
RED='\033[0;31m'
BLUE='\033[0;34m'
GREEN='\033[1;32m'
NC='\033[0m' # No Color

Keybase proof

I hereby claim:

  • I am grrywlsn on github.
  • I am grrywlsn (https://keybase.io/grrywlsn) on keybase.
  • I have a public key whose fingerprint is F071 EAF0 7A28 DBF2 CE0E C5B9 2864 5287 6A69 2EDF

To claim this, I am signing this object:

@grrywlsn
grrywlsn / coreos-efs-zone-aware
Created October 27, 2016 21:42
Mounting EFS to CoreOS instances with the matching zone DNS endpoint automatically
#cloud-config
write_files:
- path: /etc/conf.d/nfs
permissions: '0644'
content: |
OPTS_RPC_MOUNTD=""
coreos:
units:
- name: rpc-statd.service
command: start
@grrywlsn
grrywlsn / etcd2-cluster-master
Created September 29, 2016 16:24
AWS user-data cloud-config for autoscaling etcd2 masters
coreos:
flannel:
interface: $private_ipv4
etcd_endpoints: http://127.0.0.1:2379
etcd2:
advertise-client-urls: http://$private_ipv4:2379
initial-advertise-peer-urls: http://$private_ipv4:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://$private_ipv4:2380
units:
@grrywlsn
grrywlsn / local.yml
Created July 6, 2016 00:00
local.yml to set up a new image on first Ansible-Pull
---
- hosts: localhost
tasks:
- name: get ec2 facts
action: ec2_facts
- name: list tags on an instance
ec2_tag:
region: "{{ ansible_ec2_placement_region }}"
resource: "{{ ansible_ec2_instance_id }}"