Refactor to support multiple OS's

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
2021-11-29 08:07:17 +00:00
parent 48ad89385b
commit 3990c8fd9c
31 changed files with 1025 additions and 366 deletions

View File

@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -e
NAMESPACE="org-giantswarm"
RELEASE="20.0.0-alpha1"
PROVIDER="aws"
AZS="eu-west-1a"
print_usage() {
echo "gs-create-cluster - create a Giant Swarm managed workload cluster"
echo " "
echo "gs-create-cluster [cluster-name]"
echo " "
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the cluster is in (default: org-giantswarm)"
echo "-r, --release the namespace the cluster is in (default: 20.0.0-alpha1)"
echo "-p, --provider the cloud provider to use (default: aws)"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-r|--release)
shift
RELEASE=$1
shift
;;
-p|--provider)
shift
PROVIDER=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
# Positional args
NAME=${1:-wc001}
PREFIXED_NAMESPACE="org-$NAMESPACE"
case $NAMESPACE in org-*)
PREFIXED_NAMESPACE="$NAMESPACE"
NAMESPACE=${NAMESPACE#"org-"}
esac
echo "✨ Pre-flight checks"
gs-get-cluster --namespace ${PREFIXED_NAMESPACE} ${NAME} &>/dev/null
if [ $? -eq 0 ]; then
echo "Cluster named '${NAME}' already exists"
exit 1
else
echo "Cleaning up any old awsclusterroleidentities..."
kubectl get --namespace ${PREFIXED_NAMESPACE} awsclusterroleidentities ${NAME} >/dev/null && kubectl delete --namespace ${PREFIXED_NAMESPACE} awsclusterroleidentities ${NAME}
fi
echo "✨ Creating an ${PROVIDER} cluster called '${NAMESPACE}/${NAME}' with release '${RELEASE}'"
kubectl-gs template cluster --provider ${PROVIDER} --release ${RELEASE} --organization ${NAMESPACE} --name ${NAME} --description "$(whoami)'s test cluster" | kubectl apply -f -
echo "✨ Adding node pool to cluster"
kubectl-gs template nodepool --provider ${PROVIDER} --release ${RELEASE} --organization ${NAMESPACE} --cluster-name ${NAME} --description "$(whoami)'s test cluster" --availability-zones ${AZS} | kubectl apply -f -
echo "✨ Checking status..."
gs-get-cluster --namespace ${PREFIXED_NAMESPACE} ${NAME}

35
home/.bin/gs-get-cluster Normal file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e
NAMESPACE="org-giantswarm"
print_usage() {
echo "gs-get-cluster - get a Giant Swarm managed workload cluster"
echo " "
echo "gs-get-cluster [cluster-name]"
echo " "
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the cluster is in (default: org-giantswarm)"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
kubectl-gs get cluster --namespace $NAMESPACE $@ 2>/dev/null || kubectl get cl --namespace $NAMESPACE $@

59
home/.bin/gs-login Normal file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -e
TTL="24h"
CERTIFICATE_GROUP="system:masters"
print_usage() {
echo "gs-login - login to Giant Swarm managed clusters"
echo " "
echo "gs-login [INSTALLATION] [WORKLOAD CLUSTER] [ORGANISATION]"
echo " "
echo "Examples:"
echo "> gs-login gauss"
echo "> gs-login gauss mywc1"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-t, --ttl the certificate ttl for the workload cluster login (default: 24h)"
echo "-g, --certificate-group the certificate group to login as on the workload cluster (default: system:masters)"
}
while test $# -gt 0; do
case "$1" in
-t|--ttl)
shift
TTL=$1
shift
;;
-g|--certificate-group)
shift
CERTIFICATE_GROUP=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
case $# in
1)
kubectl gs login $1 2>/dev/null || opsctl kgs login -i $1
;;
2)
kubectl gs login $1 --workload-cluster $2 --certificate-group system:masters --certificate-ttl 24h
;;
3)
kubectl gs login $1 --workload-cluster $2 --certificate-group system:masters --certificate-ttl 24h --organization $3
;;
*)
print_usage
exit 1
;;
esac

103
home/.bin/gs-release Normal file
View File

