Make things pretty
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
b9647b569d
commit
381adefe87
39
home/.bin/.utils
Normal file
39
home/.bin/.utils
Normal file
@ -0,0 +1,39 @@
|
||||
END_CHARS="\e[0m\n"
|
||||
tput colors &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
bold() {
|
||||
printf "\e[1m$@${END_CHARS}"
|
||||
}
|
||||
|
||||
italic() {
|
||||
printf "\e[3m$@${END_CHARS}"
|
||||
}
|
||||
|
||||
underline() {
|
||||
printf "\e[4m$@${END_CHARS}"
|
||||
}
|
||||
|
||||
orange() {
|
||||
printf "\e[38;5;208m$@${END_CHARS}"
|
||||
}
|
||||
|
||||
blue() {
|
||||
printf "\e[38;5;75m$@${END_CHARS}"
|
||||
}
|
||||
else
|
||||
bold() {
|
||||
echo $@
|
||||
}
|
||||
|
||||
italic() {
|
||||
echo $@
|
||||
}
|
||||
|
||||
underline() {
|
||||
echo $@
|
||||
}
|
||||
|
||||
orange() {
|
||||
echo $@
|
||||
}
|
||||
fi
|
@ -1,17 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source .utils
|
||||
|
||||
ACCOUNT_ID=${AWS_ACCOUNTID}
|
||||
ROLE=GiantSwarmAdmin
|
||||
MFA=
|
||||
MFA_ARN=arn:aws:iam::${AWS_ACCOUNTID}:mfa/marcus@giantswarm.io
|
||||
|
||||
print_usage() {
|
||||
echo "gs-aws - set up AWS credentials"
|
||||
orange "gs-aws - set up AWS credentials"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "gs-aws"
|
||||
echo " "
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
echo "-a, --account the AWS account number (default: \$AWS_ACCOUNTID)"
|
||||
echo "-r, --role the role to assume (default: GiantSwarmAdmin)"
|
||||
|
@ -1,17 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source .utils
|
||||
|
||||
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"
|
||||
orange "gs-create-cluster - create a Giant Swarm managed workload cluster"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "gs-create-cluster [cluster-name]"
|
||||
echo " "
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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)"
|
||||
|
@ -1,16 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source .utils
|
||||
|
||||
set -e
|
||||
|
||||
NAMESPACE="org-giantswarm"
|
||||
|
||||
print_usage() {
|
||||
echo "gs-get-cluster - get a Giant Swarm managed workload cluster"
|
||||
orange "gs-get-cluster - get a Giant Swarm managed workload cluster"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "gs-get-cluster [cluster-name]"
|
||||
echo " "
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
echo "-n, --namespace the namespace the cluster is in (default: org-giantswarm)"
|
||||
}
|
||||
|
@ -1,17 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source .utils
|
||||
|
||||
DEBUG=""
|
||||
|
||||
print_usage() {
|
||||
echo "gs-login - login to Giant Swarm managed clusters"
|
||||
orange "gs-login - login to Giant Swarm managed clusters"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "gs-login [INSTALLATION] [WORKLOAD CLUSTER] [ORGANISATION]"
|
||||
echo " "
|
||||
echo "Examples:"
|
||||
underline "Examples:"
|
||||
echo "> gs-login gauss"
|
||||
echo "> gs-login gauss mywc1"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source .utils
|
||||
|
||||
DEBUG=""
|
||||
|
||||
SUPPORTED_APPS="alertmanager argocd grafana happa kibana kyverno prometheus"
|
||||
SUPPORTED_APPS="alertmanager cloudprovider grafana happa kibana kyverno prometheus"
|
||||
|
||||
print_usage() {
|
||||
echo "gs-open - open apps on Giant Swarm clusters"
|
||||
orange "gs-open - open apps on Giant Swarm clusters"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "gs-open [APP] [INSTALLATION] [WORKLOAD CLUSTER] "
|
||||
echo " "
|
||||
echo "Examples:"
|
||||
underline "Supported apps:"
|
||||
italic "${SUPPORTED_APPS}"
|
||||
echo " "
|
||||
underline "Examples:"
|
||||
echo "> gs-open prometheus gauss"
|
||||
echo "> gs-open alertmanager gauss mywc1"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
echo " --debug show debug log output"
|
||||
}
|
||||
@ -48,17 +54,25 @@ if [ ${#POS_ARGS[@]} -eq 1 ]; then
|
||||
POS_ARGS+=(`opsctl list installations --short | tr ' ' '\n' | fzf`)
|
||||
fi
|
||||
|
||||
APP=${POS_ARGS[0]}
|
||||
if [[ "${APP}" == "cloud" ]]; then
|
||||
APP=cloudprovider
|
||||
fi
|
||||
if [[ "${APP}" == "prom" ]]; then
|
||||
APP=prometheus
|
||||
fi
|
||||
|
||||
case ${#POS_ARGS[@]} in
|
||||
0)
|
||||
print_usage
|
||||
exit 1
|
||||
;;
|
||||
2)
|
||||
echo "✨ Opening ${POS_ARGS[0]} on ${POS_ARGS[1]}"
|
||||
opsctl open ${DEBUG} --app ${POS_ARGS[0]} --installation ${POS_ARGS[1]}
|
||||
echo "✨ Opening ${APP} on ${POS_ARGS[1]}"
|
||||
opsctl open ${DEBUG} --app ${APP} --installation ${POS_ARGS[1]}
|
||||
;;
|
||||
3)
|
||||
echo "✨ Opening ${POS_ARGS[0]} on ${POS_ARGS[1]}/${POS_ARGS[2]}"
|
||||
opsctl open ${DEBUG} --app ${POS_ARGS[0]} --installation ${POS_ARGS[1]} --workload-cluster ${POS_ARGS[2]}
|
||||
echo "✨ Opening ${APP} on ${POS_ARGS[1]} / ${POS_ARGS[2]}"
|
||||
opsctl open ${DEBUG} --app ${APP} --installation ${POS_ARGS[1]} --workload-cluster ${POS_ARGS[2]}
|
||||
;;
|
||||
esac
|
||||
|
@ -1,14 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source .utils
|
||||
|
||||
set -e
|
||||
|
||||
print_usage() {
|
||||
echo "gs-release - create a new release of a Giant Swarm repo"
|
||||
orange "gs-release - create a new release of a Giant Swarm repo"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "gs-release [SEMVER LEVEL]"
|
||||
echo " "
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
LABEL=""
|
||||
ALL_NAMESPACES=false
|
||||
|
||||
print_usage() {
|
||||
echo "kube-all - A better 'kubectl get all' - actually get all Kubernetes resources, including custom resources"
|
||||
blue "kube-all - A better 'kubectl get all' - actually get all Kubernetes resources, including custom resources"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-all [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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"
|
||||
|
@ -1,17 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
LABEL=""
|
||||
ALL_NAMESPACES=false
|
||||
|
||||
print_usage() {
|
||||
echo "kube-clean-replicasets - Remove all olf ReplicaSets with 0 desired pods"
|
||||
blue "kube-clean-replicasets - Remove all olf ReplicaSets with 0 desired pods"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-clean-replicasets [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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"
|
||||
|
@ -1,17 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
POD=""
|
||||
CMD="sh"
|
||||
|
||||
print_usage() {
|
||||
echo "kube-exec - execute commands within a pod"
|
||||
blue "kube-exec - execute commands within a pod"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-exec [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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"
|
||||
|
@ -1,16 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
|
||||
print_usage() {
|
||||
echo "kube-force-delete - Force delete resources, even those with finalizers"
|
||||
blue "kube-force-delete - Force delete resources, even those with finalizers"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-force-delete [RESOURCE_TYPE] [RESOURCE_NAME]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
echo "-n, --namespace the namespace the resource is in (default: current namespace)"
|
||||
}
|
||||
|
@ -1,16 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
HOST_PORT=10001
|
||||
|
||||
print_usage() {
|
||||
echo "kube-forward-all - create port-forwards for all pods in the given namespace"
|
||||
blue "kube-forward-all - create port-forwards for all pods in the given namespace"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-forward-all [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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)"
|
||||
|
@ -1,17 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
POD=""
|
||||
ARGS=""
|
||||
|
||||
print_usage() {
|
||||
echo "kube-logs - tail logs from a pod"
|
||||
blue "kube-logs - tail logs from a pod"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-logs [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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"
|
||||
|
@ -1,16 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
NAMESPACE="-A"
|
||||
|
||||
print_usage() {
|
||||
echo "kube-restarting - Show all pods with restarts"
|
||||
blue "kube-restarting - Show all pods with restarts"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-restarting [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
echo "-n, --namespace the namespace the to search in (searches all if not set)"
|
||||
}
|
||||
|
@ -1,18 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
POD="shell"
|
||||
IMAGE="bash"
|
||||
CMD="sh"
|
||||
|
||||
print_usage() {
|
||||
echo "kube-shell - create a new pod and exec into it's shell"
|
||||
blue "kube-shell - create a new pod and exec into it's shell"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-shell [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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)"
|
||||
|
@ -1,18 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
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)"
|
||||
blue "kube-ssh - gain access to a Kubernetes host node (ssh-like for when a host doesn't have ssh)"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-ssh [options]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "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)"
|
||||
|
@ -1,15 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
NAMESPACE=""
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
|
||||
print_usage() {
|
||||
echo "kube-template - Quickly template up kubernetes resources"
|
||||
blue "kube-template - Quickly template up kubernetes resources"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-template [options] RESOURCE_KIND NAME [extra arguments]"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
echo "-n, --namespace the namespace the to search in"
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source .utils
|
||||
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}' &>/dev/null)"
|
||||
set -e
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
|
||||
print_usage() {
|
||||
echo "kube-trigger-cronjob - Triggers a CronJob by creating a new job based on it"
|
||||
blue "kube-trigger-cronjob - Triggers a CronJob by creating a new job based on it"
|
||||
echo " "
|
||||
underline "Usage:"
|
||||
echo "kube-trigger-cronjob [options] CRONJOB_NAME"
|
||||
echo " "
|
||||
echo "Options:"
|
||||
underline "Options:"
|
||||
echo "-h, --help show this help text"
|
||||
echo "-n, --namespace the namespace the to search in"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user