parent
48ad89385b
commit
3990c8fd9c
@ -1,24 +0,0 @@ |
||||
alias aws='docker pull -q amazon/aws-cli:latest 1> /dev/null && docker run --rm -i -v ~/.aws:/root/.aws -v $(pwd):/aws -e NO_COLOR=true -e AWS_PROFILE -e AWS_DEFAULT_REGION -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN amazon/aws-cli' |
||||
|
||||
assume-role() { |
||||
ROLE=$1 |
||||
|
||||
if [[ -z "$ROLE" ]]; then |
||||
export AWS_ACCESS_KEY_ID= |
||||
export AWS_SECRET_ACCESS_KEY= |
||||
export AWS_SESSION_TOKEN= |
||||
else |
||||
OUTPUT=$(aws sts assume-role --role-arn $ROLE --role-session-name assumed-role-session --query Credentials --output json) |
||||
|
||||
export AWS_ACCESS_KEY_ID=$(echo $OUTPUT | jq -r .AccessKeyId) |
||||
export AWS_SECRET_ACCESS_KEY=$(echo $OUTPUT | jq -r .SecretAccessKey) |
||||
export AWS_SESSION_TOKEN=$(echo $OUTPUT | jq -r .SessionToken) |
||||
fi |
||||
|
||||
aws sts get-caller-identity |
||||
} |
||||
|
||||
aws-decode-message() { |
||||
ENCODED=$1 |
||||
aws sts decode-authorization-message --query DecodedMessage --output text --encoded-message $ENCODED | jq -r '.context.action, .context.resource' |
||||
} |
@ -1,13 +0,0 @@ |
||||
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 |
||||
|
||||
eval "$(starship init zsh)" |
@ -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} |
@ -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 $@ |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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) |
@ -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 # |
||||
"######################################## |
||||
|
@ -0,0 +1,5 @@ |
||||
colorscheme tickle-contrast |
||||
set paste |
||||
set number |
||||
set linespace=3 |
||||
set cursorline |
@ -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)" |
@ -0,0 +1,101 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH" |
||||
|
||||
GITEMAIL=$(git config --get user.email) |
||||
|
||||
[ -d ~/.additional_dotfiles ] || (mkdir -p ~/.additional_dotfiles && touch ~/.additional_dotfiles/credentials) |
||||
|
||||
# Install homebrew |
||||
which brew >/dev/null || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
||||
|
||||
echo "🔵 Setting up zsh" |
||||
|
||||
# Install oh-my-zsh |
||||
printf "Cloning oh-my-zsh..." |
||||
[ -d ~/.oh-my-zsh ] || sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
||||
printf " ✅\n" |
||||
|
||||
# Install ZSH plugins |
||||
printf "Cloning zsh plugins..." |
||||
[ -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ] || git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions |
||||
[ -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting |
||||
printf " ✅\n" |
||||
|
||||
# Install tools |
||||
BREW_TOOLS=( |
||||
argocd bandwhich bat danielfoehrkn/switch/switch derailed/k9s/k9s dive dog duf dust exa fd fzf |
||||
git-delta git-delta go helm homebrew/cask-fonts/font-open-dyslexic-nerd-font htop jq kind krew |
||||
kubectl kubectx kustomize node procs progress ripgrep rs/tap/curlie rust starship |
||||
tektoncd/tools/tektoncd-cli tldr tailscale |
||||
) |
||||
CARGO_TOOLS=( macchina bottom ) |
||||
NODE_TOOLS=( git-split-diffs ) |
||||
KREW_TOOLS=( gs ) |
||||
|
||||
echo "🔵 Installing / updating tools" |
||||
|
||||
# Homebrew |
||||
export HOMEBREW_NO_INSTALL_CLEANUP=true |
||||
for tool in "${BREW_TOOLS[@]}" |
||||
do |
||||
printf "${tool}..." |
||||
brew upgrade ${tool} &>/dev/null || brew install ${tool} &>/dev/null |
||||
printf " ✅\n" |
||||
done |
||||
|
||||
# Cargo |
||||
for tool in "${CARGO_TOOLS[@]}" |
||||
do |
||||
printf "${tool}..." |
||||
cargo install ${tool} &>/dev/null |
||||
printf " ✅\n" |
||||
done |
||||
|
||||
# Krew |
||||
kubectl-krew update &>/dev/null |
||||
for tool in "${KREW_TOOLS[@]}" |
||||
do |
||||
printf "${tool}..." |
||||
kubectl-krew upgrade ${tool} &>/dev/null || kubectl-krew install ${tool} &>/dev/null |
||||
printf " ✅\n" |
||||
done |
||||
|
||||
echo "🔵 Adding configuration" |
||||
FILES=$(find ./home -maxdepth 1 -mindepth 1 -printf '%f ') |
||||
for file in $FILES |
||||
do |
||||
f=$(readlink -f "./home/${file}") |
||||
printf "Linking ${f}..." |
||||
ln -sfn ${f} ~/$(basename "./home/${file}") |
||||
printf " ✅\n" |
||||
done |
||||
|
||||
|
||||
echo "🔵 OS Specific setup" |
||||
echo "Detected OS type: ${OSTYPE}" |
||||
|
||||
case "${OSTYPE}" in |
||||
*linux*) |
||||
# Do stuff |
||||
;; |
||||
*darwin*) |
||||
# Mac specific setup |
||||
BREW_TOOLS=( pinentry-mac gpg gawk coreutils ) |
||||
for tool in "${MAC_BREW_TOOLS[@]}" |
||||
do |
||||
printf "${tool}..." |
||||
brew upgrade ${tool} &>/dev/null || brew install ${tool} &>/dev/null |
||||
printf " ✅\n" |
||||
done |
||||
|
||||
FILES=$(find ./os-specific/darwin/home -maxdepth 1 -mindepth 1 -printf '%f ') |
||||
for file in $FILES |
||||
do |
||||
f=$(readlink -f "./os-specific/darwin/home/${file}") |
||||
printf "Linking ${f}..." |
||||
ln -sfn ${f} ~/$(basename "./os-specific/darwin/home/${file}") |
||||
printf " ✅\n" |
||||
done |
||||
;; |
||||
esac |
Loading…
Reference in new issue