Skip to content

Instantly share code, notes, and snippets.

View gswallow's full-sized avatar

Greg Swallow gswallow

  • Indianapolis, IN, USA
View GitHub Profile
# Use discrete kubeconfig files
update_kubeconfig () {
KUBECONFIG=$HOME/.kube/config
for f in $HOME/.kube/config.d/*; do
KUBECONFIG=$KUBECONFIG:$f
done
export KUBECONFIG
}
update_kubeconfig
@gswallow
gswallow / k8s-create-ns.sh
Last active March 16, 2022 23:12
Creates a namespace and an admin-level account for that namespace.
#!/bin/bash
if [ "$(uname -s)" == "Darwin" ]; then
b64="base64 -D"
else
b64="base64"
fi
project_name=$1
@gswallow
gswallow / Istio-README.md
Last active August 28, 2019 01:36
Indy DevOps Meetup 8/2019 - Istio

Install istio

Mac friendly. Probably not Linux friendly. Throughout the course of these commands, feel free to check out the contents of the yaml files you apply with kubectl.

Get eksctl

brew tap weaveworks/tap
brew install weaveworks/tap/eksctl
@gswallow
gswallow / ssh-cheat.yaml
Last active May 29, 2019 18:38
Greg is a BAD, BAD MAN!
apiVersion: v1
kind: Pod
metadata:
labels:
app: ssh-cheat
name: ssh-cheat
namespace: kube-system
spec:
containers:
- command:
@gswallow
gswallow / kids.rb
Created May 28, 2019 18:04
kids.rb
#!/usr/bin/env ruby
require 'magic_cloud'
name = ARGV[0]
major = ARGV[1]
minor = ARGV[2]
angles = [350, 260, 80]
words = Array.new
@gswallow
gswallow / site.yml
Last active July 22, 2020 00:01
Ansible tags are a code smell
---
- hosts: localhost
vars:
ansible_connection: local
tasks:
- name: demo an untagged task
debug:
msg: I am an untagged task
- name: demo a normal tagged task
@gswallow
gswallow / gist:addb3bd6af1dbc350e19a9bc76d97a02
Created February 7, 2019 15:47
Find VMs by MAC address
#!/bin/bash
for vm in $(govc find -i=true / -type m); do
govc object.collect -json=true $vm config | jq -r '.[] | select(.Val.Hardware.Device[].MacAddress == "00:50:56:b4:0a:1b") | .Val.Name'
govc object.collect -json=true $vm config | jq -r '.[] | select(.Val.Hardware.Device[].MacAddress == "00:50:56:b7:06:6f") | .Val.Name'
done
@gswallow
gswallow / terraform_s3_policy.json
Created January 11, 2019 21:17
S3 bucket policy for cross-account terraform use
{
"Version": "2012-10-17",
"Id": "Policy1547233271159",
"Statement": [
{
"Sid": "Allow-non-prod-to-list-bucket-objects",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::222222222222:root"
},
@gswallow
gswallow / 01_mk_ca.sh
Last active November 3, 2018 04:18
kubernetes the hard way on aws: so many certs
#!/bin/bash
country=${country:=US}
state=${state:=Indiana}
city=${city:=Carmel}
if [ ! -d ca ]; then
mkdir ca
fi
@gswallow
gswallow / ldapclients.sh
Created August 22, 2018 17:01
Find LDAP clients from HAProxy connection logs
#!/usr/local/bin/bash
pfx=$(basename $0)
tempdir=$(mktemp -d /tmp/$pfx.$$)
for i in /var/log/messages*; do
case $i in
*.bz2 )
bunzip2 -c $i | egrep '(51|62)(:389|:636)' | awk '{print $8" "$10}' | awk -F':' '{print $1" "$3}' >> $tempdir/clients
;;