@@ -0,0 +1,103 @@
#!/usr/bin/env bash
set -e
print_usage() {
echo "gs-release - create a new release of a Giant Swarm repo"
echo " "
echo "gs-release [SEMVER LEVEL]"
echo " "
echo " "
echo "Options:"
echo "-h, --help show this help text"
}
while test $# -gt 0; do
case "$1" in
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
SEMVER=$1
CURRENT_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
MAIN_BRANCH=$(git remote show origin 2>/dev/null|grep HEAD|sed 's/.* //')
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ "$MAIN_BRANCH" != "$CURRENT_BRANCH" ]; then
echo "Not currently on main branch, please switch to ${MAIN_BRANCH} to perform a release"
exit 1
fi
VERSION_PARTS=($(echo $CURRENT_TAG | tr "." "\n"))
VERSION_MAJOR=${VERSION_PARTS[1]}
VERSION_MINOR=${VERSION_PARTS[2]}
VERSION_PATCH=${VERSION_PARTS[3]}
echo "The latest released version is ${CURRENT_TAG}"
echo ""
if [[ "$SEMVER" == "" ]]; then
printf "What semver release level? (patch, minor or major): "
read SEMVER
fi
case ${SEMVER} in
patch)
VERSION_PATCH=$((VERSION_PATCH+1))
;;
minor)
VERSION_MINOR=$((VERSION_MINOR+1))
VERSION_PATCH=0
;;
major)
if [[ ${VERSION_MAJOR:0:1} == "v" ]]; then
VERSION_MAJOR="v$((VERSION_MAJOR+1))"
else
VERSION_MAJOR=$((VERSION_MAJOR+1))
fi
VERSION_MINOR=0
VERSION_PATCH=0
;;
*)
echo "Unknown Semver level provided"
exit 1
;;
esac
NEW_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
NEW_BRANCH="${MAIN_BRANCH}#release#${NEW_VERSION}"
echo ""
echo "✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ "
echo "Current version ${CURRENT_TAG}"
echo " New version ${NEW_VERSION}"
echo " Release branch ${NEW_BRANCH}"
echo "✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ "
echo ""
printf "Confirm? (y/n): "
read CONFIRM
if [ "${CONFIRM}" = "y" ]; then
echo "Publishing new release branch..."
git checkout -b "${NEW_BRANCH}"
git push -u origin "${NEW_BRANCH}"
ORG_NAME=$(git remote get-url origin | sed 's/.*github.com[:|\/]//' | sed 's/\.git$//' | tr '/' ' ' | awk '{print $1}')
REPO_NAME=$(git remote get-url origin | sed 's/.*github.com[:|\/]//' | sed 's/\.git$//' | tr '/' ' ' | awk '{print $2}')
echo "🚀 Keep an eye on https://github.com/${ORG_NAME}/${REPO_NAME}/pulls for the new release PR"
else
echo "Aborting..."
exit 1
fi

57
home/.bin/kube-all Normal file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -e
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
LABEL=""
ALL_NAMESPACES=false
print_usage() {
echo "kube-all - A better 'kubectl get all' - actually get all Kubernetes resources, including custom resources"
echo " "
echo "kube-all [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the to search in"
echo "-l, --selector the label selector to match on"
echo "-A, --all-namespaces match resources in all namespaces (default: false)"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-l|--selector)
shift
LABEL=$1
shift
;;
-A|--all-namespaces)
ALL_NAMESPACES=true
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
if [[ "${LABEL}" != "" ]]; then
LABEL="-l ${LABEL}"
fi
NAMES="$(kubectl api-resources --namespaced --verbs list -o name | tr '\n' ,)"
if [ $ALL_NAMESPACES ]; then
kubectl get "${NAMES:0:-1}" --show-kind --ignore-not-found ${LABEL} -A
else
kubectl get "${NAMES:0:-1}" --show-kind --ignore-not-found ${LABEL} -n ${NAMESPACE}
fi

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -e
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
LABEL=""
ALL_NAMESPACES=false
print_usage() {
echo "kube-clean-replicasets - Remove all olf ReplicaSets with 0 desired pods"
echo " "
echo "kube-clean-replicasets [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the to search in"
echo "-l, --selector the label selector to match on"
echo "-A, --all-namespaces match resources in all namespaces (default: false)"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-l|--selector)
shift
LABEL=$1
shift
;;
-A|--all-namespaces)
ALL_NAMESPACES=true
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
if [[ "${LABEL}" != "" ]]; then
LABEL="-l ${LABEL}"
fi
if [ $ALL_NAMESPACES ]; then
kubectl get replicasets --all-namespaces $LABEL -o jsonpath='{range .items[?(@.status.replicas==0)]}--namespace {@.metadata.namespace} {@.metadata.name};{end}' | \
tr ";" "\n" | \
xargs -I {} sh -c "kubectl delete rs {}"
else
kubectl get replicasets --namespace $NAMESPACE $LABEL -o jsonpath='{range .items[?(@.status.replicas==0)]}--namespace {@.metadata.namespace} {@.metadata.name};{end}' | \
tr ";" "\n" | \
xargs -I {} sh -c "kubectl delete rs {}"
fi

