Skip to content

3. online deploy cluster

老夫的猫呢 edited this page Dec 2, 2024 · 4 revisions

preparatory work

This project requires git, make, and vim commands. You can install them by running the following command

# ubuntu
apt-get update
apt-get install git make -y

# centos
yum install git make vim -y

# Arch
pacman -Scc --noconfirm
pacman -Sy --noconfirm
pacman -S --noconfirm python3
pacman -S --noconfirm git make vim
pacman -S --noconfirm git make python-pip python3

clone code

This project uses branches to distinguish Kubernetes versions. If you want to deploy Kubernetes version 1.14, you should clone the v1.14 branch. For example, if you want to deploy Kubernetes version 1.27, you should run the following command.

git clone -b v1.27 https://github.com/buxiaomo/kubeasy.git /usr/local/src/kubeasy

install project runtime

cd /usr/local/src/kubeasy
make runtime

configuring cluster parameters

You can run the following command to create default Kubernetes parameters in the group_vars directory. You can modify them if necessary

make -C group_vars/

The ./group_vars/all.yml file includes the following settings

  • timezone
  • modprobe
  • ipvs
  • sysctl
  • limits

The ./group_vars/kubernetes.yml file includes the following settings

  • docker
  • containerd
  • etcd
  • kube-apiserver
  • kube-controller-manager
  • kube-scheduler
  • kubelet
  • kube-proxy

configuring cluster inventory

For more instructions reference inventory/README.md

IPv4

for example:

# cd /usr/local/src/kubeasy
# make hosts
# cat inventory/${PROJECT_NAME}-${PROJECT_ENV}.ini
[master]
172.16.115.11
172.16.115.12
172.16.115.13

[worker]
172.16.115.14

[kubernetes:children]
master
worker

[kubernetes:vars]
; kubernetes network config
networking={"dnsDomain": "cluster.local", "serviceSubnet": "10.96.0.0/12", "podSubnet": "10.244.0.0/16", "mode": "ipvs"}

; ha config
; slb is software load balancing, will install harpoxy and keepalived on master node
; clb is cloud load balancing, will use cloud load balancing
; ha={"type": "slb", "vip": "172.16.115.10", "mask": 16 }

; loadBalancing is 4 layer forwarding to ingress by haproxy, only used in slb
; loadBalancing={"http": {"src": 80, "dest": 30001}, "https": {"src": 443, "dest": 30002}}

[all:vars]
ansible_ssh_port=22
ansible_ssh_user=root
ansible_ssh_pass=root
; ansible_sudo_user=root
; ansible_sudo_pass=root

IPv6

for example:

# cd /usr/local/src/kubeasy
# make hosts
# cat inventory/${PROJECT_NAME}-${PROJECT_ENV}.ini
[master]
240e:369:7a65:d00:250:56ff:fe82:1a77
240e:369:7a65:d00:250:56ff:fe82:c3aa
240e:369:7a65:d00:250:56ff:fe82:9865

[worker]
240e:369:7a65:d00:250:56ff:fe82:ddd7

[kubernetes:children]
master
worker

[kubernetes:vars]
; kubernetes network config
networking={"dnsDomain": "cluster.local", "serviceSubnet": "fd00:10:96::/112", "podSubnet": "fd00:10:244::/64", "mode": "ipvs"}

; ha config
; slb is software load balancing, will install harpoxy and keepalived on master node
; clb is cloud load balancing, will use cloud load balancing
; ha={"type": "slb", "vip": "240e:369:7a65:d00:250:56ff:fe82:1111", "mask": 64 }

; loadBalancing is 4 layer forwarding to ingress by haproxy, only used in slb
; loadBalancing={"http": {"src": 80, "dest": 30001}, "https": {"src": 443, "dest": 30002}}

[all:vars]
ansible_ssh_port=22
ansible_ssh_user=root
; ansible_ssh_pass=root
; ansible_sudo_user=root
; ansible_sudo_pass=root

IPv4/IPv6 dual-stack

for example:

# cd /usr/local/src/kubeasy
# make hosts
# cat inventory/${PROJECT_NAME}-${PROJECT_ENV}.ini
[master]
172.16.115.11 ipv6=fdcd:d1e9:f503:0:250:56ff:fe82:c2be

[worker]
172.16.115.12 ipv6=fdcd:d1e9:f503:0:250:56ff:fe82:bdb8

[kubernetes:children]
master
worker

[kubernetes:vars]
; kubernetes network config
networking={"dnsDomain": "cluster.local", "serviceSubnet": "10.96.0.0/12,2402:db8:42:d600::/112", "podSubnet": "10.244.0.0/16,2402:db8:42:d700::/64", "mode": "ipvs"}

; ha config
; slb is software load balancing, will install harpoxy and keepalived on master node
; clb is cloud load balancing, will use cloud load balancing
; ha={"type": "slb", "vip": "172.16.115.10", "mask": 16 }

; loadBalancing is 4 layer forwarding to ingress by haproxy, only used in slb
; loadBalancing={"http": {"src": 80, "dest": 30001}, "https": {"src": 443, "dest": 30002}}

[all:vars]
ansible_ssh_port=22
ansible_ssh_user=root
; ansible_ssh_pass=root
; ansible_sudo_user=root
; ansible_sudo_pass=root

download package

if you can download file from google, you can skip this step, this step will download file from GitHub.

make prepare

deploy cluster

make deploy

scale cluster

Run the following command to add asset information. Currently, only worker nodes can be expanded.

make hosts

Then execute the following command to expand the capacity, with parameters consistent with deploy, such as KUBE_VERSION, KUBE_RUNTIME, KUBE_NETWORK, REGISTRY_URL, etc

make scale

upgrade cluster

git pull
git checkout v1.28
make upgrade

renew certificates

make renew