Skip to content

Instantly share code, notes, and snippets.

View GauntletWizard's full-sized avatar

Ted Hahn GauntletWizard

View GitHub Profile
CREDS=$(aws sts assume-role --role-arn "arn:aws:iam::${ACCOUNT}:role/${ROLE}" --role-session-name="${USER}")
docker run -ti --rm --name prowler --env "AWS_ACCESS_KEY_ID=$(echo $CREDS | jq -r .Credentials.AccessKeyId)" --env "AWS_SECRET_ACCESS_KEY=$(echo $CREDS | jq -r .Credentials.SecretAccessKey)" --env "AWS_SESSION_TOKEN=$(echo $CREDS | jq -r .Credentials.SessionToken)" toniblyx/prowler:latest -f us-west-2
git fetch
for deployment in $(kubectl get deployment -o name) ; do
local sha=$(kubectl get “$deployment” -o json |jq -r '.spec.template.spec.containers[].image | capture(".*:(?<sha>.*)")| .sha’);
count=$(git rev-list --count “${SHA}..origin/master”) ;
echo $deployment is $count revisions behind master (at $sha)
done
apiVersion: apps/v1
kind: Deployment
metadata:
name: init-demo
spec:
template:
spec:
hostNetwork: true
containers:
- name: nginx
### What version of rules_go are you using?
0.18.1
### What version of gazelle are you using?
0.15.0
### What version of Bazel are you using?
@GauntletWizard
GauntletWizard / alllogs.sh
Last active March 13, 2024 18:51
Kubernetes tools
#!/bin/bash
# Script to
# Relies on non-standard programs - ts(moreutils)
set -eux -o pipefail
labels="${1:-}"
if [[ $labels = "-h" ]] || [[ $labels = "--help" ]]
then
go list -f "{{range .Deps}}{{.}} {{end}}" | xargs go list -f "{{if not .Standard}}{{.ImportPath}} {{end}}" | xargs bazel run //:gazelle -- update-repos
# List current version of a go get installed package
# For bazel, I need the munged name, it's github location, and current HEAD.
git -C "$(go list -f '{{.Dir}}' gopkg.in/yaml.v2)" rev-parse HEAD
git -C "$(go list -f '{{.Dir}}' gopkg.in/yaml.v2)" remote get-url origin
@GauntletWizard
GauntletWizard / wall_drawing_273.scad
Created October 10, 2018 01:44
Wall Drawing 273 SCAD
// Wall Drawing 273 is an art piece by Sol LeWitt.
// This open source implementation is by Ted Hahn.
// This is generative art - Your viewing of it will be different than mine. I have included the positions of the walls because I am lazy and have not gotten around to making those random too, but the art on those walls is unique - You will not see the same image I did.
// draftlines is the number of lines to draw from each side.
draftlines = 10;
// The line module draws a 2d line from start to end, where start and end are [x, y] pairs.
module line (start, end, width=.1) {
echo("start=", start, "end=", end);
@GauntletWizard
GauntletWizard / info.sh
Created July 24, 2018 21:02
OSX Security for k8s
# Notes on connecting
# Trust the k8s root certificate
security -v add-trusted-cert -k "${HOME}/Library/Keychains/login.keychain-db" -r trustRoot "${KUBE_CERT}"
# Generate a user key and `security import` it
openssl genrsa -out "${CLIENTCERTKEY}" 4096
security import "${CLIENTCERTKEY}"
# Set for OSX
# Get the sha
# security find-cert -a -c ted -Z
@GauntletWizard
GauntletWizard / gist:3c5f13c3c98eb68148b7c365ee4b0f43
Last active July 11, 2018 21:29
Creating a IAM user/policy for K8s role accounts
set -eux -o pipefail
IAMUSER="$1"
aws iam create-user --user-name "${IAMUSER}"
POLICY="$(aws iam create-policy --policy-name "${IAMUSER}" --policy-document file://policy.json)" # "file://${IAMUSER}.policy"
ARN="$(echo $POLICY |jq -r .Policy.Arn)"
aws iam attach-user-policy --user-name "${IAMUSER}" --policy-arn="${ARN}"
# Create the access-key and parse the response to the ID and Secret
KEY="$(aws iam create-access-key --user-name "${IAMUSER}")"
KEYID="$(echo "${KEY}" |jq -r .AccessKey.AccessKeyId)"
KEYSECRET="$(echo "${KEY}" |jq -r .AccessKey.SecretAccessKey)"