62
home/.bin/kube-exec Normal file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -e
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
POD=""
CMD="sh"
print_usage() {
echo "kube-exec - execute commands within a pod"
echo " "
echo "kube-exec [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the pod is in"
echo "-p, --pod the name of the pod"
echo "-c, --command the command to run in the pod (default: sh)"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-p|--pod)
shift
POD=$1
shift
;;
-c|--command)
shift
CMD=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
if [[ "$POD" == "" ]]; then
which fzf &>/dev/null || (
echo "If no pod provided, fzf is required to select pods"
echo ""
print_usage
exit 1
)
pod=($(kubectl get pods --all-namespaces -owide | fzf | awk '{print $1, $2}'))
POD=$pod[1]
NAMESPACE=$pod[0]
fi
echo kubectl exec -it --namespace $NAMESPACE $POD $CMD
kubectl exec -it --namespace $NAMESPACE $POD $CMD

View File

@@ -0,0 +1,86 @@
#!/usr/bin/env bash
set -e
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
HOST_PORT=10001
print_usage() {
echo "kube-forward-all - create port-forwards for all pods in the given namespace"
echo " "
echo "kube-forward-all [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace to launch the pod in"
echo "-p, --port the port to start at (and increment from for each service) (default: 10001)"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-p|--port)
shift
HOST_PORT=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
# Get all services first
IFS=$'\n'
SERVICES=( $(kubectl get service --namespace ${NAMESPACE} --no-headers -o json | jq '[.items[] | select(.metadata.annotations."kube-forward" != "false")] | (.[] | .metadata.name + "\t" + ([.spec.ports[].port] | join(",")))' -r | column -t) )
unset IFS
# Track the port-forwards we need to clean up
TO_KILL=()
cleanup() {
echo "\nClosing connections..."
for pid in "${TO_KILL[@]}"
do
(kill -2 $pid) &> /dev/null
done
trap - INT TERM
}
trap 'cleanup' INT TERM
echo "Forwarding..."
for s in "${SERVICES[@]}"
do
SERVICE=( $(echo $s) )
NAME=${SERVICE[0]}
PORT=${SERVICE[1]}
PORTS=($(echo $PORT | tr "," "\n"))
for PORT in "${PORTS[@]}"
do
(kubectl port-forward --namespace ${NAMESPACE} svc/$NAME $HOST_PORT:$PORT &>/dev/null) &
BG_PID=$!
if `curl -s -o /dev/null --retry 5 --retry-delay 0 --retry-connrefused -m 3 http://localhost:$HOST_PORT`
then
echo "\e[1m$NAME:$PORT\e[0m ➡ \e[34mhttp://localhost:$HOST_PORT\e[0m"
TO_KILL+=($BG_PID)
((HOST_PORT=HOST_PORT+1))
else
(kill -2 $BG_PID) &> /dev/null
fi
done
done
echo "\n\e[2m(Use [Ctl + C] to exit)"
cat
cleanup

62
home/.bin/kube-logs Normal file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -e
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
POD=""
ARGS=""
print_usage() {
echo "kube-logs - tail logs from a pod"
echo " "
echo "kube-logs [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the pod is in"
echo "-p, --pod the name of the pod to get logs for"
echo "-a, --args additional arguments to pass to kubectl logs command"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-p|--pod)
shift
POD=$1
shift
;;
-a|--args)
shift
ARGS=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
if [[ "$POD" == "" ]]; then
which fzf &>/dev/null || (
echo "If no pod provided, fzf is required to select pods"
echo ""
print_usage
exit 1
)
pod=($(kubectl get pods --all-namespaces -owide | fzf | awk '{print $1, $2}'))
POD=$pod[1]
NAMESPACE=$pod[0]
fi
echo kubectl logs -f $ARGS --namespace $NAMESPACE $POD
kubectl logs -f $ARGS --namespace $NAMESPACE $POD

57
home/.bin/kube-shell Normal file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -e
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
POD="shell"
IMAGE="bash"
CMD="sh"
print_usage() {
echo "kube-shell - create a new pod and exec into it's shell"
echo " "
echo "kube-shell [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace the pod should launch in"
echo "-p, --pod the name of the pod to get logs for (default: shell)"
echo "-i, --image the image to use for the shell container (default: bash)"
echo "-c, --command the initial command to execute in the container (default: sh)"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-p|--pod)
shift
POD=$1
shift
;;
-i|--image)
shift
IMAGE=$1
shift
;;
-c|--command)
shift
CMD=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
echo kubectl run -it --namespace $NAMESPACE $POD --image $IMAGE --restart Never --rm -- $CMD
kubectl run -it --namespace $NAMESPACE $POD --image $IMAGE --restart Never --rm -- $CMD

