How To Perform AI Center On-Premise Environment Reset

How to perform AI Center On-Premise environment reset?

Introduction : Currently an On-Prem environment might already be setup having the infra and AI Center solution installed. Now, if a new infra again requires to be installed, instead of provisioning the new Infra the below script can be executed which will reset the On-Prem environment.

Pre-Requisites :

  • Identify the disks where the ceph LVM are setup, and make sure this is not the OS disk, as cleaning the disks action is required to be performed. If wrong disks are provided as input, then data will be lost.

  • Run the script in SuperUser mode, make sure to enter “sudo su” and then run the script.

Steps To Perform :

  1. First Download the Script below

#!/bin/bash

echo "starting cleanup"
#This script will be used to delete all the resources related to kubeadm and make it available for the next install

#this will call kubeadm reset
echo "Kube reset"
curl https://k8s.kurl.sh/aif-core/tasks.sh | sudo bash -s reset

#cleanup of disks
echo "creating new partition"
for disk in "$@"
do
echo "cleaning for $disk"
diskname="/dev/$disk"
sudo sgdisk --zap-all "$diskname"
#checking for Hdd or ssd
if [ $(lsblk -d -o name,rota | grep $disk | awk '{print $2}') = "1" ]
then
echo "the disk is hdd $disk"
sudo dd if=/dev/zero of="$diskname" bs=1M count=100 oflag=direct,dsync
else
echo "the disk is ssd $disk"
blkdiscard $diskname
fi
done

echo "Clearing the ceph folders"
rm -rf /var/lib/ceph
rm -rf /var/lib/rook

ls /dev/mapper/ceph-* | xargs -I% -- dmsetup remove %

echo "removing ceph storage"
sudo rm -rf /dev/ceph-*

echo "done"

  1. Now become super user entering the below command
1sudo su

  1. Go to the directory where script is present and run the below commands
find . -type f -print0 | xargs -0 dos2unix
chmod u+x OnPrem_Reset.sh

  1. Run the below command , the disks which have been identified to be cleaned up should be given as arguments to the below command
/OnPrem_Reset.sh <arg1> <arg2>
Example : Suppose there are 2 disks which are to be cleaned sdb and sdc , then command would be
./OnPrem_Reset.sh sdb sdc
  1. Now a prompt will be asked, and “Y” needs to be selected

AICUninstall1.png
  1. After all the steps is done just run the command “lsblk” no lvm should be listed

AICUninstall2.png

  1. Now restart the VM and verify. The VM has been reset.