Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Goodness mgoodness

View GitHub Profile
View kube-ssh.sh
#!/usr/bin/env bash
while getopts ":u:" opt; do
case "$opt" in
u)
username="${OPTARG}"
;;
\?)
echo "Invalid option: -${OPTARG}" >&2
return 1
View kube-context.sh
kube-context() {
if [[ -n "$1" ]]; then
context=$1
else
context=$(kubectl config get-contexts \
| fzf --header-lines=1 --no-multi \
| awk '{if ($1!="*") print $1; else print $2 }')
fi
[[ -n ${context} ]] && kubectl config use-context ${context}
View docker-rmi.sh
docker-rmi() {
docker images \
| fzf --header-lines=1 --multi \
| awk '{print $3}' \
| xargs docker rmi ${1+"$@"}
}
View find-replace.sh
find-replace() {
for m in (ag --files-with-matches -- $1); do
sed -i '' -e "s/$1/$2/g" $m
done
}
View k8s-api.sh
k8s-api() {
if [[ "$1" == "1.9" ]]; then
url="https://v1-9.docs.kubernetes.io/docs/api-reference/v1.9/"
else
url="https://kubernetes.io/docs/reference/generated/kubernetes-api/v$1/"
fi
open ${url}
}
View git-rebase-preserve-author.sh
git-rebase-preserve-author() {
git rebase --preserve-merges $1
root_dir=(git rev-parse --show-toplevel)
while [[ -f ${root_dir}/.git/rebase-merge/stopped-sha ]]; do
stopped_sha=(cat ${root_dir}/.git/rebase-merge/stopped-sha)
git_author_string=(git show -s --format='%an <%ae>' ${stopped_sha})
for c in (git diff --name-only --diff-filter=U); do
eval ${EDITOR} ${root_dir}/$c
@mgoodness
mgoodness / nginx-ingress-controller-rbac.md
Last active May 28, 2019
nginx-ingress-controller RBAC setup for K8s v1.8+ (tested on minikube)
View nginx-ingress-controller-rbac.md
kubectl -n kube-system create sa nginx-ingress-controller
kubectl apply -f https://gist.github.com/mgoodness/684d91e5812d383f6cc48d420bdad5b5/raw/8ef6d0623e9273aa93f22ab2b5d5cbb40502a5aa/nginx-ingress-controller-clusterrole.yaml
kubectl -n kube-system apply -f https://gist.github.com/mgoodness/4c5ddf4cc340a7c504a01a8f9ff422cf/raw/421d2032e4a36577739b60c0e673e889c1d1c6e2/nginx-ingress-controller-role.yaml
kubectl create clusterrolebinding nginx-ingress-controller --clusterrole nginx-ingress-controller --serviceaccount=kube-system:nginx-ingress-controller
kubectl -n kube-system create rolebinding nginx-ingress-controller --role nginx-ingress-controller --serviceaccount=kube-system:nginx-ingress-controller
kubectl -n kube-system patch rc/nginx-ingress-controller -p '{"spec": {"template": {"spec": {"serviceAccountName": "nginx-ingress-controller"}}}}'
kubectl -n kube-system delete po -l app=nginx-ingress-controller
@mgoodness
mgoodness / nginx-ingress-controller-role.yaml
Last active May 28, 2019
nginx-ingress-controller Role
View nginx-ingress-controller-role.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: nginx-ingress-controller
rules:
- apiGroups:
- ""
resources:
- configmaps
- pods
@mgoodness
mgoodness / nginx-ingress-controller-clusterrole.yaml
Created Dec 21, 2017
nginx-ingress-controller ClusterRole
View nginx-ingress-controller-clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: nginx-ingress-controller
rules:
- apiGroups:
- ""
resources:
- configmaps
- endpoints
@mgoodness
mgoodness / kubernetes-dashboard-rbac.md
Created Dec 21, 2017
kubernetes-dashboard RBAC setup for K8s v1.8+ (tested on minikube) Raw
View kubernetes-dashboard-rbac.md
kubectl -n kube-system create sa kubernetes-dashboard
kubectl create clusterrolebinding kubernetes-dashboard --clusterrole cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
kubectl -n kube-system patch rc/kubernetes-dashboard -p '{"spec": {"template": {"spec": {"serviceAccountName": "kubernetes-dashboard"}}}}'
kubectl -n kube-system delete po -l app=kubernetes-dashboard
You can’t perform that action at this time.