91
home/.bin/kube-ssh Normal file
View File

@@ -0,0 +1,91 @@
#!/usr/bin/env bash
set -e
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
POD="kube-ssh"
NODE=""
print_usage() {
echo "kube-ssh - gain access to a Kubernetes host node (ssh-like for when a host doesn't have ssh)"
echo " "
echo "kube-ssh [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace to launch the pod in"
echo "-p, --pod the name of the pod to launch (default: kube-ssh)"
echo "-N, --node the name of the node to access"
}
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-p|--pod)
shift
POD=$1
shift
;;
-N|--node)
shift
NODE=$1
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
break
;;
esac
done
if [[ "$NODE" == "" ]]; then
NODES=$(kubectl get nodes --no-headers -o custom-columns=name:.metadata.name)
if [ -z "$(which fzf)" ]; then
i=0
while read -r node; do
echo "[$i] - $node"
i=$((i+1))
done <<< "$NODES"
read -p "Which node would you like to connect to? " -r
echo ""
IFS=$'\n' NODES=($NODES)
NODE=${NODES[$REPLY]}
else
NODE=$(echo "$NODES" | fzf)
fi
fi
NODE_NAME=$(kubectl get node $NODE -o template --template='{{index .metadata.labels "kubernetes.io/hostname"}}')
NODE_SELECTOR='"nodeSelector": { "kubernetes.io/hostname": "'${NODE_NAME}'" },'
kubectl run --namespace ${NAMESPACE} $POD --restart=Never -it --rm --image overriden --overrides '
{
"spec": {
"hostPID": true,
"hostNetwork": true,
'"${NODE_SELECTOR}"'
"tolerations": [{
"operator": "Exists"
}],
"containers": [
{
"name": "kube-ssh",
"image": "averagemarcus/kube-ssh:latest",
"stdin": true,
"tty": true,
"securityContext": {
"privileged": true
}
}
]
}
}' --attach

62
home/.dotfiles/1-zsh Normal file
View File

