From ee4198ce40336fd1eb5c183d54b277ffee64602b Mon Sep 17 00:00:00 2001 From: rohow Date: Tue, 23 Apr 2024 11:30:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(doc):=20=E6=96=87=E6=A1=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/README.md | 8 +++---- install/README.md | 47 ++++++++++++++++++++------------------- install/agent.config.yaml | 1 + 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/core/README.md b/core/README.md index 128acc9..de90ddb 100644 --- a/core/README.md +++ b/core/README.md @@ -1,12 +1,12 @@ ### 调试 -` +```shell kubectl run -i --tty --rm --restart=Never \ --overrides='{"apiVersion": "v1", "spec": {"nodeSelector": {"kubernetes.io/hostname": "tcc"}}}' \ --image=busybox:1.28 \ debug -- sh -` +``` ### path core中服务的节点亲和性 使他们只运行在master节点上 -` +```shell kubectl patch -n kube-system deployment coredns --patch-file=patch-affinity.yaml -` \ No newline at end of file +``` \ No newline at end of file diff --git a/install/README.md b/install/README.md index 288b911..bd7a3ff 100644 --- a/install/README.md +++ b/install/README.md @@ -1,64 +1,65 @@ ### 替换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 \ + 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 -` \ No newline at end of file +``` \ No newline at end of file diff --git a/install/agent.config.yaml b/install/agent.config.yaml index 3959c9a..3023410 100644 --- a/install/agent.config.yaml +++ b/install/agent.config.yaml @@ -3,6 +3,7 @@ server: "https://k3s.dev.cm:6443" token: "K1012101b9ab5a404897d6a0530f9dac014b571b374251e3741c95fd74e86cee2e5::server:97760133590f01e7a94ab320dfdbfe96" # 网络相关 +# 阿里云vps 需要添加 extraArgs=--netfilter-mode=off vpn-auth: "name=tailscale,joinKey=tskey-auth-ksJXXH4CNTRL-4WRkX448yC6W6yhytK1FD68HMDK4zStw" # 节点相关