Skip to content

Instantly share code, notes, and snippets.

View mjpitz's full-sized avatar
🏳️‍🌈
out and proud

Mya mjpitz

🏳️‍🌈
out and proud
View GitHub Profile
@mjpitz
mjpitz / kubeconfig.sh
Last active December 1, 2020 15:00
One-line dynamic KUBECONFIG per shell
# Enables each Shell instance to have their own KUBECONFIG.
# Also aggregates all cluster contexts into a single configuration.
# Simply add to .bashrc or .bash_profile
kubeconfig="${KUBECONFIG}"
if [[ -z "${kubeconfig}" ]]; then
kubeconfig="$(mktemp):$(ls -1 ${HOME}/.kube/*.yaml | tr $'\n' ':')${HOME}/.kube/config"
fi
export KUBECONFIG="${kubeconfig}"
@mjpitz
mjpitz / kubeauth.sh
Created January 17, 2020 14:14
Simple little script for demonstrating certificate auth in kubernetes
#!/usr/bin/env bash
## Simple script demonstrating how to use certificate auth in Kubernetes. In this script
## we leverage the built in csr approval process. In practice, the approval process can
## be delegated to an external authority so long as the external authority and the
## Kubernetes API server share a common CA.
readonly name=${1:-$(whoami)}
trap "rm ${name}-key.pem ${name}.csr ${name}.crt" EXIT
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: test
name: test-a
spec:
replicas: 1
selector:
matchLabels:
@mjpitz
mjpitz / memberlist-serf-raft.go
Created May 8, 2020 15:00
Basic idea on how to use memberlist, serf, and raft all together. Last example I found had a few bugs to work out.
package main
import (
"fmt"
"github.com/hashicorp/memberlist"
"github.com/hashicorp/raft"
"github.com/hashicorp/raft-boltdb"
"github.com/hashicorp/serf/serf"
"io"
"log"
### Individual Contributor License Agreement
In order to clarify the intellectual property license granted with
Contributions from any person or entity, deps.cloud must have a Contributor
License Agreement ("CLA") on file that has been signed by each Contributor,
indicating agreement to the license terms below. This license is for your
protection as a Contributor as well as the protection of deps.cloud; it does
not change your rights to use your own Contributions for any other purpose.
You accept and agree to the following terms and conditions for Your present
### Software Grant and Corporate Contributor License Agreement
In order to clarify the intellectual property license granted with
Contributions from any person or entity, deps.cloud must have a Contributor
License Agreement (CLA) on file that has been signed by each Contributor,
indicating agreement to the license terms below. This license is for your
protection as a Contributor as well as the protection of deps.cloud and its
users; it does not change your rights to use your own Contributions for any
other purpose.
# setup credentials for the api
export GITHUB_AUTHORIZATION="token PRIVATE-TOKEN"
export GITHUB_GROUP="deps-cloud"
export BRANCH_NAME="main"
# start with a fresh copy of your code (just to be safe)
curl -sSL -H "Authorization: ${GITHUB_AUTHORIZATION}" https://api.github.com/users/${GITHUB_GROUP}/repos | \
jq -r .[].ssh_url | \
#!/usr/bin/env bash
# Quick script that will prepent a `date:` field to all files. Helpful for a qiuck one time hack.
for file in $(find ${1} -type f); do
last_modified=$(git log -n 1 --pretty=format:"%ad" --date=short -- "${file}")
content="---\\ndate: ${last_modified}"
echo "${file}"
sed -i "1s/.*/${content}/" "${file}"
@mjpitz
mjpitz / git-migrate.sh
Created August 19, 2020 01:10
git-migrate.sh
#!/usr/bin/env bash
set -e
function usage {
echo ''
echo ' git migrate <repourl> <target> [branch: main]'
echo ''
echo ' This command is used to migrate code from the repository that'
echo ' exists at the specified URL, at target path in repository, on'
echo ' the specified branch. This command will preserve git history'
@mjpitz
mjpitz / production-outage-scenario-template.md
Created September 26, 2020 21:29
production-outage-scenario-template.md

Production Outage Scenario Template

Symptoms

Describe the current state of the system.

Context

Provide context about the systems and the potential impact on the end users.