@@ -0,0 +1,62 @@
export ZSH="$HOME/.oh-my-zsh"
plugins=(
zsh-syntax-highlighting
)
autoload -U compinit
# Use this setting if you want to disable marking untracked files under VCS as dirty.
# This makes repository status checks for large repositories much, much faster.
DISABLE_UNTRACKED_FILES_DIRTY="true"
SHOW_AWS_PROMPT=false
COMPLETION_WAITING_DOTS=true
source $ZSH/oh-my-zsh.sh
zstyle ':omz:update' mode reminder
source `brew --prefix switch`/switch.sh
# History
HISTFILE="$HOME/.zsh_history"
HISTIGNORE="&:exit:reset:clear:zh"
setopt append_history
setopt hist_ignore_space
setopt HIST_IGNORE_DUPS
setopt sharehistory
setopt INC_APPEND_HISTORY
setopt HIST_REDUCE_BLANKS
# Options
setopt autocd
autoload -U add-zsh-hook
DISABLE_AUTO_TITLE="true"
# Override auto-title when static titles are desired ($ title My new title)
title() { export TITLE_OVERRIDDEN=1; echo -en "\e]0;$*\a"}
# Turn off static titles ($ autotitle)
autotitle() { export TITLE_OVERRIDDEN=0 }; autotitle
# Condition checking if title is overridden
overridden() { [[ $TITLE_OVERRIDDEN == 1 ]]; }
# Show cwd when shell prompts for input.
precmd() {
if overridden; then return; fi
pwd=$(pwd) # Store full path as variable
cwd=${pwd##*/} # Extract current working dir only
print -Pn "\e]0;$cwd\a" # Replace with $pwd to show full path
}
# Prepend command (w/o arguments) to cwd while waiting for command to complete.
preexec() {
if overridden; then return; fi
printf "\033]0;%s\a" "${1%% *} | $cwd" # Omit construct from $1 to show args
}
# Giant Swarm specific
which opsctl &>/dev/null && opsctl completion zsh > /usr/local/share/zsh/site-functions/_opsctl
which gsctl &>/dev/null && gsctl completion zsh --stdout > /usr/local/share/zsh/site-functions/_gsctl
which devctl &>/dev/null && devctl completion zsh > /usr/local/share/zsh/site-functions/_devctl

63
home/.dotfiles/aliases Normal file
View File

@@ -0,0 +1,63 @@
# Rename existing tools
alias _cat=`which cat`
alias _curl=`which curl`
alias _ls="/bin/ls"
alias _grep="/bin/grep"
alias _diff="/usr/bin/diff"
alias _du=`which du`
alias _df=`which df`
alias _find=`which find`
alias _top=`which top`
alias _ps="/bin/ps"
alias _dig=`which dig`
alias _git=`which git`
# Aliases
alias cat='bat '
alias curl='curlie'
alias ls='exa --group-directories-first --icons --header --git --ignore-glob=.git'
alias grep='rg'
alias diff='delta'
alias du='dust'
alias df='duf -hide special'
alias find='fd'
alias bandwhich='sudo bandwhich'
alias top='btm'
alias ps='procs'
alias dig='dog'
alias kubectx='switch'
alias kctx='switch'
alias machine-info='macchina -t Boron --bar'
alias watch='watch '
alias tmp='cd $(mktemp -d)'
lt() {
DEPTH=$(echo $1 | grep "^[0-9]*$")
if [ "$DEPTH" = "" ]; then
DEPTH=2
else
shift
fi
ls -l --tree -L $DEPTH -I ".git|cache|log|logs|node_modules|vendor" $@
}
git() {
if [ "$1" = "take" ]; then # Git clone then cd into new directory
_git clone $2
cd $(basename $2 | sed 's/\.git$//')
elif [ "$1" = "commit" ]; then # Sign all commits
shift
_git commit -s $@
else
_git $@
fi
}
# Giant Swarm specific
alias prom='opsctl open -a prometheus --sso -i'
alias happa='opsctl open -a happa --sso -i'
alias grafana='opsctl open -a grafana --sso -i'
alias argo='opsctl open -a argocd --sso -i'
alias cloud-provider='opsctl open -a cloudprovider -i'
alias get-cluster='gs-get-cluster'
alias create-cluster='gs-create-cluster'

View File

@@ -0,0 +1,26 @@
export EDITOR='vim'
export VISUAL='code'
export GPG_TTY=$(tty)
# AWS
if [ -f ~/.aws/profile ]; then
export AWS_PROFILE=$(cat ~/.aws/profile)
export AWS_DEFAULT_REGION=eu-west-1
export AWS_REGION=eu-west-1
fi
# Node
export NODE_ENV=localhost
[ -f ~/.npmrc ] && export NPM_TOKEN=`head -n 1 ~/.npmrc | sed 's~//registry.npmjs.org/:_authToken=\(.*\)~\1~'`
# Go
export GOPATH=$HOME/goworkspace
export GO111MODULE=on
# Starship
export STARSHIP_CONFIG=~/.starship/config.toml
export STARSHIP_LOG=error
# Bat
export BAT_THEME="Monokai Extended Light"
export BAT_STYLE="grid,header"

10
home/.dotfiles/kubernetes Normal file
View File

@@ -0,0 +1,10 @@
alias k='kubectl '
alias kx='kube-exec '
alias kl='kube-logs '
alias kshell='kube-shell '
alias kall='kube-all '
alias fix-broken-replicasets='kube-clean-replicasets '
alias kube-forward='kube-forward-all '
source <(kubectl completion zsh)
source <(tkn completion zsh)

60
home/.gitconfig Normal file
View File

@@ -0,0 +1,60 @@
[user]
name = Marcus Noble
signingkey = B8F2DB8A7AEBAF78
[commit]
gpgsign = true
[core]
editor = /usr/bin/vim
excludesfile = ~/.gitignore
[pager]
diff = delta
log = delta
reflog = delta
show = delta
[delta]
line-numbers = true
side-by-side = true
[push]
default = simple
[init]
defaultBranch = main
[credential]
helper = store
[color]
ui = true
[color "diff"]
old = red strike
new = green italic
[alias]
basename = "!git remote -v | head -n1 | awk '{print $2}' | sed 's/.*\\///' | sed 's/\\.git//'"
org-name = "!git remote -v | grep -m 1 -o ':.*/' | sed 's:^.\\(.*\\).$:\\1:'"
branch-name = "!git rev-parse --abbrev-ref HEAD"
changelog-changed = "!test $(git diff --name-only HEAD origin/$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') | grep CHANGELOG.md | wc -l | xargs) = 1"
main-branch = "!git remote show origin|grep HEAD|sed 's/.* //'"
main = "!git remote set-head origin --auto && git checkout $(git main-branch) && git pull"
publish = "!func(){ if [[ $(git branch-name) != \"$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')\" ]]; then git push -u origin $(git branch-name) && (git changelog-changed || echo '\n\n⚠ Dont forget to update changelog ⚠️ ') ; else echo "Wat?!"; fi; }; func"
cleanup = "!git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done"
dont-change-file = "!git update-index --assume-unchanged"
ignore-file = "!git update-index --skip-worktree"
remember-file = "!git update-index --no-skip-worktree"
logg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
dif = "!git diff -w"
pop = "!git stash pop"
[help]
autocorrect = 1
[diff]
compactionHeuristic = true
[url "ssh://git@github.com"]
insteadOf = https://github.com

156
home/.hyper.js Normal file
View File

@@ -0,0 +1,156 @@
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
scrollback: 10000000,
// default font size in pixels for all tabs
fontSize: 13,
// font family with optional fallbacks
fontFamily: '"OpenDyslexicMono Nerd Font", "Fira Code", Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// default font weight: 'normal' or 'bold'
fontWeight: 'normal',
// font weight for bold characters: 'normal' or 'bold'
fontWeightBold: 'bold',
// line height as a relative unit
lineHeight: 1,
// letter spacing as a relative unit
letterSpacing: 0,
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
// terminal text color under BLOCK cursor
cursorAccentColor: '#000',
// `'BEAM'` for |, `'UNDERLINE'` for _, `'BLOCK'` for █
cursorShape: 'BEAM',
// set to `true` (without backticks and without quotes) for blinking cursor
cursorBlink: true,
// color of the text
foregroundColor: '#fff',
// terminal background color
// opacity is only supported on macOS
backgroundColor: '#000',
// terminal selection color
selectionColor: 'rgba(248,28,229,0.3)',
// border color (window, tabs)
borderColor: '#333',
// custom CSS to embed in the main window
css: `.line {
color: #999;
stroke: #999;
}`,
// custom CSS to embed in the terminal window
termCSS: '',
// if you're using a Linux setup which show native menus, set to false
// default: `true` on Linux, `true` on Windows, ignored on macOS
showHamburgerMenu: '',
// set to `false` (without backticks and without quotes) if you want to hide the minimize, maximize and close buttons
// additionally, set to `'left'` if you want them on the left, like in Ubuntu
// default: `true` (without backticks and without quotes) on Windows and Linux, ignored on macOS
showWindowControls: '',
// custom padding (CSS format, i.e.: `top right bottom left`)
padding: '12px 14px',
// the full list. if you're going to provide the full color palette,
// including the 6 x 6 color cubes and the grayscale map, just provide
// an array here instead of a color map object
colors: {
black: '#000000',
red: '#C51E14',
green: '#1DC121',
yellow: '#C7C329',
blue: '#0A2FC4',
magenta: '#C839C5',
cyan: '#20C5C6',
white: '#C7C7C7',
lightBlack: '#686868',
lightRed: '#FD6F6B',
lightGreen: '#67F86F',
lightYellow: '#FFFA72',
lightBlue: '#6A76FB',
lightMagenta: '#FD7CFC',
lightCyan: '#68FDFE',
lightWhite: '#FFFFFF',
},
// the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
// if left empty, your system's login shell will be used by default
//
// Windows
// - Make sure to use a full path if the binary name doesn't work
// - Remove `--login` in shellArgs
//
// Bash on Windows
// - Example: `C:\\Windows\\System32\\bash.exe`
//
// PowerShell on Windows
// - Example: `C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`
shell: '',
// for setting shell arguments (i.e. for using interactive shellArgs: `['-i']`)
// by default `['--login']` will be used
shellArgs: ['--login'],
// for environment variables
env: {},
// set to `false` for no bell
bell: `false`,
// if `true` (without backticks and without quotes), selected text will automatically be copied to the clipboard
copyOnSelect: false,
// if `true` (without backticks and without quotes), hyper will be set as the default protocol client for SSH
defaultSSHApp: true,
// if `true` (without backticks and without quotes), on right click selected text will be copied or pasted if no
// selection is present (`true` by default on Windows and disables the context menu feature)
// quickEdit: true,
// URL to custom bell
// bellSoundURL: 'http://example.com/bell.mp3',
// for advanced config flags please refer to https://hyper.is/#cfg
},
// a list of plugins to fetch and install from npm
// format: [@org/]project[#version]
// examples:
// `hyperpower`
// `@company/project`
// `project#1.0.1`
plugins: ["hyper-search", "hyperterm-paste", "hyper-tabs-enhanced", "hyper-chesterish", "hyper-quit"],
// in development, you can create a directory under
// `~/.hyper_plugins/local/` and include it here
// to load it and avoid it being `npm install`ed
localPlugins: [],
keymaps: {
// Example
// 'window:devtools': 'cmd+alt+o',
},
};

