antony@notes:~/kubernetes$ cat "Install-Taroko-K8s-on-Ubuntu-20.04.md"
Install Taroko K8s on Ubuntu 20.04
Install Taroko K8s on Ubuntu 20.04 LTS
1. 環境設定
# 1. 安裝與設定 podman v5.2.5
$ curl -fsSL -o podman-linux-amd64.tar.gz https://github.com/mgoltzsche/podman-static/releases/download/v5.2.5/podman-linux-amd64.tar.gz && \
tar -xzf podman-linux-amd64.tar.gz && \
sudo cp -r podman-linux-amd64/usr podman-linux-amd64/etc /
# 2. 設定 Cgroup v2
$ sudo nano /etc/default/grub
## 在 GRUB_CMDLINE_LINUX 新增參數
systemd.unified_cgroup_hierarchy=1
$ sudo update-grub
# 3. 設定使用者登入環境
$ sudo nano /etc/profile
## 在檔案最下方新增以下內容
gw=$(route -n | grep -e "^0.0.0.0 ")
export GWIF=${gw##* }
ips=$(ifconfig $GWIF | grep 'inet ')
export IP=$(echo $ips | cut -d' ' -f2 | cut -d':' -f2)
export NETID=${IP%.*}
export GW=$(route -n | grep -e '^0.0.0.0' | tr -s \ - | cut -d ' ' -f2)
export PATH="/home/bigred/tk/bin:/home/bigred/wulin/bin:/home/bigred/kind/bin:$PATH"
clear && sleep 2
echo "Welcome to Ubuntu Linux : `cat /etc/os-release | grep -w VERSION | cut -d '\"' -f 2`"
[ "$IP" != "" ] && echo "IP : $IP"
echo ""
export PS1="[\${STY#*.}]\u@\h:\w$ "
export KUBE_EDITOR="nano"
export NOW="--force --grace-period 0"
alias ping='ping -c 4 '
alias pingdup='sudo arping -D -I eth0 -c 2 '
alias dir='ls -alh '
alias poweroff='sudo poweroff; sleep 5'
alias reboot='sudo reboot; sleep 5'
alias kg='kubectl get'
alias ka='kubectl apply'
alias kd='kubectl delete'
alias kc='kubectl create'
alias ks='kubectl get pods -n kube-system'
alias docker='sudo podman'
alias pc='sudo podman system prune -a -f'
alias vms='sudo /usr/bin/vmware-toolbox-cmd disk shrink /'
alias kp='kubectl get pods -o wide -A | sed '\''s/(.*)//'\'' | tr -s '\'' '\'' | cut -d '\'' '\'' -f 1-4,7,8 | column -t'
alias kt='kubectl top'
alias dsize='sudo du -sh -- /* 2>/dev/null | sort -rh'
alias kgip="kubectl get pod --template '{{.status.podIP}}'"
alias dkimg='curl -X GET -s -u bigred:bigred http://dkreg.kube-system:5000/v2/_catalog | jq ".repositories[]"'
export KIND_EXPERIMENTAL_PROVIDER='podman kind create cluster'
[ $USER == "bigred" ] && sudo mount --make-rshared /
# 4. 設定 Rootless Podman
$ echo 'bigred:500000:65535' | sudo tee /etc/subuid
$ echo 'bigred:500000:65535' | sudo tee /etc/subgid
$ echo 'rbean:100000:65535' | sudo tee -a /etc/subuid
$ echo 'rbean:100000:65535' | sudo tee -a /etc/subgid
# 5. 關閉 swap (註解掉 /swapfile 那行)
$ sudo nano /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda5 during installation
UUID=69b47d93-2f82-40c5-864c-392f4b609b7a / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=C0A9-83BA /boot/efi vfat umask=0077 0 1
#/swapfile none swap sw 0 0
# 6. 啟用 IP Forward
$ sudo nano /etc/sysctl.conf
將 net.ipv4.ip_forward=1 取消註解
# 7. 重新開機
$ sudo reboot
# 8. 確認 OS 是否有啟用 cgroupVersion v2
$ cat /sys/fs/cgroup/cgroup.controllers
cpuset cpu io memory hugetlb pids rdma misc
# 9. 確認 podman cgroupVersion 版本
$ podman info | grep 'cgroupVersion'
cgroupVersion: v22. 建置 Taroko K8S
# 1. 下載 Taroko CDC 套件
$ wget http://www.oc99.org/zip/tk2025v1.0.zip; unzip tk2025v1.0.zip
# 2. 設定 tkllm K8S 叢集的 Gateway IP
## 修改 GWIP 變數的值,需設定與 VM 同網段的一個可用 IP
$ nano tk/conf/tkllm.conf
export TKIND="K8S"
export NTP="Internal"
# Container Configuration
export NID="172.22.72.0/24"
export NGW="172.22.72.254"
export IMG="docker.io/kindest/node:v1.32.0"
export LCTN="172.22.72.1:tkllm-control-plane:6G:2 \
172.22.72.2:tkllm-worker1:6G:2 \
172.22.72.3:tkllm-worker2:8G:2"
# K8S Configuration
export KVER="1.32.0"
export SVRIP="172.22.72.1"
export PNID="10.244.72.0/21"
export SNID="10.98.72.0/24"
# k8S Gateway Configuration
export TKGW="true"
export GWIF=""
export GWIP="10.103.105.32/24"
# 3. 建立 tkllm K8S 叢集
$ kto tkllm
[tkllm Cluster Infrastructure]
tkllm Network (Local:172.22.72.0/24) created
tkllm-control-plane container created
tkllm-worker1 container created
tkllm-worker2 container created
[tkllm K8S Cluster]
tkllm-control-plane ok
pod/kube-proxy-bmnw4 condition met
pod/canal-4ksn9 condition met
tkllm-worker1 join ok
tkllm-worker2 join ok
gVisor & crun ok
add label 'app=taroko' to tkllm-worker2
pod/metrics-server-8467fcc7b7-5q2rn condition met
Local Path Provisioner ok
pod/taroko-tkadm-56f4959c4-jvw8m condition met
tkadd-dnat.sh tkdel-dnat.sh created
tkllm-control-plane /etc/hosts ok
tkllm-worker1 /etc/hosts ok
tkllm-worker2 /etc/hosts ok
dkreg secret ok
tkllm: take office