123 lines
6.9 KiB
Bash
123 lines
6.9 KiB
Bash
#!/bin/sh
|
|
|
|
source ./tmaxcloud.conf
|
|
|
|
ESC=`printf "\033"`;
|
|
|
|
input_key() {
|
|
read -s -n3 INPUT;
|
|
echo $INPUT;
|
|
}
|
|
|
|
check_selected() {
|
|
if [ $1 = $2 ];
|
|
then echo " => "
|
|
else echo " "
|
|
fi
|
|
}
|
|
|
|
select_menu() {
|
|
SELECTED=1;
|
|
INPUT="";
|
|
MIN_MENU=1;
|
|
MAX_MENU=$#;
|
|
|
|
while true;
|
|
do
|
|
for (( i=1; i<=$#; i++))
|
|
do
|
|
printf "$ESC[2K$(check_selected $i $SELECTED) $i. ${!i}\n";
|
|
done
|
|
printf "\n$ESC[2Ke-mail : sa_8001@jhcloud.kr\nmake.202201031\n";
|
|
INPUT=$(input_key);
|
|
if [[ $INPUT = "" ]];
|
|
then break;
|
|
fi
|
|
|
|
if [[ $INPUT = $ESC[A ]];
|
|
then SELECTED=$(expr $SELECTED - 1);
|
|
elif [[ $INPUT = $ESC[B ]];
|
|
then SELECTED=$(expr $SELECTED + 1);
|
|
fi
|
|
|
|
if [[ $SELECTED -lt $MIN_MENU ]];
|
|
then SELECTED=${MIN_MENU};
|
|
elif [[ $SELECTED -gt $MAX_MENU ]];
|
|
then SELECTED=${MAX_MENU};
|
|
fi
|
|
|
|
printf "$ESC[$(expr $# + 3)A";
|
|
done
|
|
return `expr ${SELECTED} - 1`;
|
|
}
|
|
|
|
select_test() {
|
|
arr_params=("Inventory Settings" "Install K8S infra" "Install argocd-installer" "Show argocd password" "Reset Cluster");
|
|
echo -e "\nWelmcome! HyperCloud Helper\nChoose your job\n";
|
|
select_menu "${arr_params[@]}";
|
|
local SELECTED=$?;
|
|
SELECTED_MODE=${arr_params[${SELECTED}]};
|
|
}
|
|
|
|
main() {
|
|
select_test;
|
|
if [ $SELECTED -eq 1 ]
|
|
then
|
|
all_node=(${master_node_name[@]} ${worker_node_name[@]})
|
|
all_node_ip=(${master_node_ip[@]} ${worker_node_ip[@]})
|
|
echo "[all]" > ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
for ((i=0; i<${#all_node[@]}; i++));
|
|
do
|
|
echo ${all_node[i]} "ansible_host="${all_node_ip[i]} "ip="${all_node_ip[i]} >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
done
|
|
echo "" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
echo "[kube_control_plane]" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
for ((i=0; i<${#master_node_name[@]}; i++));
|
|
do
|
|
echo ${master_node_name[i]} >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
done
|
|
echo "" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
echo "[etcd]" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
for ((i=0; i<${#master_node_name[@]}; i++));
|
|
do
|
|
echo ${master_node_name[i]} >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
done
|
|
echo "" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
echo "[kube_node]" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
for ((i=0; i<${#worker_node_name[@]}; i++));
|
|
do
|
|
echo ${worker_node_name[i]} >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
done
|
|
echo "" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
echo -e "[calico_rr]\n\n[k8s_cluster:children]\nkube_control_plane\nkube_node\ncalico_rr" >> ./1.infra-installer/inventory/tmaxcloud/inventory.ini
|
|
cp ./1.infra-installer/inventory/tmaxcloud/inventory.ini ./2.argocd-installer/inventory/tmaxcloud/inventory.ini
|
|
echo -e "\n\033[93mSettings Done! choose menu 2\033[0m"
|
|
main
|
|
elif [ $SELECTED -eq 2 ]
|
|
then
|
|
if [ ${#worker_node_name[@]} -eq 0 ]
|
|
then
|
|
ansible-playbook -i ./1.infra-installer/inventory/tmaxcloud/inventory.ini --become --become-user=root ./1.infra-installer/cluster.yml -e ignore_assert_errors=yes -e API_SERVER_IP=$API_SERVER_IP -e DNS_SERVER_IP=$DNS_SERVER_IP -e REGISTRY_URL=$REGISTRY_URL -e REPO_URL=$REPO_URL -e NFS_ENABLED=$NFS_ENABLED -e NFS_SERVER_IP=$NFS_SERVER_IP -e NFS_DIR=$NFS_DIR -e LB_POOL=$LB_POOL -e NODE_IP_CIDR=$NODE_IP_CIDR -e TRAFFIK_DOMAIN=$TRAFFIK_DOMAIN -e TRAFFIK_DOMAIN_IP=$TRAFFIK_DOMAIN_IP -e SC=$SC -e GITLAB_PASSWORD=$GITLAB_PASSWORD -e CLUSTER_IP=$CLUSTER_IP -e POD_IP=$POD_IP -e KUBE_VERSION=$KUBE_VERSION -e HYPERREGISTRY_SUBDOMAIN=$HYPERREGISTRY_SUBDOMAIN -e HYPERREGISTRY_NOTARY_SUBDOMAIN=$HYPERREGISTRY_NOTARY_SUBDOMAIN -e GITLAB_SUBDOMAIN=$GITLAB_SUBDOMAIN
|
|
else
|
|
ansible-playbook -i ./1.infra-installer/inventory/tmaxcloud/inventory.ini --become --become-user=root ./1.infra-installer/cluster.yml -e API_SERVER_IP=$API_SERVER_IP -e DNS_SERVER_IP=$DNS_SERVER_IP -e REGISTRY_URL=$REGISTRY_URL -e REPO_URL=$REPO_URL -e NFS_ENABLED=$NFS_ENABLED -e NFS_SERVER_IP=$NFS_SERVER_IP -e NFS_DIR=$NFS_DIR -e LB_POOL=$LB_POOL -e NODE_IP_CIDR=$NODE_IP_CIDR -e TRAFFIK_DOMAIN=$TRAFFIK_DOMAIN -e TRAFFIK_DOMAIN_IP=$TRAFFIK_DOMAIN_IP -e SC=$SC -e GITLAB_PASSWORD=$GITLAB_PASSWORD -e CLUSTER_IP=$CLUSTER_IP -e POD_IP=$POD_IP -e KUBE_VERSION=$KUBE_VERSION -e HYPERREGISTRY_SUBDOMAIN=$HYPERREGISTRY_SUBDOMAIN -e HYPERREGISTRY_NOTARY_SUBDOMAIN=$HYPERREGISTRY_NOTARY_SUBDOMAIN -e GITLAB_SUBDOMAIN=$GITLAB_SUBDOMAIN
|
|
fi
|
|
elif [ $SELECTED -eq 3 ]
|
|
then
|
|
if [ ${#worker_node_name[@]} -eq 0 ]
|
|
then
|
|
ansible-playbook -i ./2.argocd-installer/inventory/tmaxcloud/inventory.ini --become --become-user=root ./2.argocd-installer/cluster.yml -e ignore_assert_errors=yes -e API_SERVER_IP=$API_SERVER_IP -e DNS_SERVER_IP=$DNS_SERVER_IP -e REGISTRY_URL=$REGISTRY_URL -e REPO_URL=$REPO_URL -e NFS_ENABLED=$NFS_ENABLED -e NFS_SERVER_IP=$NFS_SERVER_IP -e NFS_DIR=$NFS_DIR -e LB_POOL=$LB_POOL -e NODE_IP_CIDR=$NODE_IP_CIDR -e NGINX_DOMAIN=$NGINX_DOMAIN -e NGINX_DOMAIN_IP=$NGINX_DOMAIN_IP -e SC=$SC -e GITLAB_PASSWORD=$GITLAB_PASSWORD -e CLUSTER_IP=$CLUSTER_IP -e POD_IP=$POD_IP -e KUBE_VERSION=$KUBE_VERSION -e HYPERREGISTRY_SUBDOMAIN=$HYPERREGISTRY_SUBDOMAIN -e HYPERREGISTRY_NOTARY_SUBDOMAIN=$HYPERREGISTRY_NOTARY_SUBDOMAIN -e GITLAB_SUBDOMAIN=$GITLAB_SUBDOMAIN -t bootstrap-cloud
|
|
else
|
|
ansible-playbook -i ./2.argocd-installer/inventory/tmaxcloud/inventory.ini --become --become-user=root ./2.argocd-installer/cluster.yml -e API_SERVER_IP=$API_SERVER_IP -e DNS_SERVER_IP=$DNS_SERVER_IP -e REGISTRY_URL=$REGISTRY_URL -e REPO_URL=$REPO_URL -e NFS_ENABLED=$NFS_ENABLED -e NFS_SERVER_IP=$NFS_SERVER_IP -e NFS_DIR=$NFS_DIR -e LB_POOL=$LB_POOL -e NODE_IP_CIDR=$NODE_IP_CIDR -e NGINX_DOMAIN=$NGINX_DOMAIN -e NGINX_DOMAIN_IP=$NGINX_DOMAIN_IP -e SC=$SC -e GITLAB_PASSWORD=$GITLAB_PASSWORD -e CLUSTER_IP=$CLUSTER_IP -e POD_IP=$POD_IP -e KUBE_VERSION=$KUBE_VERSION -e HYPERREGISTRY_SUBDOMAIN=$HYPERREGISTRY_SUBDOMAIN -e HYPERREGISTRY_NOTARY_SUBDOMAIN=$HYPERREGISTRY_NOTARY_SUBDOMAIN -e GITLAB_SUBDOMAIN=$GITLAB_SUBDOMAIN -t bootstrap-cloud
|
|
fi
|
|
elif [ $SELECTED -eq 4 ]
|
|
then
|
|
echo -e "\n\033[93m$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo)\n\033[0m"
|
|
elif [ $SELECTED -eq 5 ]
|
|
then
|
|
ansible-playbook -i ./1.infra-installer/inventory/tmaxcloud/inventory.ini --become --become-user=root ./1.infra-installer/reset.yml
|
|
podman network create podman
|
|
podman stop tmaxcloud
|
|
podman stop registry-browser
|
|
fi
|
|
}
|
|
main |