26
home/.k9s/config.yml Normal file
View File

@@ -0,0 +1,26 @@
k9s:
refreshRate: 2
maxConnRetry: 5
enableMouse: false
headless: false
logoless: true
crumbsless: false
readOnly: false
noIcons: false
logger:
tail: 5000
buffer: 50000
sinceSeconds: 0
fullScreenLogs: false
textWrap: false
showTime: false
currentContext:
currentCluster:
clusters: []
thresholds:
cpu:
critical: 90
warn: 80
memory:
critical: 90
warn: 80

75
home/.k9s/skin.yml Normal file
View File

@@ -0,0 +1,75 @@
# Base16 Material - k9s color config
# Scheme author: Nate Peterson
# Template author: Jef LeCompte (https://jef.buzz)
k9s:
# General K9s styles
body:
fgColor: '#eeffff'
bgColor: '#263238'
logoColor: '#89ddff'
# ClusterInfoView styles
info:
fgColor: '#c3e88d'
sectionColor: '#eeffff'
# Frame styles
frame:
# Borders styles
border:
fgColor: '#82aaff'
focusColor: '#89ddff'
# MenuView attributes and styles
menu:
fgColor: '#eeffff'
keyColor: '#c3e88d'
# Used for favorite namespaces
numKeyColor: '#c3e88d'
# CrumbView attributes for history navigation.
crumbs:
fgColor: '#89ddff'
bgColor: '#263238'
activeColor: '#263238'
# Resource status and update styles
status:
newColor: '#eeffff'
modifyColor: '#ffcb6b'
addColor: '#c3e88d'
errorColor: '#f07178'
highlightcolor: '#89ddff'
killColor: '#f07178'
completedColor: '#c3e88d'
# Border title styles.
title:
fgColor: '#eeffff'
bgColor: '#263238'
highlightColor: '#c792ea'
counterColor: '#c792ea'
filterColor: '#c792ea'
# Specific views styles
views:
# TableView attributes.
table:
fgColor: '#82aaff'
bgColor: '#263238'
cursorColor: '#89ddff'
# Header row styles.
header:
fgColor: '#82aaff'
bgColor: '#263238'
sorterColor: '#c792ea'
# YAML info styles.
yaml:
keyColor: '#f07178'
colonColor: '#89ddff'
valueColor: '#eeffff'
# Logs styles.
logs:
fgColor: '#eeffff'
bgColor: '#263238'

