项目作者: en0x

项目描述 :
Kubernetes HA using Ansible (creates only master nodes)
高级语言: Ruby
项目地址: git://github.com/en0x/ansible-k8s-ha.git
创建时间: 2019-07-23T18:45:21Z
项目社区:https://github.com/en0x/ansible-k8s-ha

开源协议:GNU General Public License v3.0

下载


General

This code was written so we can test kubernetes clusters on local machines. But the main purpose of this code is to create kubernetes clusters on bare metal machines. Our goal was to only have master nodes in the cluster and that’s why you won’t see code for worker nodes. Adding provisioning of worker nodes to this playbook should be easy as most of the code is independent.

Requirements

What you need to have installed on ansible host:

  • ansible
  • kubectl
  • helm

Vagrant

Ansible

If you don’t want to run vagrant you can just go to ansible and modify the hosts.example file

This playbook only works on CentOS/RedHat

  1. cd ansible
  2. cp hosts.example hosts
  3. # Modify the hosts file to your needs
  4. ansible-playbook -i hosts playbook.yml

Kubernetes

Here is how it works:

keepalived -> haproxy -> kube-apiserver

In this playbook we are only creating etcd cluster and k8s master nodes in HA. We are not creating worker nodes. Worker nodes will be added later the the playbook.

Here are the following steps:

  1. Installing all dependencies
  2. Installing docker-ce
  3. Installing haproxy
  4. Installing keepalived
  5. Installing etcd and joining all the nodes together
  6. Installing kube* and creating first master
    1. Joining other masters to first master
  7. Copying kube config to local machine from where the ansible was executed
  8. Printing message

TODO

  1. Masters role have hardcoded creates checks to vagrant directory… this should be changed!

Example:

  1. args:
  2. creates: /home/vagrant/.kube/config
  1. Add worker nodes