文件
k3s/install/README.md
T

67 行
1.6 KiB
Markdown

### 替换hostname
```shell
export HOSTNAME=node
hostnamectl set-hostname $HOSTNAME && reboot
vim /etc/hosts
```
### 安装tailscale
```shell
curl -fsSL https://tailscale.com/install.sh | sh
```
### 开启ip转发
```shell
echo 'net.ipv4.ip_forward = 1' | tee -a /etc/sysctl.d/99-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | tee -a /etc/sysctl.d/99-tailscale.conf
sysctl -p /etc/sysctl.d/99-tailscale.conf
```
### 新建目录 将不同节点类型的config写入
```shell
mkdir -p /etc/rancher/k3s && vim /etc/rancher/k3s/config.yaml
```
### 安装k3s 此处注意安装类型 是server 还是 agent
```shell
curl -sfL https://get.k3s.io | \
INSTALL_K3S_VERSION=v1.30.5+k3s1 \
INSTALL_K3S_MIRROR=cn \
sh -s - server
```
### 国内安装加速 & 镜像加速地址
https://rancher-mirror.rancher.cn/k3s/k3s-install.sh
```shell
vim /etc/rancher/k3s/registries.yaml
```
### 查看serverToken 记得在config中替换最新的token
```shell
cat /var/lib/rancher/k3s/server/node-token
```
### 查看api server config 需要替换到.kube/config中 注意将其中的server地址替换为高可用地址
```shell
cat /etc/rancher/k3s/k3s.yaml
```
### 给node添加地域标签
```shell
kubectl label nodes tca topology.kubernetes.io/region=cn-sh
kubectl label nodes tca svccontroller.k3s.cattle.io/enablelb="true"
```
### 给master节点添加污点
```shell
kubectl taint nodes tca node-role.kubernetes.io/master:NoSchedule
```
### 节点网络优化
可以在需要加速的节点屏蔽目标ip 比如85.113.71.11 让tailscale强制走drep服务器进行加速
```shell
iptables -A OUTPUT -p udp --dport 41641 -d 85.113.71.11 -j DROP
```