项目作者: zufardhiyaulhaq

项目描述 :
Automating Kubernetes the hard way cluster with Ansible. Support Vagrant and OIDC! feature to renew the certificate, add a new worker node, and upgrade the Kubernetes version!
高级语言: HTML
项目地址: git://github.com/zufardhiyaulhaq/kubernetes-hard-way-ansible.git


Kubernetes Hard Way Ansible

Ansible template to create kubernetes cluster with the following specs:

  • Kubernetes v1.22.10
  • Flannel v0.18.1
  • CNI v1.1.1
  • CRI v1.22.0
  • runc v1.1.3
  • containerd v1.6.6
  • gvisor 20220510
  • etcd v3.5.4
  • core-dns 1.9.3
  • metrics-server v0.6.1
  • metallb v0.12.1
  • Haproxy & keepalived
  • Secure communication between component

Additional Feature

  • OIDC supported
  • MetalLB supported
  • Vagrant installation supported
  • Insecure Registry supported
  • Renewing certificate playbook
  • Adding worker node playbook
  • Upgrade Kubernetes playbook

Tested Environment

  • Ubuntu 18.04
    • 3 master nodes, 3 worker nodes
    • 3 etcd nodes, 3 master nodes, 3 worker nodes

Step Installation

Execution happen on the deployer node. All the ceritificate generated and store in the deployer node. The deployer node cannot be deleted if you want to renew certificate or extending kubernetes worker node. All this step executed in the deployer node.

  • Prepare ansible
    1. sudo apt-add-repository ppa:ansible/ansible -y
    2. sudo apt update
    3. sudo apt install ansible -y
  • Make sure have access into all nodes

please make sure that have privilege access, you can add the user in sudoers files, after bootstrap is done, fell free to remove that.

  1. ssh-keygen
  2. # copy to deployer itself
  3. ssh-copy-id <user>@<deployer-node>
  4. # copy to etcd node
  5. ssh-copy-id <user>@<etcd-node>
  6. ssh-copy-id <user>@<etcd-node>
  7. ssh-copy-id <user>@<etcd-node>
  8. # copy to master node
  9. ssh-copy-id <user>@<master-node>
  10. ssh-copy-id <user>@<master-node>
  11. ssh-copy-id <user>@<master-node>
  12. # copy to master node
  13. ssh-copy-id <user>@<worker-node>
  14. ssh-copy-id <user>@<worker-node>
  15. ssh-copy-id <user>@<worker-node>
  • disable ansible hostkey checking
    ```bash
    vi ~/.ansible.cfg

[defaults]
host_key_checking = False

  1. * Clone this repository
  2. ```bash
  3. git clone https://github.com/zufardhiyaulhaq/kubernetes-hardway-ansible.git
  4. git checkout --track origin/<TAG>
  • Adjust variable in the group_vars

    1. vi group_vars/all.yml
  • Adjust Kubernetes host and nodes

    1. vi hosts/hosts
  • Run ansible

    1. ansible-playbook main.yml -i hosts/hosts

Please backup certificate directory in the deployer node!

Additional Setup