Compare commits
2 Commits
dc6bf17452
...
f50d6136b9
Author | SHA1 | Date | |
---|---|---|---|
f50d6136b9 | |||
6462c06743 |
65
home/.bin/kube-template
Executable file
65
home/.bin/kube-template
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
NAMESPACE=""
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
print_usage() {
|
||||||
|
echo "kube-template - Quickly template up kubernetes resources"
|
||||||
|
echo " "
|
||||||
|
echo "kube-template [options] RESOURCE_KIND NAME [extra arguments]"
|
||||||
|
echo " "
|
||||||
|
echo "Options:"
|
||||||
|
echo "-h, --help show this help text"
|
||||||
|
echo "-n, --namespace the namespace the to search in"
|
||||||
|
}
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case "$1" in
|
||||||
|
-n|--namespace)
|
||||||
|
shift
|
||||||
|
NAMESPACE="--namespace $1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
NAME=${2}
|
||||||
|
|
||||||
|
addLabelsAndAnnotations() {
|
||||||
|
yq e '.metadata.labels."app.kubernetes.io/name" = "'${NAME}'" |
|
||||||
|
.metadata.labels."giantswarm.io/user" = "'$(whoami)'" |
|
||||||
|
.metadata.annotations."giantswarm.io/description" = ""' -
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
deployment|dp)
|
||||||
|
kubectl create ${NAMESPACE} deployment ${NAME} --image=nginx:1.21 --dry-run=client -o yaml ${@:3} | addLabelsAndAnnotations
|
||||||
|
;;
|
||||||
|
ingress|in)
|
||||||
|
kubectl create ${NAMESPACE} ingress ${NAME} --dry-run=client -o yaml --rule=example.com/=my-service:web ${@:3} | addLabelsAndAnnotations
|
||||||
|
;;
|
||||||
|
service|svc)
|
||||||
|
kubectl create ${NAMESPACE} service clusterip ${NAME} --dry-run=client -o yaml ${@:3} | addLabelsAndAnnotations
|
||||||
|
;;
|
||||||
|
configmap|cm)
|
||||||
|
kubectl create ${NAMESPACE} configmap ${NAME} --dry-run=client -o yaml ${@:3} | addLabelsAndAnnotations
|
||||||
|
;;
|
||||||
|
secret|sec)
|
||||||
|
kubectl create ${NAMESPACE} secret generic ${NAME} --dry-run=client -o yaml ${@:3} | addLabelsAndAnnotations
|
||||||
|
;;
|
||||||
|
cronjob|cj)
|
||||||
|
kubectl create ${NAMESPACE} cronjob ${NAME} --image=alpine:latest --schedule="1 * * * *" --dry-run=client -o yaml ${@:3} | addLabelsAndAnnotations
|
||||||
|
;;
|
||||||
|
job|jo)
|
||||||
|
kubectl create ${NAMESPACE} job ${NAME} --image=alpine:latest --dry-run=client -o yaml ${@:3} | addLabelsAndAnnotations
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
38
home/.bin/kube-trigger-cronjob
Executable file
38
home/.bin/kube-trigger-cronjob
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
NAMESPACE="$(kubectl config view --minify --output 'jsonpath={..namespace}')"
|
||||||
|
NAMESPACE=${NAMESPACE:-default}
|
||||||
|
|
||||||
|
print_usage() {
|
||||||
|
echo "kube-trigger-cronjob - Triggers a CronJob by creating a new job based on it"
|
||||||
|
echo " "
|
||||||
|
echo "kube-trigger-cronjob [options] CRONJOB_NAME"
|
||||||
|
echo " "
|
||||||
|
echo "Options:"
|
||||||
|
echo "-h, --help show this help text"
|
||||||
|
echo "-n, --namespace the namespace the to search in"
|
||||||
|
}
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case "$1" in
|
||||||
|
-n|--namespace)
|
||||||
|
shift
|
||||||
|
NAMESPACE=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
NAME=${1}
|
||||||
|
|
||||||
|
kubectl create job --namespace ${NAMESPACE} ${NAME}-manual --from=cronjob/${NAME} ${@:3}
|
||||||
|
|
@ -28,7 +28,7 @@ BREW_TOOLS=(
|
|||||||
argocd bandwhich bat danielfoehrkn/switch/switch derailed/k9s/k9s dive dog duf dust exa fd fzf
|
argocd bandwhich bat danielfoehrkn/switch/switch derailed/k9s/k9s dive dog duf dust exa fd fzf
|
||||||
git-delta go helm homebrew/cask-fonts/font-open-dyslexic-nerd-font htop jq kind krew
|
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
|
kubectl kubectx kustomize node procs progress ripgrep rs/tap/curlie rust starship
|
||||||
tektoncd/tools/tektoncd-cli tldr tailscale python-yq hashicorp/tap/vault stats
|
tektoncd/tools/tektoncd-cli tldr tailscale yq hashicorp/tap/vault stats
|
||||||
tabby
|
tabby
|
||||||
)
|
)
|
||||||
CARGO_TOOLS=( macchina bottom )
|
CARGO_TOOLS=( macchina bottom )
|
||||||
|
Loading…
Reference in New Issue
Block a user