Skip to content

Instantly share code, notes, and snippets.

View ianblenke's full-sized avatar
🎯
Focusing

Ian Blenke ianblenke

🎯
Focusing
View GitHub Profile
@ianblenke
ianblenke / deis-backup.sh
Created January 18, 2015 05:43
Script for backing up deis ceph buckets to S3
#!/bin/bash
# File: deis-backup.sh
# Author: Ian Blenke
# License: Apache License, Version 2.0
#
# Note: This script is meant to be run under CoreOS "toolbox", as it uses the /media mount and talks locally to etcd to obtain Deis ceph credentials.
# Error out whenever something returns a non-zero errno
set -eo pipefail
@ianblenke
ianblenke / blackhole.sh
Last active August 29, 2015 14:13
A braindead simple bash script for systemd hosts that uses etcd to track whitelisted and blacklisted IPs before running: ip route add blacklist $ip
#!/bin/bash
set -eo pipefail
case $1 in
stop)
if [ ! -f /var/run/blackhole.pid ] ; then
echo "Lack of /var/run/blackhole.pid means there is nothing to stop" 1>&2
exit 1
fi
kill $(cat /var/run/blackhole.pid)
@ianblenke
ianblenke / blackhole.cloud-init
Last active August 29, 2015 14:13
sudo coreos-cloudinit --from-file=blackhole.cloud-init
#cloud-config
coreos:
units:
- name: blackhole-create-fleet-units.service
command: start
content: |
[Unit]
After=docker.service
ConditionFileIsExecutable=/srv/blackhole-create-fleet-units.sh
ConditionFileNotEmpty=/srv/[email protected]
@ianblenke
ianblenke / ntp.cloud-init
Created January 21, 2015 23:48
An NTP cloud-init for coreos
#cloud-config
coreos:
units:
- name: settimezone.service
command: start
content: |
[Unit]
Description=Set the timezone
@ianblenke
ianblenke / docker-machine_vmware.sh
Last active September 16, 2015 17:25
Steps needed to run docker-machine with vmwarefusion
#!/bin/bash
BUCKET=$(whoami)-docker-machine
# Build a boot2docker.iso for vmware (optional)
# git clone https://github.com/ianblenke/boot2docker
# cd boot2docker
# docker build -t boot2docker . && docker run --rm boot2docker > boot2docker.iso
# aws s3 cp boot2docker.iso s3://$BUCKET/boot2docker.iso --acl 'public-read'
# URL=https://s3.amazonaws.com/$BUCKET/boot2docker.iso
@ianblenke
ianblenke / docker-machine.sh
Last active August 29, 2015 14:14
Preparing the DOCKER environment variables for fig to use, as pulled from a docker-machine config
if which docker-machine > /dev/null 2>&1; then
export DOCKER_HOST=""
alias d="docker $(docker-machine config $(docker-machine ls -q | head -1))"
declare -a lines=( $(docker-machine config $(docker-machine ls -q | head -1)) )
for (( i = 0; i < ${#lines[*]}; ++ i )) ; do
line="${lines[$i]}"
if [ "$line" = "--tls" ]; then
export DOCKER_TLS_VERIFY=true
@ianblenke
ianblenke / sinatra-docker.sh
Last active August 29, 2015 14:14
A quick and dirty sinatra project docker demo
#!/bin/bash
# A quick and dirty sinatra project docker demo
mkdir projects
cd projects
gem install hazel
hazel my_app
cd my_app
bundle pack
bundle install --path vendor/bundle --local
@ianblenke
ianblenke / add-xfleet-conflicts.sh
Last active August 29, 2015 14:14
Add an X-Fleet Conflicts to all deis deployed units
#!/bin/bash -e
fleetctl list-units -fields=unit -no-legend | grep -v -e '@\|deis' | cut -d. -f1-2 | sort | uniq | while read name ; do
max=$(fleetctl list-machines -no-legend | wc -l)
count=$(fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | wc -l)
if [ $count -gt $max ]; then
echo "Skipping $name, there are $count deployed units on $max fleet machines"
else
echo "Processing $name"
fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | while read service; do
others=$(echo $service | cut -d. -f1-2)
sudo bash -c 'mkdir -p /etc/systemd/system/docker.service.d/; cat <<EOF > /etc/systemd/system/docker.service.d/50-insecure-registry.conf
[Service]
Environment="DOCKER_OPTS=--insecure-registry 10.0.0.0/8 --insecure-registry 172.16.0.0/12 --insecure-registry 192.168.0.0/16"
EOF
'
@ianblenke
ianblenke / upgrade-coreos.md
Last active July 7, 2021 03:49
How to upgrade CoreOS manually

Before upgrading, make sure you are allowing insecure registry access, or your newer docker won't be able to talk to the Deis registry:

sudo bash -c 'mkdir -p /etc/systemd/system/docker.service.d/; cat <<EOF > /etc/systemd/system/docker.service.d/50-insecure-registry.conf
[Service]
Environment="DOCKER_OPTS=--insecure-registry 10.0.0.0/8 --insecure-registry 172.16.0.0/12 --insecure-registry 192.168.0.0/16"
EOF
'