Compare commits
5 Commits
deb5a86b92
...
beaa8fff5b
Author | SHA1 | Date | |
---|---|---|---|
|
beaa8fff5b | ||
|
60584cbc68 | ||
|
bb0f3ffc7b | ||
|
6fed8d09b5 | ||
|
086435d6a7 |
2
.bashrc
2
.bashrc
@ -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)" != "exsilio" ]] && export PS1_COLOR_HOSTNAME="\[\033[0;33m\]"
|
[[ "$(hostname)" != "pingue" ]] && export PS1_COLOR_HOSTNAME="\[\033[0;33m\]"
|
||||||
|
|
||||||
#exit with no error
|
#exit with no error
|
||||||
/bin/true
|
/bin/true
|
||||||
|
@ -8,3 +8,4 @@ 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
|
||||||
|
@ -79,3 +79,51 @@ 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
|
||||||
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
function upgrade_tools(){
|
function upgrade_tools(){
|
||||||
new_log "Install client tools"
|
echo "Install/Upgrade 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')
|
||||||
@ -53,24 +52,9 @@ function upgrade_tools(){
|
|||||||
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 --strip-components=1 stern_${STERN_STABLE:1}_linux_amd64/stern
|
tar xvzf stern_${STERN_STABLE:1}_linux_amd64.tar.gz stern
|
||||||
rm stern_${STERN_STABLE:1}_linux_amd64.tar.gz
|
rm stern_${STERN_STABLE:1}_linux_amd64.tar.gz
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "---- virtctl ----"
|
cd "$CURRENT_PWD"
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
15
bin/backup.sh
Executable file
15
bin/backup.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/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
|
Loading…
Reference in New Issue
Block a user