Git Product home page Git Product logo

kubespray-ansible-rhel's Introduction

k8s 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.
  • The target servers are configured to allow IPv4 forwarding.
  • If using IPv6 for pods and services, the target servers are configured to allow IPv6 forwarding.
  • The firewalls are not managed, you'll need to implement your own rules the way you used to. in order to avoid any issue during deployment you should disable your firewall.
  • If kubespray is run from non-root user account, correct privilege escalation method should be configured in the target servers. Then the ansible_become flag or command parameters --become or -b should be specified.
  • Get Chocolatey and use it to install vagrant:
  choco install vagrant

Getting Started

  1. Provision vagrant VMs

    vagrant up
  2. Login to control vm

    vagrant ssh control
  3. Change password of root user This new password will be required when public RSA keys are being transferred to kube nodes.

    sudo passwd
  4. Update yum package manager

    cd /
    yum update
  5. Install git

    yum install git
  6. Clone this repo to / directory in control node

    git clone [email protected]:odennav/kubespray-bash-ansible.git
  7. Clone kubernetes-sigs kubespray repo to / directory in control node

    git clone [email protected]:kubernetes-sigs/kubespray.git
  8. Run dependencies-install.sh in control node to install necessary dependencies

    Updating Yum, installing necessary dependencies, and ensuring Python compatibility.

    chmod 770 dependencies-install
    ./dependencies-install
  9. Setup system for Ansible playbook execution

    This bash script copies SSH keys, updates Ansible inventory, builds host inventory manifest and installs kubectl.

    chmod 770 k8s-env-build.sh
    ./k8s-env-build.sh
  10. Run Ansible playbook to to deploy kubernetes cluster

    Change directory to your local kubespray repo and execute cluster playbook

    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

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.

vagrant destroy

Special Credits

Special thanks to Kubernetes-sigs for their amazing work.

Enjoy!

kubespray-ansible-rhel's People

Contributors

odennav avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.