Cleanup bugfixes. Move vars to dedicated files
This commit is contained in:
parent
d46b475e1b
commit
6721e05387
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
stopdls() {
|
stopdls() {
|
||||||
if docker ps &>/dev/null | grep -q " $DLS_CTR_NAME$"; then
|
if docker ps | grep -q " $DLS_CTR_NAME$"; then
|
||||||
pinfo "Stopping Direktil Local Server..."
|
pinfo "Stopping Direktil Local Server..."
|
||||||
docker stop $DLS_CTR_NAME
|
docker stop $DLS_CTR_NAME
|
||||||
fi
|
fi
|
||||||
@ -28,14 +28,20 @@ cleanuppaths() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanupssh() {
|
||||||
|
for host in ${!hosts[*]}; do
|
||||||
|
ssh-keygen -R ${hosts[$host]} &>/dev/null
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
cleanupnetwork() {
|
cleanupnetwork() {
|
||||||
if iptables -L |grep -q $QEMU_BR_NAME; then
|
if iptables -L -n |grep -q $QEMU_BR_NAME; then
|
||||||
pinfo "Cleaning iptables rules..."
|
pinfo "Cleaning iptables rules..."
|
||||||
iptables -t nat -D POSTROUTING -j MASQUERADE -s $QEMU_BR_IP/$QEMU_BR_MASK \! -o $QEMU_BR_NAME
|
iptables -t nat -D POSTROUTING -j MASQUERADE -s $QEMU_BR_IP/$QEMU_BR_MASK \! -o $QEMU_BR_NAME
|
||||||
iptables -D FORWARD -o $QEMU_BR_NAME -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
iptables -D FORWARD -o $QEMU_BR_NAME -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
||||||
iptables -D FORWARD -j ACCEPT -i $QEMU_BR_NAME
|
iptables -D FORWARD -j ACCEPT -i $QEMU_BR_NAME
|
||||||
fi
|
fi
|
||||||
if ip li show $QEMU_BR_NAME ; then
|
if ip li show $QEMU_BR_NAME &>/dev/null; then
|
||||||
pinfo "Cleaning existing interfaces..."
|
pinfo "Cleaning existing interfaces..."
|
||||||
ip li set $QEMU_BR_NAME down
|
ip li set $QEMU_BR_NAME down
|
||||||
ip li del $QEMU_BR_NAME
|
ip li del $QEMU_BR_NAME
|
||||||
@ -50,3 +56,5 @@ declare -A hosts
|
|||||||
get_hosts
|
get_hosts
|
||||||
destroyvms
|
destroyvms
|
||||||
cleanuppaths
|
cleanuppaths
|
||||||
|
cleanupssh
|
||||||
|
cleanupnetwork
|
||||||
|
@ -1,24 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
## Vars
|
source $(dirname $0)/vars
|
||||||
# Docker container name for dir2config
|
|
||||||
D2C_CTR_NAME=dir2config
|
|
||||||
# Docker container name for direktil local server
|
|
||||||
DLS_CTR_NAME=dls
|
|
||||||
|
|
||||||
# QEMU local bridge name. If you specificy a custom name, you may have to configure qemu bridge helper to allow it
|
|
||||||
QEMU_BR_NAME=virbr0
|
|
||||||
# QEMU VM default disk size
|
|
||||||
QEMU_DISK_SIZE=30G
|
|
||||||
# Allocated CPUs to QEMU VMs
|
|
||||||
QEMU_VM_CPU=4
|
|
||||||
# Allocated Memory to QEMU VMs
|
|
||||||
QEMU_VM_MEM=8096
|
|
||||||
################
|
|
||||||
|
|
||||||
# Token file for dls
|
|
||||||
tknfile=".dls_adm_token"
|
|
||||||
|
|
||||||
|
|
||||||
## Helper funcs
|
## Helper funcs
|
||||||
|
|
||||||
@ -57,9 +39,10 @@ check_root() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prereqs() {
|
prereqs() {
|
||||||
# set -ex
|
set -e
|
||||||
cd "$(dirname $0)/.."
|
cd "$(dirname $0)/.."
|
||||||
ctxdir="$PWD"
|
ctxdir="$PWD"
|
||||||
|
source scripts/vars
|
||||||
}
|
}
|
||||||
|
|
||||||
check_conf() {
|
check_conf() {
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Admin token to unlock the DLS store
|
|
||||||
DLS_UNLOCK_TOKEN=changeme
|
|
||||||
#
|
|
||||||
#
|
|
||||||
D2C_IMG=novit.tech/direktil/local-server:b6fa941
|
|
||||||
DLS_IMG=novit.tech/direktil/local-server:b6fa941
|
|
||||||
|
|
||||||
prereqs_dls() {
|
prereqs_dls() {
|
||||||
command -v docker 1>/dev/null || perror "Docker is needed, please install it and run again."
|
command -v docker 1>/dev/null || perror "Docker is needed, please install it and run again."
|
||||||
@ -39,8 +33,8 @@ start_store() {
|
|||||||
|
|
||||||
source $(dirname $0)/.common
|
source $(dirname $0)/.common
|
||||||
check_root
|
check_root
|
||||||
prereqs_dls
|
|
||||||
prereqs
|
prereqs
|
||||||
|
prereqs_dls
|
||||||
dir2config
|
dir2config
|
||||||
start_store
|
start_store
|
||||||
unlock_store
|
unlock_store
|
||||||
|
@ -14,7 +14,7 @@ prereqs_qemu() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
setup_network_qemu() {
|
setup_network_qemu() {
|
||||||
if ! ip li show $QEMU_BR_NAME ; then
|
if ! ip li show $QEMU_BR_NAME &>/dev/null ; then
|
||||||
ip li add name $QEMU_BR_NAME type bridge
|
ip li add name $QEMU_BR_NAME type bridge
|
||||||
ip li set $QEMU_BR_NAME up
|
ip li set $QEMU_BR_NAME up
|
||||||
fi
|
fi
|
||||||
|
@ -47,6 +47,24 @@ EOF
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_for_apiserver() {
|
||||||
|
vip=$(extract_var clusters public_vip)
|
||||||
|
vip_api_port=$(extract_var clusters api_port)
|
||||||
|
|
||||||
|
sleep 20
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
pinfo "Waiting for apiserver availability ($vip:$vip_api_port). Images may still being pulled... "
|
||||||
|
if kctl get node &>/dev/null ; then
|
||||||
|
pinfo "API is up!"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 30
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
install_addons() {
|
install_addons() {
|
||||||
body='{"Kind":"cluster","Name":"'$cluster'","Assets":["addons"]}'
|
body='{"Kind":"cluster","Name":"'$cluster'","Assets":["addons"]}'
|
||||||
download_id=$(dls /authorize-download -d "$body"|tr -d \")
|
download_id=$(dls /authorize-download -d "$body"|tr -d \")
|
||||||
@ -82,6 +100,7 @@ unlock_store
|
|||||||
declare -A hosts && get_hosts
|
declare -A hosts && get_hosts
|
||||||
checkup
|
checkup
|
||||||
start_control_plane
|
start_control_plane
|
||||||
|
wait_for_apiserver
|
||||||
create_kubeconfig
|
create_kubeconfig
|
||||||
install_addons
|
install_addons
|
||||||
approve_kubelet_certificates # clients and serving certs
|
approve_kubelet_certificates # clients and serving certs
|
||||||
|
28
scripts/vars
Normal file
28
scripts/vars
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
## Vars
|
||||||
|
|
||||||
|
# Admin token to unlock the DLS store
|
||||||
|
DLS_UNLOCK_TOKEN=changeme
|
||||||
|
|
||||||
|
# Docker container name for dir2config
|
||||||
|
D2C_IMG=novit.tech/direktil/local-server:b6fa941
|
||||||
|
D2C_CTR_NAME=dir2config
|
||||||
|
|
||||||
|
# Docker container name for direktil local server
|
||||||
|
DLS_IMG=novit.tech/direktil/local-server:b6fa941
|
||||||
|
DLS_CTR_NAME=dls
|
||||||
|
|
||||||
|
# QEMU local bridge name. If you specificy a custom name, you may have to configure qemu bridge helper to allow it
|
||||||
|
QEMU_BR_NAME=virbr0
|
||||||
|
# QEMU VM default disk size
|
||||||
|
QEMU_DISK_SIZE=30G
|
||||||
|
# Allocated CPUs to QEMU VMs
|
||||||
|
QEMU_VM_CPU=4
|
||||||
|
# Allocated Memory to QEMU VMs
|
||||||
|
QEMU_VM_MEM=8096
|
||||||
|
################
|
||||||
|
|
||||||
|
# Token file for dls
|
||||||
|
tknfile=".dls_adm_token"
|
||||||
|
|
||||||
|
# SSH command args
|
||||||
|
SSH_CMD="ssh -o StrictHostKeyChecking=no"
|
Loading…
Reference in New Issue
Block a user