文件
k3s/install/README.md
T
2024-04-23 11:30:16 +08:00

65 行
1.5 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
```
### 开启tailscale的自动更新
```shell
tailscale set --auto-update
```
### 开启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.28.8+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
```