This project is a set of six Bash scripts that set up a default Kubernetes cluster with kubespray.
This project was created because I could not find one like it on the web. A similar solution is YOTRON's Local Kubernetes Cluster.
Yes, the scripts are ugly, but they work. KISS.
- File path root:
$HOME/2020_RCNIT/Scripts
- Create these folders and put deployment and maintenance in them.
- OS: CentOS 7/8
- Scripts are executable:
chmod +x <script.sh>
Before:
. ($HOME/2020_RCNIT)
├── Scripts
├── deployment
│ ├── deploy.sh
│ ├── kickstart.ks
├── maintenance
├── kill-machines.sh
├── revert-machines-to-fresh-install.sh
├── revert-machines-to-fresh-kubernetes.sh
├── start-machines.sh
└── stop-machines.sh
After:
.
├── ISOs
│ ├── CentOS-7-x86_64-Minimal-1908.iso
├── kubespray (big folder)
├── Scripts
├── deployment
│ ├── deploy.sh
│ ├── kickstart.ks
├── maintenance
├── kill-machines.sh
├── revert-machines-to-fresh-install.sh
├── revert-machines-to-fresh-kubernetes.sh
├── start-machines.sh
└── stop-machines.sh
└── VMs
├── node1.qcow2
├── node2.qcow2
├── node3.qcow2
└── node4.qcow2
The root password, admin name, and admin password are all bashful
. These can be changed in kickstart.ks. If these credentials are
changed, they need to be manually changed in deploy.sh too.
The VMs names are hardcoded in every script as node1
, node2
, node3
, and node4
under the variable machines
.
Run deploy.sh to set up the VMs and the Kubernetes cluster. This script will:
- Set up the project folder structure.
- Download all the necessary software.
- Use
virt-install
and kickstart.ks to create 4 VMs with CentOS 7. - Make snapshots of the fresh OS installation.
- Configure passwordless SSH access to each VM.
- Set up k8s on each VM using kubespray.
- Set up kubectl on
localhost
andnode1
. - Make snapshots of the fresh Kubernetes installation.
The only manual inputs needed are pressing Enter
at the end of each OS installation (which will close the Virt Viewer windows) and entering the local and
remote sudo passwords several times.
The purpose of the maintenance scripts is to help speed up development – it would take longer to manually force power-off (i.e. kill), revert to previous snapshots, start, or shut down machines.