diff --git a/README.md b/README.md index 46a9d86..bc73974 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -### k3s 部署仓库 +### k3s 部署仓库 让你快速拥有一个高可用的k3s集群 并且具有完备的生产级能力(监控、告警、防护、负载、备份) + +#### install 集群安装相关 +参见 [install/README.md](install/README.md) #### apps 相关应用 - -#### core 集群核心组件 - -#### install 集群安装相关 \ No newline at end of file +参见 [apps/README.md](apps/README.md) diff --git a/apps/infra/data/cloudnative-pg/helmchart.yaml b/apps/infra/data/cloudnative-pg/helmchart.yaml index 0faf858..721c419 100644 --- a/apps/infra/data/cloudnative-pg/helmchart.yaml +++ b/apps/infra/data/cloudnative-pg/helmchart.yaml @@ -19,6 +19,6 @@ spec: values: - "cn-sh" tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" diff --git a/apps/infra/data/postgresql-ha/helmchart.yaml b/apps/infra/data/postgresql-ha/helmchart.yaml index df38657..af2824d 100644 --- a/apps/infra/data/postgresql-ha/helmchart.yaml +++ b/apps/infra/data/postgresql-ha/helmchart.yaml @@ -29,7 +29,7 @@ spec: topologyKey: topology.kubernetes.io/region weight: 1 tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" image: @@ -66,7 +66,7 @@ spec: topologyKey: kubernetes.io/hostname weight: 1 tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" replicaCount: 1 diff --git a/apps/infra/devops/cert-manager/helmchart-dnspod.yaml b/apps/infra/devops/cert-manager/helmchart-dnspod.yaml index 736a3a4..892ae73 100644 --- a/apps/infra/devops/cert-manager/helmchart-dnspod.yaml +++ b/apps/infra/devops/cert-manager/helmchart-dnspod.yaml @@ -30,6 +30,6 @@ spec: values: - "cn-sh" tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" diff --git a/apps/infra/devops/cert-manager/helmchart.yaml b/apps/infra/devops/cert-manager/helmchart.yaml index 4981565..77d2cd9 100644 --- a/apps/infra/devops/cert-manager/helmchart.yaml +++ b/apps/infra/devops/cert-manager/helmchart.yaml @@ -21,7 +21,7 @@ spec: values: - "cn-sh" tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" prometheus: @@ -41,7 +41,7 @@ spec: values: - "cn-sh" tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" cainjector: @@ -55,6 +55,6 @@ spec: values: - "cn-sh" tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" diff --git a/apps/infra/devops/reflector/helmchart.yaml b/apps/infra/devops/reflector/helmchart.yaml index 369cfce..a132571 100644 --- a/apps/infra/devops/reflector/helmchart.yaml +++ b/apps/infra/devops/reflector/helmchart.yaml @@ -19,6 +19,6 @@ spec: values: - "cn-sh" tolerations: - - key: "node-role.kubernetes.io/master" + - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" diff --git a/install/README.md b/install/README.md index c7a11f2..f5ef31d 100644 --- a/install/README.md +++ b/install/README.md @@ -1,11 +1,23 @@ +## 安装方法 +需要在每个节点上执行以下命令 节点系统需求 debian 11+ ubuntu 20.04+ + ### 替换hostname +hostname为最终的节点名称 方便后期管理 ```shell -export HOSTNAME=node +export HOSTNAME=YOU_SHOULD_MODIFY_THIS_HOSTNAME hostnamectl set-hostname $HOSTNAME && reboot -vim /etc/hosts ``` -### 安装tailscale +### 安装tailscale 构建集群节点网络层 +如果是单机集群 可以不安装 但考虑到集群扩展性 此处推荐安装 +安装后请到tailscale官网申请一个auth key (免费服务) + +然后后续的节点安装时需要将config.yaml中的 `YOU_SHOULD_MODIFY_THIS_JOIN_KEY` 替换为你申请的auth key + +优势: +- 通过tailscale构建集群网络层 可以夸不同的云服务商进行组网 甚至是与内网环境下的服务器进行组网 (家里云启动~) +- tailscale的网络层是基于wireguard的 速度快、延迟低 可以动态路由不同的节点流量 + ```shell curl -fsSL https://tailscale.com/install.sh | sh ``` @@ -18,27 +30,44 @@ sysctl -p /etc/sysctl.d/99-tailscale.conf ``` ### 新建目录 将不同节点类型的config写入 +master-init.config.yaml 是第一个master节点的配置 +master.config.yaml 是master从节点的配置 +agent.config.yaml 是agent节点的配置 + +如果是单机集群 只需要将master-init.config.yaml中的内容写入到config.yaml中即可 + +将上述文件中的内容写入到此处 + ```shell mkdir -p /etc/rancher/k3s && vim /etc/rancher/k3s/config.yaml ``` ### 安装k3s 此处注意安装类型 是server 还是 agent +如果是agent节点 请将最后的server替换为agent ```shell curl -sfL https://get.k3s.io | \ INSTALL_K3S_VERSION=v1.32.3+k3s1 \ - INSTALL_K3S_MIRROR=cn \ - sh -s - agent + sh -s - server ``` -### 国内安装加速 & 镜像加速地址 +### 国内安装加速 -https://rancher-mirror.rancher.cn/k3s/k3s-install.sh +如果服务器在国内 请使用国内的安装脚本 +```shell +curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | \ + INSTALL_K3S_VERSION=v1.32.3+k3s1 \ + INSTALL_K3S_MIRROR=cn \ + sh -s - server +``` +### 镜像加速地址 +如果服务器在国内 请将registries.yaml文件内容写入到此处 ```shell vim /etc/rancher/k3s/registries.yaml ``` -### 查看serverToken 记得在config中替换最新的token +### 查看serverToken +如果后续安装从节点 或者工作节点 需要将master.config.yaml中的token替换为此处的token ```shell cat /var/lib/rancher/k3s/server/node-token ``` @@ -48,6 +77,8 @@ cat /var/lib/rancher/k3s/server/node-token cat /etc/rancher/k3s/k3s.yaml ``` +## 以下为集群安装后的优化操作 可以选择性的执行 + ### 给node添加地域标签 ```shell kubectl label nodes tca topology.kubernetes.io/region=cn-sh