Compare commits

..

No commits in common. "beaa8fff5b8d0b9c01472928ef4113eff62fd3c4" and "deb5a86b92253ea98fa30dc5585a4755fb9fdad2" have entirely different histories.

5 changed files with 22 additions and 70 deletions

View File

@ -37,7 +37,7 @@ fi
# shellcheck disable=1090 # shellcheck disable=1090
[[ -d "$HOME/.rbenv/bin" ]] && export PATH="$HOME/.rbenv/bin:$PATH" && eval "$(rbenv init -)" [[ -d "$HOME/.rbenv/bin" ]] && export PATH="$HOME/.rbenv/bin:$PATH" && eval "$(rbenv init -)"
[[ "$(hostname)" != "pingue" ]] && export PS1_COLOR_HOSTNAME="\[\033[0;33m\]" [[ "$(hostname)" != "exsilio" ]] && export PS1_COLOR_HOSTNAME="\[\033[0;33m\]"
#exit with no error #exit with no error
/bin/true /bin/true

View File

@ -8,4 +8,3 @@ Categories=Network
Type=Application Type=Application
StartupNotify=false StartupNotify=false
X-GNOME-Autostart-enabled=true X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-Delay=10

View File

@ -79,51 +79,3 @@ function k8s_neuvector_cve_db_version(){
function k8s_node_taints(){ function k8s_node_taints(){
kubectl get nodes -o json | jq '.items[].spec.taints' kubectl get nodes -o json | jq '.items[].spec.taints'
} }
function k8s_apps(){
# parameters,
# stop = Set all deployments & statefultsets to replica=0
# start = set all deployments & statefulsets to replica=1
# show = show status of all deployments & statefulsets
CHOICE="$1"
if [[ ! "start stop show" =~ (" "|^)"$CHOICE"(" "|$) ]]; then
echo "no parameter given"
return 1
fi
local USER_PROJECT_IDS=(p-c5fcj p-q8pbm)
local OK='\e[32m\u2714\e[0m'
local NOT_OK='\u274c'
printf "%-22s %s\n" "namespace" "application"
printf -- '-%.0s' {1..34}
printf "\n"
for PROJECT in "${USER_PROJECT_IDS[@]}"; do
for NS in $(kubectl get namespaces --selector=field.cattle.io/projectId="$PROJECT" --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do
for DEPLOYMENT in $(kubectl --namespace "$NS" get deployments --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do
if [[ "$CHOICE" == "stop" ]];then
kubectl --namespace "$NS" scale deployment "$DEPLOYMENT" --replicas=0 > /dev/null
elif [[ "$CHOICE" == "start" ]];then
kubectl --namespace "$NS" scale deployment "$DEPLOYMENT" --replicas=1 > /dev/null
fi
if [[ $(kubectl --namespace "$NS" get deployments "$DEPLOYMENT" -o jsonpath='{.spec.replicas}') == "0" ]];then
echo -n -e "$NOT_OK "
else
echo -n -e "$OK "
fi
printf "%-20s %s\n" "$NS" "$DEPLOYMENT"
done
for STATEFULSET in $(kubectl --namespace "$NS" get statefulsets --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do
if [[ "$CHOICE" == "stop" ]];then
kubectl --namespace "$NS" scale statefulset "$STATEFULSET" --replicas=0 > /dev/null
elif [[ "$CHOICE" == "start" ]];then
kubectl --namespace "$NS" scale statefulset "$STATEFULSET" --replicas=1 > /dev/null
fi
if [[ $(kubectl --namespace "$NS" get statefulsets "$STATEFULSET" -o jsonpath='{.spec.replicas}') == "0" ]];then
echo -n -e "$NOT_OK "
else
echo -n -e "$OK "
fi
printf "%-20s %s\n" "$NS" "$STATEFULSET"
done
done
done
}

View File

@ -1,14 +1,15 @@
function upgrade_tools(){ function upgrade_tools(){
echo "Install/Upgrade client tools" new_log "Install client tools"
echo "- kubectl" echo "- kubectl"
echo "- helm" echo "- helm"
echo "- stern" echo "- stern"
echo "- virtctl"
if asktobreak; then if asktobreak; then
return return
fi fi
set +e
echo "---- kubectl ----" echo "---- kubectl ----"
local CURRENT_PWD="$(pwd)"
cd $HOME/bin cd $HOME/bin
if [[ -f kubectl ]]; then if [[ -f kubectl ]]; then
KUBECTL_CURRENT=$(./kubectl version --client 2> /dev/null| sed -n 's/.* GitVersion:"\(v[0-9]*\.[0-9]*\.[0-9]*\)".*/\1/p') KUBECTL_CURRENT=$(./kubectl version --client 2> /dev/null| sed -n 's/.* GitVersion:"\(v[0-9]*\.[0-9]*\.[0-9]*\)".*/\1/p')
@ -51,10 +52,25 @@ function upgrade_tools(){
echo "Latest stable version: $STERN_STABLE" echo "Latest stable version: $STERN_STABLE"
if [[ "$STERN_CURRENT" != "$STERN_STABLE" ]]; then if [[ "$STERN_CURRENT" != "$STERN_STABLE" ]]; then
echo "updating to $STERN_STABLE" echo "updating to $STERN_STABLE"
curl -LO https://github.com/stern/stern/releases/download/$STERN_STABLE/stern_${STERN_STABLE:1}_linux_amd64.tar.gz curl -LO https://github.com/stern/stern/releases/download/$STERN_STABLE/stern_${STERN_STABLE:1}_linux_amd64.tar.gz
tar xvzf stern_${STERN_STABLE:1}_linux_amd64.tar.gz stern tar xvzf stern_${STERN_STABLE:1}_linux_amd64.tar.gz --strip-components=1 stern_${STERN_STABLE:1}_linux_amd64/stern
rm stern_${STERN_STABLE:1}_linux_amd64.tar.gz rm stern_${STERN_STABLE:1}_linux_amd64.tar.gz
fi fi
echo "" echo ""
cd "$CURRENT_PWD" echo "---- virtctl ----"
if [[ -f stern ]]; then
VIRTCTL_CURRENT="$(./virtctl version --client 2> /dev/null| sed -n 's/.*GitVersion:"\(v[0-9]*\.[0-9]*\.[0-9]*\)".*/\1/p')"
else
VIRTCTL_CURRENT="N/A"
fi
VIRTCTL_STABLE="$(curl -Ls https://github.com/kubevirt/kubevirt/releases | egrep 'href="/kubevirt/kubevirt/releases/tag/v[0-9]+.[0-9]+.[0-9]+*\"' | head -n 1 | sed -n 's/.*tag\/\(v.*\)" data.*/\1/p')"
echo "Installed version: $VIRTCTL_CURRENT"
echo "Latest stable version: $VIRTCTL_STABLE"
if [[ "$VIRTCTL_CURRENT" != "$VIRTCTL_STABLE" ]]; then
echo "updating to $VIRTCTL_STABLE"
curl -Lo virtctl https://github.com/kubevirt/kubevirt/releases/download/$VIRTCTL_STABLE/virtctl-$VIRTCTL_STABLE-linux-amd64
chmod +x ./virtctl
fi
echo ""
set -e
} }

View File

@ -1,15 +0,0 @@
#!/bin/bash
set -aeou pipefail
RESTIC=/usr/bin/restic
# some helpers and error handling:
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
# shellcheck disable=SC1090
source "${HOME}"/.restic/restic.env
$RESTIC backup \
--exclude-file="$HOME"/.restic/excludes.txt \
--files-from="$HOME"/.restic/includes.txt \
--verbose