Kubespray High Availability (HA) Kubernetes

๐Ÿ’ก Kubespray High Availability (HA) Kubernetes โ€” Executive Summary

Technical architectural analysis, practical configuration manifests, and deployment instructions for Kubespray High Availability (HA) Kubernetes.

References and Guidelines (NOTE)

CoreDNS operation when using systemd-resolved on host

HostNode:

  • systemd-resolved is fixed as /etc/resolv.conf = 127.0.0.53loopback address.
  • The actual resolve defined in /etc/systemd/resolved.conf is /var/run/systemd/resolve/resolv.conf.

Kubelet:

  • Default mounts /etc/resolv.conf on HostNode.
  • Kublet cannot access the loopback address 127.0.0.53.
References and Guidelines (NOTE)

Kubernetes:

k3s:

bash
k3s server --resolv-conf $value
curl -sfL https://get.k3s.io | sh -s - server --resolv-conf $value

Prepare Deploy Server

Install required packages
bash
apt update
apt install python3-pip # python3.8.10
pip install ansible==4.10.0
#ansible==4.10.0 ,ansible-core==2.11.12 ,kubernetes_v1.24.6
#ansible==2.9.7 ,ansible-core==2.9.6 ,kubernetes_v1.23.7

pip install netaddr
apt-get install sshpass
References and Guidelines (NOTE)

When changing the version, it works well even if you overwrite it without uninstalling it

Preparation
bash
# ๊ฐ ๋…ธ๋“œ์ •๋ณด ์ถ”๊ฐ€
vi /etc/hosts

# ssh-key ์„ค์ •
ssh-keygen -t rsa
# ์„ค์น˜ํ•  ๋…ธ๋“œํ˜ธ์ŠคํŠธ์— pubํ‚ค ๋ณต์‚ฌ
ssh-copy-id root@k8s-master1

Exec

Playbook setting
bash
git clone https://Enterprise Cloudlab:[email protected]/Enterprise Cloudlab/cmp-infra.git

cd ~/cmp-infra/kubernetes/ansible/kubernetes_v1.23.7/

# ํ˜ธ์ŠคํŠธ์ •๋ณด ์ˆ˜์ •
vi inventory/cmp/inventory.ini
# kube version ๋ฐ ๋””๋ ‰ํ† ๋ฆฌ ๋“ฑ ์ˆ˜์ •
vi inventory/cmp/group_vars/k8s_cluster/k8s-cluster.yml
# offline.yml์€ ์ฃผ์„์ฒ˜๋ฆฌ ๋˜์–ด์žˆ์Œ. ๊ฐ€์žฅ ์šฐ์„ ์ˆœ์œ„
vi inventory/cmp/group_vars/all/offline.yml
Run Playbook
bash
ansible-playbook -i inventory/$env/inventory.ini cluster.yml -vv

#ansible-playbook myplaybook.yaml -i myinventory --env-container=/path/to/offline.yaml

Detail

Addons


โ€ผ Closed network

External Servers
Prepare OS Image
  • RHEL:
Prepare Package Repository
  • RHEL:
  • DEB:
Prepare File Repository
Preparing Docker Repository (Harbor)
Deploy Server
Edit offline.yaml
After Playbook execution
Before: All Nodes: external repository mount, etchost registration
  • RHEL: :import
bash
#harbor host ๋“ฑ๋ก
vi /etc/hosts
1Cycle After: All Nodes: Harbor access permission settings
bash
#harbor ๊ถŒํ•œ ์ธ์ฆ
nerdctl login harbor.Enterprise Cloud.cld
2Cycle After: Master Node: Edit CoreDNS ConfigMap
  • :coredns, nodelocaldns Not Running

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *