Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

Use Kubespray to deploy a Production Ready Kubernetes Cluster

Usages
You have two ways to run Kubespray.

Shell Mode

======================================================================
# Download kubespray
$ git clone git@github.com: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/
Comment

PREVIOUS NEXT
Code Example
Shell :: explicitly pull images from docker hub and list them on your terminal 
Shell :: vs code search panel regex match all css media queries 
Shell :: set the environment path variable for ffmpeg by running the following command: 
Shell :: ec2 print instance id powershell script 
Shell :: retrieve column from csv unix 
Shell :: install ubuntu along windows not showing up , even with unallocated space 
Shell :: stash recrusive submodules 
Shell :: error: refname refs/heads/origin not found 
Shell :: pip install dali 
Shell :: rust install cargo 
Shell :: thunderbird refresh emails shortcut 
Shell :: apt disable ipv6 
Shell :: linux pipe string contains 
Shell :: linux file explorer like mac 
Shell :: Fedora RPM Fusion with dnf 
Shell :: localhost/xampp/index.php 
Shell :: heroku rename remote app 
Shell :: what is set in ubuntu 
Shell :: display two content linux 
Shell :: vim replace word with copied 
Shell :: adb install --abi armeabi-v7a aab 
Shell :: watchan windows latest release 
Shell :: vite 
Shell :: format terminal mac 
Shell :: boot flash commande 
Shell :: install telnet mint 9 
Shell :: Install-Module PSWindowsUpdate 
Shell :: Enable MySQL as a service FreeBSD 
Shell :: cmder find parameter formate not correct 
Shell :: iterate through text files with spaces batch 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =