Skip to content

jorikseldeslachts/ansible-kubernetes-cluster

Repository files navigation

Kubernetes with Ansible

About

This project can be used to setup a Kubernetes cluster with HA control panes and HA Etcd cluster using Ansible. It provides three playbooks:

Playbook Description
playbook-k8s-all.yml Complete Kubernetes cluster installation.
playbook-kubeadm-add-new-master.yml Add new master(s) to an existing cluster.
playbook-kubeadm-add-new-worker.yml Add new worker(s) to an existing cluster.

Requirements

  • Ansible 2.8
  • Virtual Machines with CentOS8 ready when not using Vagrant

Ansible

Before running the playbooks you need to copy your SSH key to the remote servers.

# copy ssh keys
$ for i in {21,22,23,24}
  do
      sshpass -p "vagrant" ssh-copy-id [email protected].$i
      sshpass -p "vagrant" ssh-copy-id [email protected].$i
      echo "172.16.88.$i done"
  done

You will need to prepare an inventory file for Ansible. There are examples you can copy and edit in the inventories/examples folder. Place them in the inventories folder and you are good to go.

After that export the Ansible configuration and you are ready to run the playbooks.

$ export ANSIBLE_CONFIG=./ansible.cfg

It is advised to run a syntax check to be sure all needed variabled are filled in and there are no syntax errors.

# Run a syntax check
$ ansible-playbook playbook-k8s-all.yml \
  -i inventories/vagrant-full-install.inv \
  -u vagrant \
  --ask-become-pass \
  --syntax-check

Install the playbooks:

  • Complete Kubernetes cluster installation:
    # Complete installation
    $ ansible-playbook \
        -i inventories/vagrant-full-install.inv \
        -u vagrant \
        --ask-become-pass \
        playbook-k8s-all.yml
  • Add new master(s) to an existing cluster:
    # Add masters
    $ ansible-playbook \
        -i inventories/vagrant-add-master.inv \
        -u vagrant \
        --ask-become-pass \
        playbook-kubeadm-add-new-master.yml
  • Add new worker(s) to an existing cluster:
    # Add workers
    $ ansible-playbook \
        -i inventories/vagrant-add-worker.inv \
        -u vagrant \
        --ask-become-pass \
        playbook-kubeadm-add-new-worker.yml

Known Issues

TODO

  • Check to NOT join master/worker if already "Ready"
  • Taint master to allow running pods on the master node in "init-first-master" role
  • Support for Calico CNI
  • Add the option to add new nodes to the etcd cluster when adding masters

Contributors

  • Jorik Seldeslachts

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published