Giter VIP home page Giter VIP logo

kubernetes-ansible's Introduction

Kubernetes-Ansible

Repo Size

This Repository is Using Ansible Deploy a Binary High Availability Kubernetes Cluster. Roles step Fllow the offical deploy tools Kubeadm.

High availability

each node running a envoy loadbalancer on 127.0.0.1:8443 proxy the kube-apiserver serivce.

                                            upstream    +-------------------+
                           +--------------------------> | kube-master1:6443 |
                           |                            +-------------------+
                           |
                           |
                           |
+-----------+  request   +----------------+  upstream   +-------------------+
| kube-node | ---------> | 127.0.0.1:8443 | ----------> | kube-master2:6443 |
+-----------+            +----------------+             +-------------------+
                           |
                           |
                           |
                           |                upstream    +-------------------+
                           +--------------------------> | kube-master3:6443 |
                                                        +-------------------+

VirtualBox Network

If virtualbox > 2.2.18 /etc/vbox/networks.conf

* 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12

Calico

calico disable ipip modules, in vagrant this settings require:

# change calico.yaml variable
IP_AUTODETECTION_METHOD="skip-interface=eth0"
CALICO_IPV4POOL_IPIP="Never"
CALICO_IPV4POOL_CIDR="{{ kubernetes_pod_network_cidr }}"
# kubelet 10-kubeadm.conf add --node-ip
--node-ip="{{ ansible_host_ip }}"

Dependencies

On Host machine:

  • OS: macOS Monterey
  • Vagrant: 2.2.19
  • VirtualBox: 6.1.36
  • Ansible: 2.13.0

On Guest machine:

  • Linux Distribution: CentOS/7
  • Containerd: 1.6.6
  • Critools: 1.24.2
  • Kubernetes: 1.24.3
  • Calico: 3.23.3

Quick Start

Vagrant

Clone this repository, then use vagrant create kubernetes cluster:

git clone https://github.com/kuops/kubernetes-ansible.git
cd kubernetes-ansible
vagrant up

Default config in vagrant.yaml, this config load before vagrant up:

box: centos/7
box_url:  https://mirrors.ustc.edu.cn/centos-cloud/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-2004_01.VirtualBox.box
master:
  prefix: kube-master
  number: 3
  cpu: 2
  memory: 4096
worker:
  prefix: kube-worker
  number: 2
  cpu: 1
  memory: 2048

If has some ansible error, setting debug variables:

then you can try vagrant provision or vagrant up --provision continue running ansible.

# ansbile verbose level 0-4
ANSIBLE_DEBUG=2 vagrant up --provision

Ansible

Generator ca cert and bootstrap token, you can run:

# generator cert at base directory in .cert
make cert

Add your inventory on inventories directory, like example inventory:

inventories/example
├── group_vars
│   └── all.yml
└── hosts

is_vagrant variable add a route 8.8.8.8 dev eth1 scope link change ansible_default_ipv4 value to vagrant_network_interface ip address, if not use vagrant, change to no:

is_vagrant: no
# comment vagrant_network_interface variable
# vagrant_network_interface: eth1

local_bin_dir and local_certs_dir in ansible-playbook diffrence vagrantfile:

local_bin_dir: "{{ inventory_dir| regex_replace('inventories.*$','.bin') }}"
local_certs_dir: "{{ inventory_dir| regex_replace('inventories.*$','.certs') }}"

run deploy example:

ansible-playbook -i inventories/example/hosts site.yml

kubernetes-ansible's People

Contributors

kuops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.