Utilisez Kubspray pour déployer un cluster Kubernetes Ready Ready de production

Usages
You have two ways to run Kubespray.

Shell Mode

======================================================================
# Download kubespray
$ git clone [email protected]:kubernetes-sigs/kubespray.git

$ cd kubespray

# Install dependencies from ``requirements.txt``
$ sudo pip3 install -r requirements.txt

# Copy ``inventory/sample`` as ``inventory/mycluster``
$ cp -rfp inventory/sample inventory/mycluster

# Update Ansible inventory file with inventory builder
$ declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5)
$ CONFIG_FILE=inventory/mycluster/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}

# Review and change parameters under ``inventory/mycluster/group_vars``
$ cat inventory/mycluster/group_vars/all/all.yml
$ cat inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml

# Deploy Kubespray with Ansible Playbook - run the playbook as root
# The option `--become` is required, as for example writing SSL keys in /etc/,
# installing packages and interacting with various systemd daemons.
# Without --become the playbook will fail to run!
$ ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root cluster.yml

=======================================================================


or Docker Container Mode

=======================================================================

$ docker pull quay.io/kubespray/kubespray:v2.16.0

# Enter into Docker container
$ docker run --rm -it --mount type=bind,source="$(pwd)"/inventory/sample,dst=/inventory \
  --mount type=bind,source="${HOME}"/.ssh/id_rsa,dst=/root/.ssh/id_rsa \
  quay.io/kubespray/kubespray:v2.16.0 bash

# Update Ansible inventory file with inventory builder
root@1f615c0327ff:/kubespray# declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5)
root@1f615c0327ff:/kubespray# CONFIG_FILE=/inventory/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}

# Review and change parameters under ``inventory/mycluster/group_vars``
root@1f615c0327ff:/kubespray# cat /inventory/group_vars/all/all.yml
root@1f615c0327ff:/kubespray# cat /inventory/group_vars/k8s_cluster/k8s-cluster.yml

# Inside the container you may now run the kubespray playbooks:
root@1f615c0327ff:/kubespray# ansible-playbook -i /inventory/inventory.ini --private-key /root/.ssh/id_rsa cluster.yml

root@1f615c0327ff:/kubespray# ansible-playbook -i /inventory/hosts.yaml --private-key /root/.ssh/id_rsa cluster.yml

Proxy Configuration
# inventory/mycluster/group_vars/all/all.yml

## Set these proxy values in order to update package manager and docker daemon to use proxies
http_proxy: "http://192.168.88.130:38001"
https_proxy: "http://192.168.88.130:38001"

## Refer to roles/kubespray-defaults/defaults/main.yml before modifying no_proxy
no_proxy: "localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.svc.cluster.local"



READ MORE: https://cloudolife.com/2021/08/28/Kubernetes-K8S/Kubespray/Use-Kubespray-to-deploy-a-Production-Ready-Kubernetes-Cluster/
DreamCoder