View File

View File

@@ -0,0 +1,8 @@
kind: SwitchConfig
version: v1alpha1
kubeconfigName: "*.yaml"
kubeconfigStores:
- kind: filesystem
kubeconfigName: "*.yaml"
paths:
- ~/.kube/clusters/

View File

@@ -0,0 +1,71 @@
format = """\
$status\
$cmd_duration\
$line_break\
$directory\
$git_branch\
$git_commit\
$git_state\
$git_status\
$kubernetes\
$helm\
$golang\
$nodejs\
$terraform\
$package\
$custom\
$line_break\
$jobs\
$time\
$character\
"""
command_timeout = 1000
add_newline = true
[character]
success_symbol = "[✨](yellow)"
error_symbol = "[✗](red)"
[aws]
symbol = " "
format = "[$symbol$profile]($style) "
[git_commit]
only_detached = true
[golang]
symbol = " "
format = "[$symbol$version]($style) "
[kubernetes]
format = '[$symbol$context \($namespace\)]($style) '
symbol = "ﴱ "
style = "bold blue"
disabled = false
[kubernetes.context_aliases]
"gs-(?P<cluster>.+)" = "$cluster [MC]"
[terraform]
format = "[$symbol$version]($style) "
[nodejs]
symbol = " "
[status]
style = "red"
symbol = "✗"
format = '[↪ \[$symbol $common_meaning$signal_name$maybe_int\]]($style)'
map_symbol = true
disabled = false
[helm]
format = "[$symbol$version]($style) "
symbol = " "
[cmd_duration]
format = " took [$duration]($style) "
[package]
symbol = "📦"
format = "[$symbol$version]($style) "

View File

