Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/odennav/kubespray-ansible-rhel
Deploy a Kubernetes cluster with Kubespray using Bash scripts, Ansible and Vagrant
https://github.com/odennav/kubespray-ansible-rhel
ansible ansible-playbook automation bash-scripting centos centos7 centos8 kubespray kubespray-vagrant rhel vagrant vagrantfile
Last synced: 11 days ago
JSON representation
Deploy a Kubernetes cluster with Kubespray using Bash scripts, Ansible and Vagrant
- Host: GitHub
- URL: https://github.com/odennav/kubespray-ansible-rhel
- Owner: odennav
- License: apache-2.0
- Created: 2024-03-03T19:31:47.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-06-23T21:01:18.000Z (5 months ago)
- Last Synced: 2024-10-31T07:42:24.464Z (18 days ago)
- Topics: ansible, ansible-playbook, automation, bash-scripting, centos, centos7, centos8, kubespray, kubespray-vagrant, rhel, vagrant, vagrantfile
- Language: Shell
- Homepage:
- Size: 34.2 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Deployment of a Kubernetes Cluster with Kubespray
This project automates the deployment of a kubernetes cluster with kubespray in Test environment.
Ansible and bash scripts are used to setup a kubernetes cluster.
Vagrant is utilized to provision VMs.
### Requirements
- Minimum required version of Kubernetes is **`v1.27`**
- **`Ansible v2.14+`**, **`Jinja 2.11+`** and **`python-netaddr`** is installed on the machine that will run Ansible commands.
- The target servers must have access to the Internet in order to pull docker images. Otherwise, additional configuration is required.
Get [Chocolatey](https://chocolatey.org/install) and use it to install vagrant:
```bash
choco install vagrant
```### Getting Started
Provision vagrant VMs
```bash
vagrant up
```Login to `control` VM
```bash
vagrant ssh control
```Change password of `root` user
This new password will be required when public RSA keys are being transferred to kube nodes.
```bash
sudo passwd
```Update yum package manager
```bash
cd /
yum update
```Install Git
```bash
yum install git
```Clone this repo to `/` directory in control node
```bash
git clone [email protected]:odennav/kubespray-bash-ansible.git
```Clone kubernetes-sigs kubespray repo to `/` directory in control node
```bash
git clone [email protected]:kubernetes-sigs/kubespray.git
```Run `dependencies-install.sh` script in `control` node to install necessary dependencies, update yum package index and ensuring python version compatibility.
```bash
chmod 770 dependencies-install
./dependencies-install
```Setup system for Ansible playbook execution
This bash script copies SSH keys, updates Ansible inventory, builds host inventory manifest and installs kubectl.
```bash
chmod 770 k8s-env-build.sh
./k8s-env-build.sh
```
Run Ansible playbook to to deploy kubernetes cluster
Change directory to your local kubespray repository and execute `cluster.yml` ansible playbook
```bash
cd /kubespray
ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root cluster.yml
```### Reset Kubernetes Cluster
To remove current kubernetes cluster, run playbook as root user.
Run this command in kubespray directory
```bash
cd /kubespray
ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root reset.yml
```
### Destroying Resources(Optional)To destroy the VMs created by vagrant.
```bash
vagrant destroy
```-----
special thanks to [Kubernetes-sigs](https://https://github.com/kubernetes-sigs) for their amazing work.
-----
Enjoy!