Skip to content

Commit

Permalink
cleanup some autocomplete + kube helpers
Browse files Browse the repository at this point in the history
Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed Jun 1, 2022
1 parent a55eca5 commit ea445e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
17 changes: 6 additions & 11 deletions .bash_completion
@@ -1,25 +1,20 @@
#!/bin/bash

[ -f ~/baby/shipcat/shipcat.complete.sh ] && source ~/baby/shipcat/shipcat.complete.sh
[ -f ~/babylon/shipcat/shipcat_cli/shipcat.complete.sh ] && source ~/babylon/shipcat/shipcat_cli/shipcat.complete.sh
[ -f ~/repos/lalfork/lal/lal.complete.sh ] && source ~/repos/lalfork/lal/lal.complete.sh
#[ -f ~/repos/shipcat/shipcat_cli/shipcat.complete.sh ] && source ~/repos/shipcat/shipcat_cli/shipcat.complete.sh
#[ -f ~/repos/lalfork/lal/lal.complete.sh ] && source ~/repos/lalfork/lal/lal.complete.sh

if hash kubectl 2> /dev/null; then
# TODO: allow kg to autocomplete from the kubectl completion
if command -v kubectl &> /dev/null; then
source <(kubectl completion bash)
source <(helm completion bash)
fi

if hash rustup 2> /dev/null; then
if command -v rustup &> /dev/null; then
#source /usr/share/bash-completion/completions/rustup
source <(rustup completions bash)
fi

# NB: can't load paths before this annoyingly..
if [ -x ~/.go/bin/jira ]; then
source <(~/.go/bin/jira --completion-script-bash)
fi

if hash jenq 2> /dev/null; then
if command -v jenq &> /dev/null; then
source <(jenq completions bash)
fi

Expand Down
23 changes: 14 additions & 9 deletions .functions
Expand Up @@ -165,14 +165,6 @@ kl() {
kubectl logs -f "${resource}/${name}" "${container}"
}

# note we don't want this for kubectl get (because it's just for a quick lister)

kevict() {
# want to do status.reason=Evicted but that's not an allowed field selector..
# so can either pipe through a pipeline or do an approximation if we use it carefully
kubectl delete pod --field-selector 'status.phase=Failed'
}

# cluster version checker
kcver() {
for ctx in $(kubectl config get-contexts -o name | grep -v fqdn); do
Expand All @@ -183,12 +175,25 @@ kcver() {

k3dmake() {
k3d cluster create main --servers 1 --agents 1 --registry-create main \
--k3s-arg "--no-deploy=traefik@server:*" \
--no-lb \
--k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*" \
--k3s-arg '--kubelet-arg=eviction-hard=imagefs.available<1%,nodefs.available<1%@agent:*' \
--k3s-arg '--kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%@agent:*'
k3d kubeconfig get --all > ~/.kube/k3d
}

# misc kube helpers
khevict() {
# want to do status.reason=Evicted but that's not an allowed field selector..
# so can either pipe through a pipeline or do an approximation if we use it carefully
#kubectl delete pod --field-selector 'status.phase=Failed'
kubectl get pods | awk '/Evicted/ {print $1}' | xargs kubectl delete pod
}
khleftovers() {
kubectl api-resources --verbs=list --namespaced -o name \
| xargs -n 1 kubectl get --show-kind --ignore-not-found
}

nmap-kube () {
nmap --open -T4 -A -v -Pn -p 443,2379,4194,6782-6784,6443,8443,8080,9099,10250,10255,10256 "${@}"
}
Expand Down

0 comments on commit ea445e8

Please sign in to comment.