@@ -0,0 +1,92 @@
"########################################
"########################################
" Tickle Contrast (rainglow)
"
" https://github.com/rainglow/vim
"
" Copyright (c) Dayle Rees.
"########################################
"########################################
"########################################
"# Settings. #
"########################################
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "tickle-contrast"
"########################################
"# Base Colors. #
"########################################
hi Cursor guifg=#181819 guibg=#f8f8f0 gui=NONE
hi Visual guifg=#85ffc7 guibg=#ffffff gui=NONE
hi CursorLine guifg=NONE guibg=#1f1f21 gui=NONE
hi CursorLineNr guifg=#636367 guibg=#060607 gui=NONE
hi CursorColumn guifg=NONE guibg=#060607 gui=NONE
hi ColorColumn guifg=NONE guibg=#000000 gui=NONE
hi LineNr guifg=#313133 guibg=#0b0b0c gui=NONE
hi VertSplit guifg=#313133 guibg=#313133 gui=NONE
hi MatchParen guifg=#40a5a5 guibg=NONE gui=underline
hi StatusLine guifg=#c1c1c1 guibg=#0b0b0c gui=bold
hi StatusLineNC guifg=#c1c1c1 guibg=#0b0b0c gui=NONE
hi Pmenu guifg=#c1c1c1 guibg=#0b0b0c gui=NONE
hi PmenuSel guifg=NONE guibg=#85ffc7 gui=NONE
hi IncSearch guifg=#c1c1c1 guibg=#afd1d1 gui=NONE
hi Search guifg=NONE guibg=NONE gui=underline
hi Directory guifg=#85ffc7 guibg=NONE gui=NONE
hi Folded guifg=#b4b4b4 guibg=#000000 gui=NONE
hi Normal guifg=#ff8552 guibg=#181819 gui=NONE
hi Boolean guifg=#ff8552 guibg=NONE gui=NONE
hi Character guifg=#86baba guibg=NONE gui=NONE
hi Comment guifg=#606063 guibg=NONE gui=NONE
hi Conditional guifg=#85ffc7 guibg=NONE gui=NONE
hi Constant guifg=NONE guibg=NONE gui=NONE
hi Define guifg=#85FFC7 guibg=NONE gui=NONE
hi DiffAdd guifg=#3d3d40 guibg=#a7da1e gui=bold
hi DiffDelete guifg=#3d3d40 guibg=#e61f44 gui=NONE
hi DiffChange guifg=#3d3d40 guibg=#f7b83d gui=NONE
hi DiffText guifg=#3d3d40 guibg=#f7b83d gui=bold
hi ErrorMsg guifg=#3d3d40 guibg=#e61f44 gui=NONE
hi WarningMsg guifg=#3d3d40 guibg=#f7b83d gui=NONE
hi Float guifg=#afd1d1 guibg=NONE gui=NONE
hi Function guifg=#85ffc7 guibg=NONE gui=NONE
hi Identifier guifg=#ffffff guibg=NONE gui=NONE
hi Keyword guifg=#85ffc7 guibg=NONE gui=NONE
hi Label guifg=#86baba guibg=NONE gui=NONE
hi NonText guifg=#5b5b5b guibg=#131314 gui=NONE
hi Number guifg=#afd1d1 guibg=NONE gui=NONE
hi Operator guifg=#c1c1c1 guibg=NONE gui=NONE
hi PreProc guifg=#86868a guibg=NONE gui=NONE
hi Special guifg=#c1c1c1 guibg=NONE gui=NONE
hi SpecialKey guifg=#c1c1c1 guibg=#85ffc7 gui=NONE
hi Statement guifg=#85ffc7 guibg=NONE gui=NONE
hi StorageClass guifg=#40a5a5 guibg=NONE gui=NONE
hi String guifg=#86baba guibg=NONE gui=NONE
hi Tag guifg=#85ffc7 guibg=NONE gui=NONE
hi Title guifg=#85ffc7 guibg=NONE gui=bold
hi Todo guifg=#86868a guibg=NONE gui=inverse,bold
hi Type guifg=NONE guibg=NONE gui=NONE
hi Underlined guifg=NONE guibg=NONE gui=underline
"########################################
"# Language Overrides #
"########################################
hi phpIdentifier guifg=#ffffff
hi phpMethodsVar guifg=#cacacc
hi xmlTag guifg=#85ffc7 guibg=NONE gui=NONE
hi xmlTagName guifg=#85ffc7 guibg=NONE gui=NONE
hi xmlEndTag guifg=#85ffc7 guibg=NONE gui=NONE
"########################################
"# Light Theme Overrides #
"########################################

5
home/.vimrc Normal file
View File

@@ -0,0 +1,5 @@
colorscheme tickle-contrast
set paste
set number
set linespace=3
set cursorline

30
home/.zshrc Normal file
View File

@@ -0,0 +1,30 @@
PATH_DIRS=(
"${HOME}/.bin"
"${KREW_ROOT:-${HOME}/.krew}/bin"
"${GOPATH:-${HOME}/goworkspace}/bin"
"${HOME}/.cargo/bin"
"/home/linuxbrew/.linuxbrew/bin"
"/usr/local/bin"
"/usr/bin"
"/bin"
"/usr/sbin"
"/sbin"
"${PATH}"
)
export PATH=${"${PATH_DIRS[*]}"// /:}
if [ ! -z ~/.additional_dotfiles/credentials ]; then
source ~/.additional_dotfiles/credentials
fi
for filename in ~/.dotfiles/*; do
source $filename
done
for filename in ~/.additional_dotfiles/*; do
source $filename
done
rm -f ~/.zcompdump; compinit
eval "$(starship init zsh)"