diff --git a/scripts/README.md b/scripts/README.md old mode 100644 new mode 100755 Binary files differ diff --git a/scripts/clearCounter.sh b/scripts/clearCounter.sh old mode 100644 new mode 100755 index 1aed747..fe7f8c0 --- a/scripts/clearCounter.sh +++ b/scripts/clearCounter.sh @@ -1 +1,2 @@ rm -fr ~/counter/* +rm -fr counter/* diff --git a/scripts/counter/us-ub03-prod-mp-ub2204-eno1-microk8s b/scripts/counter/us-ub03-prod-mp-ub2204-eno1-microk8s new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/scripts/counter/us-ub03-prod-mp-ub2204-eno1-microk8s @@ -0,0 +1 @@ +5 diff --git a/scripts/createCluster.sh b/scripts/createCluster.sh new file mode 100755 index 0000000..f3c316e --- /dev/null +++ b/scripts/createCluster.sh @@ -0,0 +1,146 @@ +function multipassExecTaskV1 +{ + host=$1 + echo $host + set -x + + machine="localhost" + if [ "$machine" == "multipass" ] + then + executor="multipass exec $host --" + fi + $executor sudo apt update -y + $executor sudo apt install ansible -y + $executor mkdir repo + $executor git config --global user.email "agalyadoss@gmail.com" + $executor git config --global user.name "Agalya Ramadoss" + $executor sudo addgroup --gid 8055 boss + $executor sudo adduser --system --shell /bin/bash --uid 805501 --gid 8055 aboss + $executor sudo adduser --system --shell /bin/bash --uid 905501 --gid 8055 adoss + $executor sudo usermod -aG sudo aboss + $executor sudo usermod -aG sudo adoss + $executor sudo sh -c "echo aboss:$root_password|sudo chpasswd" + $executor sudo sh -c "echo adoss:$root_password|sudo chpasswd" + $executor sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/sshd_config + $executor sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config + $executor sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config + $executor sudo sh -c "ssh-keygen -N '' -q -f ~/.ssh/id_rsa -t rsa -b 4096 -C root" + + + +} +function multipassExecTask +{ + host=$1 + echo $host + multipass exec $host -- sudo apt update -y + multipass exec $host -- sudo apt install ansible -y + multipass exec $host -- mkdir repo + multipass exec $host -- git config --global user.email "agalyadoss@gmail.com" + multipass exec $host -- git config --global user.name "Agalya Ramadoss" + multipass exec $host -- sudo addgroup --gid 8055 boss + multipass exec $host -- sudo adduser --system --shell /bin/bash --uid 805501 --gid 8055 aboss + multipass exec $host -- sudo adduser --system --shell /bin/bash --uid 905501 --gid 8055 adoss + multipass exec $host -- sudo usermod -aG sudo aboss + multipass exec $host -- sudo usermod -aG sudo adoss +# multipass exec $host -- sudo sh -c "echo $root_password\n$root_password|sudo passwd aboss" +# multipass exec $host -- echo sh -c "$root_password|sudo passwd adoss" + multipass exec $host -- sudo sh -c "echo aboss:$root_password|sudo chpasswd" + multipass exec $host -- sudo sh -c "echo adoss:$root_password|sudo chpasswd" + multipass exec $host -- sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/sshd_config + multipass exec $host -- sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config + multipass exec $host -- sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin enabled/" /etc/ssh/sshd_config +# multipass exec $host -- sudo ssh-keygen -t rsa -b 4096 -C "root" + multipass exec $host -- sudo sh -c "ssh-keygen -N '' -q -f ~/.ssh/id_rsa -t rsa -b 4096 -C root" +# multipass exec $host -- sudo vim /etc/ssh/sshd_config +# multipass exec $host -- sudo passwd +# multipass exec $host -- sudo vim /root/.ssh/authorized_keys +# multipass restart $host +# multipass exec $host -- sudo vim /etc/default/kubelet + + +} +function multipassExecPostTask +{ + host=$1 + echo $host + id_rsa=`multipass exec $host -- sudo cat /root/.ssh/id_rsa.pub` + for chost in `cat hosts` + do + echo $chost + multipass exec $chost -- sudo sh -c "echo '$id_rsa'>> /root/.ssh/authorized_keys" + echo "sleeping for 1 seconds copy from $host to $chost " + sleep 1 + done + +} + +function multipassExecPostTaskV1 +{ + host=$1 + echo $host + machine="multipass" + if [ "$machine" == "multipass" ] + then + executor="multipass exec $host --" + fi + id_rsa=`$executor sudo cat /root/.ssh/id_rsa.pub` + for chost in `cat hosts` + do + echo $chost + $executor sudo sh -c "echo '$id_rsa'>> /root/.ssh/authorized_keys" + echo "sleeping for 1 seconds copy from $host to $chost " + sleep 1 + done + +} +function multipassExecSshVerifyV1 +{ + set -x + host=$1 + echo $host + machine="localhost" + if [ "$machine" == "multipass" ] + then + executor="multipass exec $host --" + fi + for chost in `cat hosts` + do + echo $chost + $executor sudo sh -c "ssh-keyscan $host >> /root/.ssh/known_hosts" + #multipass exec $chost -- sudo ssh $host + #ssh-keyscan us-mc02-pac-mp-ub2204-en0-kubeadm-2 >> $HOME/.ssh/known_hosts + done +} +function multipassExecSshVerify +{ + host=$1 + echo $host + for chost in `cat hosts` + do + echo $chost + multipass exec $chost -- sudo sh -c "ssh-keyscan $host >> /root/.ssh/known_hosts" + #multipass exec $chost -- sudo ssh $host + #ssh-keyscan us-mc02-pac-mp-ub2204-en0-kubeadm-2 >> $HOME/.ssh/known_hosts + done +} +#Main +if [ "$root_password" == "" ] +then + echo "Please export root_password" + exit 1 +fi + +for host in `cat hosts` +do + multipassExecTask $host + echo $host +done +for host in `cat hosts` +do + multipassExecPostTask $host +done +for host in `cat hosts` +do + multipassExecSshVerify $host +done diff --git a/scripts/createHostList.sh b/scripts/createHostList.sh old mode 100644 new mode 100755 diff --git a/scripts/createVm.sh b/scripts/createVm.sh old mode 100644 new mode 100755 index 7418762..0fdc6b9 --- a/scripts/createVm.sh +++ b/scripts/createVm.sh @@ -11,7 +11,7 @@ fi currentHost=`hostname` -CPU=2 +CPU=3 function findEthEthernet { @@ -53,6 +53,10 @@ then HOSTMACHINE="mc01" fi + if [ "us-ub01-prod-pc-ub2404-eth0-kubadm-0" == "$currentHost" ] + then + HOSTMACHINE="ub03" + fi HOSTNAME_PREFIX="$REGION-$HOSTMACHINE-$ENV-$VIRTUALMACHINE-`osVersion $OS $OSVERSION`-$NETWORK-$APP" if [ "$action" == "create" ] then @@ -67,7 +71,7 @@ mkdir -p ~/data/$HOSTNAME if [ "$action" == "create" ] then - multipass launch $OSVERSION --name $HOSTNAME --memory 4G --disk 50G --cpus $CPU --network en0 --mount ~/data/$HOSTNAME:/data/ + multipass launch $OSVERSION --name $HOSTNAME --memory 4G --disk 50G --cpus $CPU --network $NETWORK --mount ~/data/$HOSTNAME:/data/ else multipass delete $HOSTNAME --purge diff --git a/scripts/hosts b/scripts/hosts old mode 100644 new mode 100755 index 9ee1eed..dab84f6 --- a/scripts/hosts +++ b/scripts/hosts @@ -1 +1,5 @@ -us-mc02-prod-utm-ub2204-microk8s-0 +us-ub03-prod-mp-ub2204-eno1-microk8s-0 +us-ub03-prod-mp-ub2204-eno1-microk8s-1 +us-ub03-prod-mp-ub2204-eno1-microk8s-2 +us-ub03-prod-mp-ub2204-eno1-microk8s-3 +us-ub03-prod-mp-ub2204-eno1-microk8s-4 diff --git a/scripts/multipassInstallPreRequired.py b/scripts/multipassInstallPreRequired.py old mode 100644 new mode 100755 diff --git a/scripts/multipassInstallPreRequired.sh b/scripts/multipassInstallPreRequired.sh index d06aaa9..78daf40 100755 --- a/scripts/multipassInstallPreRequired.sh +++ b/scripts/multipassInstallPreRequired.sh @@ -21,9 +21,10 @@ $executor sudo usermod -aG sudo adoss $executor sudo sh -c "echo aboss:$root_password|sudo chpasswd" $executor sudo sh -c "echo adoss:$root_password|sudo chpasswd" + $executor sudo sed -i "s/# PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/ssh_config $executor sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/sshd_config $executor sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config - $executor sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin enabled/" /etc/ssh/sshd_config + $executor sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config $executor sudo sh -c "ssh-keygen -N '' -q -f ~/.ssh/id_rsa -t rsa -b 4096 -C root" @@ -47,9 +48,10 @@ # multipass exec $host -- echo sh -c "$root_password|sudo passwd adoss" multipass exec $host -- sudo sh -c "echo aboss:$root_password|sudo chpasswd" multipass exec $host -- sudo sh -c "echo adoss:$root_password|sudo chpasswd" + multipass exec $host -- sudo sed -i "s/# PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/ssh_config multipass exec $host -- sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/sshd_config multipass exec $host -- sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config - multipass exec $host -- sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin enabled/" /etc/ssh/sshd_config + multipass exec $host -- sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config # multipass exec $host -- sudo ssh-keygen -t rsa -b 4096 -C "root" multipass exec $host -- sudo sh -c "ssh-keygen -N '' -q -f ~/.ssh/id_rsa -t rsa -b 4096 -C root" # multipass exec $host -- sudo vim /etc/ssh/sshd_config